fix(ci): keep CUDA stubs when GPU not available

Without nvidia RuntimeClass, there's no real libcuda.so in the
container. The before_script was stripping CUDA stubs, leaving test
binaries (like backtesting) unable to load libcuda.so.1.

Now nvidia-smi is checked first: if GPU present, strip stubs (real
CUDA from RuntimeClass). If no GPU, keep stubs so CUDA-linked test
binaries can load. CUDA compute cap defaults to 89 (L4).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jgrusewski
2026-02-27 12:16:25 +01:00
parent 5f2d7d670a
commit 74944b1696

View File

@@ -206,16 +206,20 @@ test:
- name: redis:7-alpine
alias: redis
script:
# Remove CUDA stubs from LD_LIBRARY_PATH — nvidia RuntimeClass provides real libcuda.so
- export LD_LIBRARY_PATH=$(echo "$LD_LIBRARY_PATH" | tr ':' '\n' | grep -v stubs | tr '\n' ':' | sed 's/:$//')
- nvidia-smi || echo "nvidia-smi not available (no GPU RuntimeClass) — compile-only mode"
# Detect GPU compute capability and partition sccache per architecture
# Falls back to 89 (L4) when nvidia-smi unavailable (compile jobs don't need GPU)
- export CUDA_COMPUTE_CAP=$(nvidia-smi --query-gpu=compute_cap --format=csv,noheader 2>/dev/null | head -1 | tr -d '.' || echo "89")
- export CUDA_COMPUTE_CAP=${CUDA_COMPUTE_CAP:-89}
- echo "CUDA_COMPUTE_CAP=$CUDA_COMPUTE_CAP"
- export SCCACHE_DIR="/mnt/sccache/sm_${CUDA_COMPUTE_CAP}"
- mkdir -p "$SCCACHE_DIR"
# Detect GPU: if nvidia-smi works, strip stubs (real libcuda.so from RuntimeClass)
# If no GPU, keep stubs so CUDA-linked test binaries can at least load
- |
if nvidia-smi 2>/dev/null; then
echo "GPU detected — stripping CUDA stubs from LD_LIBRARY_PATH"
export LD_LIBRARY_PATH=$(echo "$LD_LIBRARY_PATH" | tr ':' '\n' | grep -v stubs | tr '\n' ':' | sed 's/:$//')
export CUDA_COMPUTE_CAP=$(nvidia-smi --query-gpu=compute_cap --format=csv,noheader | head -1 | tr -d '.')
else
echo "No GPU detected — keeping CUDA stubs for test binary loading"
export CUDA_COMPUTE_CAP=89
fi
echo "CUDA_COMPUTE_CAP=$CUDA_COMPUTE_CAP"
export SCCACHE_DIR="/mnt/sccache/sm_${CUDA_COMPUTE_CAP}"
mkdir -p "$SCCACHE_DIR"
# Wait for Redis sidecar (K8s executor doesn't wait for service readiness)
- |
for i in $(seq 1 30); do
@@ -251,12 +255,16 @@ compile-services:
- if: $CI_PIPELINE_SOURCE == "web" || $CI_PIPELINE_SOURCE == "api"
script:
# Detect GPU compute capability and partition sccache per architecture
# Falls back to 89 (L4) when nvidia-smi unavailable (compile doesn't need GPU)
- export CUDA_COMPUTE_CAP=$(nvidia-smi --query-gpu=compute_cap --format=csv,noheader 2>/dev/null | head -1 | tr -d '.' || echo "89")
- export CUDA_COMPUTE_CAP=${CUDA_COMPUTE_CAP:-89}
- echo "CUDA_COMPUTE_CAP=$CUDA_COMPUTE_CAP"
- export SCCACHE_DIR="/mnt/sccache/sm_${CUDA_COMPUTE_CAP}"
- mkdir -p "$SCCACHE_DIR"
- |
if nvidia-smi 2>/dev/null; then
export CUDA_COMPUTE_CAP=$(nvidia-smi --query-gpu=compute_cap --format=csv,noheader | head -1 | tr -d '.')
else
echo "No GPU — keeping CUDA stubs, defaulting compute cap to 89 (L4)"
export CUDA_COMPUTE_CAP=89
fi
echo "CUDA_COMPUTE_CAP=$CUDA_COMPUTE_CAP"
export SCCACHE_DIR="/mnt/sccache/sm_${CUDA_COMPUTE_CAP}"
mkdir -p "$SCCACHE_DIR"
- sccache --zero-stats || true
# Select build profile: dev-release (fast, thin LTO) or release (full, fat LTO)
- PROFILE=${DEV_RELEASE:+dev-release}; PROFILE=${PROFILE:-release}