-
Notifications
You must be signed in to change notification settings - Fork 223
cuda.pathfinder._find_nvidia_header_directory(): add support for CTK libs
#956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
c4955e4
New supported_nvidia_headers.py, starting with just SUPPORTED_HEADERS…
rwgk d3b1a98
Add _find_ctk_header_directory(), currently for site-packages only.
rwgk 12beef6
Factor out get_cuda_home_or_path() into new cuda/pathfinder/_utils/en…
rwgk a37d132
Add CUDA_HOME code in find_nvidia_headers.py
rwgk 2a397b6
Formalize supported_nvidia_headers.CCCL_LIBNAMES
rwgk e0a22fa
Add CONDA_PREFIX code in find_nvidia_headers.py
rwgk 160d8a4
Add `shutil.which("nvcc")` code in find_nvidia_headers.py
rwgk 946721f
Cleanup: add _joined_isfile() helper
rwgk 656a30d
find_nvidia_header_directory(): return _abs_norm()
rwgk fb362ae
Merge branch 'main' into supported_nvidia_headers
rwgk 0d4e5a8
Bump pathfinder version to 1.2.3a0
rwgk 0629da2
Replace libcudacxx,cub,thrust with cccl. Add cuda-toolkit[cccl] to nv…
rwgk c7cabd8
SUPPORTED_HEADERS_CTK_LINUX_ONLY etc. (for cufile)
rwgk 6d51ffb
Merge branch 'main' into supported_nvidia_headers
rwgk 72db46d
Insert _find_based_on_conda_layout()
rwgk 601449e
Merge branch 'main' into supported_nvidia_headers
rwgk 6234000
Remove `shutil.which("nvcc")` code (it finds all includes on Windows …
rwgk 4d4ff77
Remove cccl code
rwgk 03bdbad
conda windows support
rwgk 8cefd27
Merge branch 'main' into supported_nvidia_headers
rwgk 0c5f6c2
Replace cusolver_common.h → cusolverDn.h
rwgk 1876f16
UserWarning: Both CUDA_HOME and CUDA_PATH are set but differ
rwgk 826398d
Remove `cccl` again in pyproject.toml
rwgk 607e9ef
Merge branch 'main' into supported_nvidia_headers
rwgk c023a01
Revert "Remove `cccl` again in pyproject.toml"
rwgk 476da62
Revert "Remove cccl code"
rwgk d42465e
Remove `cuda-cccl` include path in SUPPORTED_SITE_PACKAGE_HEADER_DIRS…
rwgk 17221d6
Apply reviewer suggestion:
rwgk aea31bb
Add find_nvidia_header_directory docstring.
rwgk 5774471
Add _SUPPORTED_HEADERS_CTK to public API
rwgk 306684d
Add cuda_pathfinder 1.2.3 Release notes
rwgk eee4929
Merge branch 'main' into supported_nvidia_headers
rwgk 9f55b7e
Merge branch 'main' into supported_nvidia_headers
rwgk caf4e52
Remove leading underscores: _SUPPORTED_HEADERS_CTK, _find_nvidia_head…
rwgk 3faea76
docstring in __init__.py, using `#: ` Sphinx-specific markup
rwgk 5e1146c
Bump pathfinder version to 1.2.3 (for release) and change release dat…
rwgk f31f93a
Merge branch 'main' into supported_nvidia_headers
rwgk 59de489
Make comment less ambiguous.
rwgk 410d866
Remove subtitle as suggested by reviewer.
rwgk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,25 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """cuda.pathfinder public APIs""" | ||
|
|
||
| from cuda.pathfinder._dynamic_libs.load_dl_common import DynamicLibNotFoundError as DynamicLibNotFoundError | ||
| from cuda.pathfinder._dynamic_libs.load_dl_common import LoadedDL as LoadedDL | ||
| from cuda.pathfinder._dynamic_libs.load_nvidia_dynamic_lib import load_nvidia_dynamic_lib as load_nvidia_dynamic_lib | ||
| from cuda.pathfinder._dynamic_libs.supported_nvidia_libs import ( | ||
| SUPPORTED_LIBNAMES as SUPPORTED_NVIDIA_LIBNAMES, # noqa: F401 | ||
| ) | ||
| from cuda.pathfinder._headers.find_nvidia_headers import ( | ||
| find_nvidia_header_directory as _find_nvidia_header_directory, # noqa: F401 | ||
| ) | ||
| from cuda.pathfinder._headers.find_nvidia_headers import find_nvidia_header_directory as find_nvidia_header_directory | ||
| from cuda.pathfinder._headers.supported_nvidia_headers import SUPPORTED_HEADERS_CTK as _SUPPORTED_HEADERS_CTK | ||
| from cuda.pathfinder._version import __version__ as __version__ | ||
|
|
||
| # Indirection to help Sphinx find the docstring. | ||
| #: Mapping from short CUDA Toolkit (CTK) library names to their canonical | ||
| #: header basenames (used to validate a discovered include directory). | ||
| #: Example: ``"cublas" → "cublas.h"``. The key set is platform-aware | ||
| #: (e.g., ``"cufile"`` may be Linux-only). | ||
| SUPPORTED_HEADERS_CTK = _SUPPORTED_HEADERS_CTK | ||
|
|
||
| # Backward compatibility: _find_nvidia_header_directory was added in release 1.2.2. | ||
| # It will be removed in release 1.2.4. | ||
| _find_nvidia_header_directory = find_nvidia_header_directory |
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
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
60 changes: 60 additions & 0 deletions
60
cuda_pathfinder/cuda/pathfinder/_headers/supported_nvidia_headers.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import sys | ||
| from typing import Final | ||
|
|
||
| IS_WINDOWS = sys.platform == "win32" | ||
|
|
||
| SUPPORTED_HEADERS_CTK_COMMON = { | ||
| "cccl": "cuda/std/version", | ||
| "cublas": "cublas.h", | ||
| "cudart": "cuda_runtime.h", | ||
| "cufft": "cufft.h", | ||
| "curand": "curand.h", | ||
| "cusolver": "cusolverDn.h", | ||
| "cusparse": "cusparse.h", | ||
| "npp": "npp.h", | ||
| "nvcc": "fatbinary_section.h", | ||
| "nvfatbin": "nvFatbin.h", | ||
| "nvjitlink": "nvJitLink.h", | ||
| "nvjpeg": "nvjpeg.h", | ||
| "nvrtc": "nvrtc.h", | ||
| "nvvm": "nvvm.h", | ||
| } | ||
|
|
||
| SUPPORTED_HEADERS_CTK_LINUX_ONLY = { | ||
| "cufile": "cufile.h", | ||
| } | ||
| SUPPORTED_HEADERS_CTK_LINUX = SUPPORTED_HEADERS_CTK_COMMON | SUPPORTED_HEADERS_CTK_LINUX_ONLY | ||
|
|
||
| SUPPORTED_HEADERS_CTK_WINDOWS_ONLY: dict[str, str] = {} | ||
| SUPPORTED_HEADERS_CTK_WINDOWS = SUPPORTED_HEADERS_CTK_COMMON | SUPPORTED_HEADERS_CTK_WINDOWS_ONLY | ||
|
|
||
| SUPPORTED_HEADERS_CTK_ALL = ( | ||
| SUPPORTED_HEADERS_CTK_COMMON | SUPPORTED_HEADERS_CTK_LINUX_ONLY | SUPPORTED_HEADERS_CTK_WINDOWS_ONLY | ||
| ) | ||
| SUPPORTED_HEADERS_CTK: Final[dict[str, str]] = ( | ||
| SUPPORTED_HEADERS_CTK_WINDOWS if IS_WINDOWS else SUPPORTED_HEADERS_CTK_LINUX | ||
| ) | ||
|
|
||
| SUPPORTED_SITE_PACKAGE_HEADER_DIRS_CTK = { | ||
| "cccl": ( | ||
| "nvidia/cu13/include/cccl", # cuda-toolkit[cccl]==13.* | ||
| "nvidia/cuda_cccl/include", # cuda-toolkit[cccl]==12.* | ||
| ), | ||
| "cublas": ("nvidia/cu13/include", "nvidia/cublas/include"), | ||
| "cudart": ("nvidia/cu13/include", "nvidia/cuda_runtime/include"), | ||
| "cufft": ("nvidia/cu13/include", "nvidia/cufft/include"), | ||
| "cufile": ("nvidia/cu13/include", "nvidia/cufile/include"), | ||
| "curand": ("nvidia/cu13/include", "nvidia/curand/include"), | ||
| "cusolver": ("nvidia/cu13/include", "nvidia/cusolver/include"), | ||
| "cusparse": ("nvidia/cu13/include", "nvidia/cusparse/include"), | ||
| "npp": ("nvidia/cu13/include", "nvidia/npp/include"), | ||
| "nvcc": ("nvidia/cu13/include", "nvidia/cuda_nvcc/include"), | ||
| "nvfatbin": ("nvidia/cu13/include", "nvidia/nvfatbin/include"), | ||
| "nvjitlink": ("nvidia/cu13/include", "nvidia/nvjitlink/include"), | ||
| "nvjpeg": ("nvidia/cu13/include", "nvidia/nvjpeg/include"), | ||
| "nvrtc": ("nvidia/cu13/include", "nvidia/cuda_nvrtc/include"), | ||
| "nvvm": ("nvidia/cu13/include", "nvidia/cuda_nvcc/nvvm/include"), | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import os | ||
| import warnings | ||
| from typing import Optional | ||
|
|
||
|
|
||
| def _paths_differ(a: str, b: str) -> bool: | ||
| """ | ||
| Return True if paths are observably different. | ||
|
|
||
| Strategy: | ||
| 1) Compare os.path.normcase(os.path.normpath(...)) for quick, robust textual equality. | ||
| - Handles trailing slashes and case-insensitivity on Windows. | ||
| 2) If still different AND both exist, use os.path.samefile to resolve symlinks/junctions. | ||
| 3) Otherwise (nonexistent paths or samefile unavailable), treat as different. | ||
| """ | ||
| norm_a = os.path.normcase(os.path.normpath(a)) | ||
| norm_b = os.path.normcase(os.path.normpath(b)) | ||
| if norm_a == norm_b: | ||
| return False | ||
|
|
||
| try: | ||
| if os.path.exists(a) and os.path.exists(b): | ||
| # samefile raises on non-existent paths; only call when both exist. | ||
| return not os.path.samefile(a, b) | ||
| except OSError: | ||
| # Fall through to "different" if samefile isn't applicable/available. | ||
| pass | ||
|
|
||
| # If normalized strings differ and we couldn't prove they're the same entry, treat as different. | ||
| return True | ||
|
|
||
|
|
||
| def get_cuda_home_or_path() -> Optional[str]: | ||
| cuda_home = os.environ.get("CUDA_HOME") | ||
| cuda_path = os.environ.get("CUDA_PATH") | ||
|
|
||
| if cuda_home and cuda_path and _paths_differ(cuda_home, cuda_path): | ||
| warnings.warn( | ||
| "Both CUDA_HOME and CUDA_PATH are set but differ:\n" | ||
| f" CUDA_HOME={cuda_home}\n" | ||
| f" CUDA_PATH={cuda_path}\n" | ||
| "Using CUDA_HOME (higher priority).", | ||
| UserWarning, | ||
| stacklevel=2, | ||
| ) | ||
|
|
||
| if cuda_home is not None: | ||
| return cuda_home | ||
| return cuda_path |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| __version__ = "1.2.2" | ||
| __version__ = "1.2.3" |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| .. SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| .. module:: cuda.pathfinder | ||
|
|
||
| ``cuda-pathfinder`` 1.2.3 Release notes | ||
| ======================================= | ||
|
|
||
| Released on Sep 17, 2025 | ||
|
|
||
|
|
||
| Highlights | ||
| ---------- | ||
|
|
||
| * Extend experimental ``cuda.pathfinder._find_nvidia_headers`` API | ||
| to support CTK library headers | ||
| (`PR #956 <https://github.com/NVIDIA/cuda-python/pull/956>`_) |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.