Skip to content

Improve setup.py CUDA detection and pin NumPy - #339

Merged
cuddandr merged 3 commits into
developfrom
improve_setup_py
Oct 16, 2026
Merged

cuddandr merged 3 commits into
developfrom
improve_setup_py

Conversation

@cuddandr

Copy link
Copy Markdown
Collaborator

Improve/expand the logic to detect if CUDA is available and the major version for choosing which CuPy and numba-cuda to install.

The original method was fragile and solely relied on CUDA_HOME being set in a particular format. This now tries the nvcc compiler first and then falls back to CUDA_HOME and uses a regex to more robustly get the version number. It still enforces a minimum CUDA version, and has more info output when installing.

Somewhat separately, pin NumPy to >=2.0,<2.5 to stop row_stack missing errors since numba-cuda still relies on it being present.

Tested on NERSC Perlmutter and TACC Vista for checking that setup.py detects the correct CUDA.

Improve the CUDA version detection in setup.py to use multiple methods.

First it tries to read it from the `nvcc` CUDA compiler, and then checks
CUDA_HOME if the compiler check fails. The logic for CUDA_HOME was also
improved to be more robust.

The logic for adding the correct version of CuPy (or skipping it) was
also tweaked, and new print statements for better clarity when
installing.
While Numba itself has fixed the use of NumPy row_stack (which was
removed in 2.5+), numba-cuda still relies on it and will cause a crash
if NumPy 2.5+ is installed (which is our current default).

Pin NumPy to use something before 2.5 so row_stack is still available
for numba-cuda (usually 2.4.6).

Once we move to numba-cuda-mlir this is no longer a problem.
The new setup.py will throw a runtime error if CUDA is not detected
unless told to skip the CuPy install.

Set SKIP_CUPY_INSTALL in the workflow so the docs build.
@cuddandr
cuddandr merged commit 2cff4e8 into develop Oct 16, 2026
2 checks passed
@cuddandr
cuddandr deleted the improve_setup_py branch October 16, 2026 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant