Repository navigation
Improve setup.py CUDA detection and pin NumPy - #339
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_HOMEbeing set in a particular format. This now tries thenvcccompiler first and then falls back toCUDA_HOMEand 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_stackmissing 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.