Skip to content

arch: Fix get_cuda_version when nvcc is missing - #3087

Open
saqibkh wants to merge 1 commit into
devitocodes:mainfrom
saqibkh:cuda-version-without-nvcc
Open

saqibkh wants to merge 1 commit into
devitocodes:mainfrom
saqibkh:cuda-version-without-nvcc

Conversation

@saqibkh

@saqibkh saqibkh commented Oct 23, 2026

Copy link
Copy Markdown

Fixes #3085.

get_cuda_version read out.returncode in a finally block. When nvcc isn't installed, run raises FileNotFoundError, which is swallowed, and then out is unbound, so the function raised UnboundLocalError instead of returning None. It now uses else.

With that fixed, CudaCompiler.std would fail next, with AttributeError on None.major. It now treats a missing version as pre-CUDA 13 and uses c++14, so code generation for the CUDA target without a toolchain works until compile time.

Tests: test_get_cuda_version_without_nvcc and test_cuda_std_without_nvcc in tests/test_arch.py. Both fail on main (UnboundLocalError and AttributeError) and pass with this change. I also ran the issue's repro with an empty PATH: get_cuda_version() now returns None and CudaCompiler(...).std gives c++14. All 21 tests in tests/test_arch.py pass and ruff check is clean.

I didn't touch the caller in devitopro that the issue mentions, since it isn't in this repository.

The finally block read out.returncode even when run() had raised
FileNotFoundError, so out was unbound. Use else instead, so the function
returns None, and have CudaCompiler.std treat None as a pre-CUDA 13 toolkit.
@mloubout mloubout added the arch jitting, archinfo, ... label Oct 24, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch jitting, archinfo, ...

Projects

None yet

Development

Successfully merging this pull request may close these issues.

arch: get_cuda_version raises UnboundLocalError when nvcc is missing

2 participants