Add Linux static CUDA toolkit engine build profile
This commit is contained in:
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
build_dir="${STRATA_BUILD_DIR:-${repo_root}/artifacts/build-static-cuda}"
|
||||
jobs="${BUILD_JOBS:-2}"
|
||||
[[ "$(uname -s)" == Linux ]] || { echo 'Static CUDA engine builds require Linux.' >&2; exit 1; }
|
||||
|
||||
# CUDACXX/CUDAToolkit_ROOT select an existing toolkit; STRATA_GGML_DIR avoids fetching GGML.
|
||||
extra=()
|
||||
if [[ -n "${STRATA_GGML_DIR:-}" ]]; then
|
||||
extra+=("-DSTRATA_GGML_DIR=${STRATA_GGML_DIR}")
|
||||
fi
|
||||
cmake -S "${repo_root}/engine/strata" -B "${build_dir}" \
|
||||
-DSTRATA_ENABLE_CUDA=ON -DSTRATA_ENABLE_HIP=OFF -DSTRATA_CUDA_STATIC=ON \
|
||||
-DCMAKE_BUILD_TYPE=Release -DCMAKE_CUDA_ARCHITECTURES="${CUDA_ARCHITECTURES:-120}" \
|
||||
-DSTRATA_BUILD_TESTS=OFF -DSTRATA_NATIVE_EXPERTS=ON \
|
||||
-DSTRATA_PORTABLE=ON "${extra[@]}"
|
||||
cmake --build "${build_dir}" --parallel "${jobs}" --target strata
|
||||
python3 "${repo_root}/scripts/check-static-cuda-elf.py" "${build_dir}/strata"
|
||||
# generate.cpp handles --help before any model or GPU initialization.
|
||||
env -u LD_LIBRARY_PATH CUDA_VISIBLE_DEVICES= "${build_dir}/strata" --help
|
||||
@@ -7,6 +7,7 @@ python3 -m py_compile "${repo_root}/scripts/prepare-keyless-routing.py" "${repo_
|
||||
python3 "${repo_root}/scripts/test-benchmark-harness.py"
|
||||
python3 "${repo_root}/scripts/test-native-service.py"
|
||||
python3 "${repo_root}/scripts/test-native-api.py"
|
||||
python3 "${repo_root}/scripts/test-static-cuda-elf.py"
|
||||
python3 "${repo_root}/scripts/test-keyless-routing.py"
|
||||
|
||||
cargo fmt --manifest-path "${repo_root}/control-plane/Cargo.toml" --check
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only ELF packaging gate; does not execute the engine or initialize CUDA."""
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def inspect(binary):
|
||||
output = subprocess.check_output(['readelf', '-dW', str(binary)], text=True)
|
||||
needed = re.findall(r'\(NEEDED\).*?\[(.*?)\]', output)
|
||||
allowed = {'libc.so.6', 'libm.so.6', 'libdl.so.2', 'libpthread.so.0', 'librt.so.1',
|
||||
'ld-linux-x86-64.so.2', 'ld-linux-aarch64.so.1'}
|
||||
unexpected = sorted(set(needed) - allowed)
|
||||
if unexpected:
|
||||
raise RuntimeError('Unexpected shared libraries in static CUDA profile: ' + ', '.join(unexpected))
|
||||
if '(RPATH)' in output or '(RUNPATH)' in output:
|
||||
raise RuntimeError('Static CUDA engine must not retain a build-host library path')
|
||||
if 'libc.so.6' not in needed:
|
||||
raise RuntimeError('Expected a glibc-linked Linux engine; inspect this artifact manually')
|
||||
headers = subprocess.check_output(['readelf', '-lW', str(binary)], text=True)
|
||||
if 'INTERP' not in headers:
|
||||
raise RuntimeError('Expected a host dynamic loader for the glibc-linked engine')
|
||||
symbols = subprocess.check_output(['readelf', '--version-info', str(binary)], text=True)
|
||||
versions = {tuple(int(part) for part in value.split('.'))
|
||||
for value in re.findall(r'\bGLIBC_([0-9]+(?:\.[0-9]+)+)', symbols)}
|
||||
if not versions:
|
||||
raise RuntimeError('Unable to identify the minimum symbol-versioned glibc requirement')
|
||||
return {'bytes': binary.stat().st_size, 'needed': needed, 'toolkit_shared_libraries': False,
|
||||
'host_glibc_required': True, 'minimum_glibc': '.'.join(map(str, max(versions))),
|
||||
'nvidia_driver_required': True, 'gpu_tested': False,
|
||||
'scope': 'ELF direct dependencies; runtime dlopen requirements need GPU qualification'}
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(json.dumps(inspect(Path(sys.argv[1]).resolve())))
|
||||
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Exercise ELF dependency gates with CPU fixtures, without a CUDA toolchain."""
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
spec = importlib.util.spec_from_file_location('audit', Path(__file__).with_name('check-static-cuda-elf.py'))
|
||||
audit = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(audit)
|
||||
|
||||
|
||||
@unittest.skipUnless(sys.platform == 'linux' and shutil.which('cc') and shutil.which('readelf'),
|
||||
'Linux C compiler and readelf required')
|
||||
class ElfGateTests(unittest.TestCase):
|
||||
def test_dependency_closure_and_host_path_rejection(self):
|
||||
with tempfile.TemporaryDirectory(prefix='strata-elf-gate-') as directory:
|
||||
root = Path(directory)
|
||||
source = root / 'fixture.c'
|
||||
source.write_text('#include <stdio.h>\nint main(void) { puts("fixture"); return 0; }\n')
|
||||
executable = root / 'fixture'
|
||||
def compile(*extra):
|
||||
subprocess.run(['cc', str(source), '-o', str(executable), *extra], check=True, capture_output=True)
|
||||
compile()
|
||||
self.assertTrue(audit.inspect(executable)['host_glibc_required'])
|
||||
compile('-Wl,-rpath,/private/build/toolkit')
|
||||
with self.assertRaisesRegex(RuntimeError, 'build-host'):
|
||||
audit.inspect(executable)
|
||||
library_source = root / 'library.c'
|
||||
library_source.write_text('void fake_cuda_symbol(void) {}\n')
|
||||
library = root / 'libfixture.so'
|
||||
subprocess.run(['cc', '-shared', '-fPIC', str(library_source),
|
||||
'-Wl,-soname,libcudart.so.13', '-o', str(library)], check=True, capture_output=True)
|
||||
compile('-Wl,--no-as-needed', str(library))
|
||||
with self.assertRaisesRegex(RuntimeError, 'libcudart.so.13'):
|
||||
audit.inspect(executable)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user