@@ -78,16 +78,26 @@ print(f'{mj}.{mn}')"
7878}
7979
8080if [ " ${GPU_BACKEND} " = " CUDA" ]; then
81- detected_cc=" $( detect_with_torch) " || {
82- echo " ERROR: torch-based CUDA arch detection failed in uv environment." >&2
83- echo " Ensure torch is installed and CUDA is available in the uv-selected Python." >&2
84- exit 1
85- }
86-
87- cc_major=" ${detected_cc%% .* } "
88- cc_minor=" ${detected_cc##* .} "
81+ # Compute capability drives the arch/TK defaults below. Prefer an explicit
82+ # TORCH_CUDA_ARCH_LIST (works on GPU-less build machines such as CI/Docker);
83+ # only probe a live GPU via torch when no arch was provided.
84+ if [ -n " ${TORCH_CUDA_ARCH_LIST:- } " ]; then
85+ echo " Using TORCH_CUDA_ARCH_LIST=${TORCH_CUDA_ARCH_LIST} (skipping torch GPU probe)"
86+ first_arch=" ${TORCH_CUDA_ARCH_LIST%% [;, ]* } " # first entry, e.g. 9.0a
87+ first_arch=" ${first_arch% [af]} " # strip trailing a/f suffix
88+ cc_major=" ${first_arch%% .* } "
89+ cc_minor=" ${first_arch##* .} "
90+ else
91+ detected_cc=" $( detect_with_torch) " || {
92+ echo " ERROR: torch-based CUDA arch detection failed and TORCH_CUDA_ARCH_LIST is unset." >&2
93+ echo " Set TORCH_CUDA_ARCH_LIST (e.g. 9.0a) for GPU-less builds, or build where CUDA is available." >&2
94+ exit 1
95+ }
96+ cc_major=" ${detected_cc%% .* } "
97+ cc_minor=" ${detected_cc##* .} "
98+ echo " Detected compute capability via torch: ${detected_cc} "
99+ fi
89100 cmake_arch=" ${cc_major}${cc_minor} "
90- echo " Detected compute capability via torch: ${detected_cc} (sm_${cmake_arch} )"
91101
92102 # Respect explicit overrides.
93103 if [ -z " ${TORCH_CUDA_ARCH_LIST:- } " ]; then
0 commit comments