[FEA] Centralize CUDA environment variable handling and prioritize CUDA_PATH over CUDA_HOME#1519
[FEA] Centralize CUDA environment variable handling and prioritize CUDA_PATH over CUDA_HOME#1519rparolin wants to merge 14 commits intoNVIDIA:mainfrom
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
/ok to test |
|
Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
/ok to test |
|
/ok to test |
|
/ok to test |
|
/ok to test |
|
|
/ok to test |
| "setuptools_scm[simple]>=8", | ||
| "cython>=3.2,<3.3", | ||
| "pyclibrary>=0.1.7", | ||
| "cuda-pathfinder", |
There was a problem hiding this comment.
It's already on line 34 below. Having it there seemed to work reliably in all situations?
|
This still uses the old pattern (seems like an easy fix):
This
should probably be updated to use pathfinder, similar to what I did here a few days ago: I could take care of that in a separate, small PR. Should I? |
| from cuda.pathfinder._utils.env_vars import get_cuda_home_or_path | ||
|
|
||
| CUDA_HOME = get_cuda_home_or_path() | ||
| except ImportError: |
There was a problem hiding this comment.
I don't think this fallback code is needed. cuda-bindings depends critically on cuda-pathfinder.
| Path to CUDA Toolkit, or None if neither variable is set. Empty strings are | ||
| preserved and returned as-is if explicitly set in the environment. |
There was a problem hiding this comment.
Hm, that seems like it could lead to confusing situations. Could we make it so that empty strings are equivalent to to undefined?
This PR introduces centralized CUDA environment variable handling across cuda-python packages with improved consistency and better handling of conflicting environment variable configurations.
The previous implicit priority of CUDA_HOME over CUDA_PATH was inconsistent with:
Key Changes
Breaking Change - Environment Variable Priority
Changed the search order priority from
CUDA_HOME > CUDA_PATHtoCUDA_PATH > CUDA_HOMEto align with NVIDIA tooling standards and industry conventions. This affects all packages that query CUDA Toolkit locations (cuda.pathfinder, cuda.core, cuda.bindings).New Module:
cuda.pathfinder._utils.env_var_constantsCUDA_ENV_VARS_ORDERED = ("CUDA_PATH", "CUDA_HOME")Enhanced
cuda.pathfinder._utils.env_varsget_cuda_home_or_path()with robust path comparison usingos.path.samefile()Closes #1433.