Skip to content

First version of cuda.bindings.path_finder #578

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

Open
wants to merge 58 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
147b242
First version of `cuda.bindings.path_finder` (#447)
rwgk Apr 9, 2025
7a0c068
Make `path_finder` work for `"nvrtc"` (#553)
rwgk Apr 10, 2025
32f6c76
Merge branch 'main' into path_finder_dev
rwgk Apr 25, 2025
74c9750
Add `path_finder.SUPPORTED_LIBNAMES` (#558)
rwgk Apr 25, 2025
00f8e4d
Fix tiny accident: a line in pyproject.toml got lost somehow.
rwgk Apr 25, 2025
17478da
Undo changes to the nvJitLink, nvrtc, nvvm bindings
rwgk Apr 25, 2025
7da74bd
Undo changes under .github, specific to nvvm, manipulating LD_LIBRARY…
rwgk Apr 25, 2025
211164d
PARTIALLY_SUPPORTED_LIBNAMES_LINUX, PARTIALLY_SUPPORTED_LIBNAMES_WINDOWS
rwgk Apr 25, 2025
a649e7d
Update EXPECTED_LIB_SYMBOLS for nvJitLink to cleanly support CTK vers…
rwgk Apr 25, 2025
b5cef1b
Save result of factoring out load_dl_common.py, load_dl_linux.py, loa…
rwgk Apr 25, 2025
bc0137a
Fix an auto-generated docstring
rwgk Apr 25, 2025
001a6a2
first round of Cursor refactoring (about 4 iterations until all tests…
rwgk Apr 26, 2025
9721079
Revert "first round of Cursor refactoring (about 4 iterations until a…
rwgk Apr 26, 2025
c409346
A couple trivial tweaks
rwgk Apr 26, 2025
ceff853
Merge branch 'main' into path_finder_dev
rwgk Apr 26, 2025
0cd20d8
Merge branch 'path_finder_dev' into path_finder_review1
rwgk Apr 26, 2025
b3a3b16
Prefix the public API (just two items) with underscores for now.
rwgk Apr 28, 2025
42cb9b6
Merge branch 'main' into path_finder_review1
rwgk Apr 29, 2025
180eefd
Add SPDX-License-Identifier to all files under toolshed/ that don't h…
rwgk Apr 29, 2025
bfc4b69
Add SPDX-License-Identifier under cuda_bindings/tests/
rwgk Apr 29, 2025
a7001e1
Respond to "Do these need to be run as subprocesses?" review question…
rwgk Apr 29, 2025
4d95eb4
Respond to "dead code?" review questions (e.g. https://github.com/NVI…
rwgk Apr 29, 2025
72c339a
Respond to "Do we need to implement a cache separately ..." review qu…
rwgk Apr 29, 2025
4ce94be
Remove cuDriverGetVersion() function for now.
rwgk Apr 29, 2025
26eb4b5
Move add_dll_directory() from load_dl_common.py to load_dl_windows.py…
rwgk Apr 29, 2025
72d2567
Add SPDX-License-Identifier and # Forked from: URL in cuda_paths.py
rwgk Apr 29, 2025
e14391d
Add Add SPDX-License-Identifier and Original LICENSE in findlib.py
rwgk Apr 29, 2025
9154995
Very first draft of README.md
rwgk Apr 29, 2025
bdfc6a7
Update README.md, mostly as revised by perplexity, with various manua…
rwgk Apr 29, 2025
2279bda
Merge branch 'main' into path_finder_review1
rwgk Apr 30, 2025
2ad4b79
Refork cuda_paths.py AS-IS: https://github.com/NVIDIA/numba-cuda/blob…
rwgk Apr 30, 2025
7dcaa50
ruff format cuda_paths.py (NO manual changes)
rwgk Apr 30, 2025
714b88c
Add back _get_numba_CUDA_INCLUDE_PATH from 2279bda65640b73a9a5632df87…
rwgk Apr 30, 2025
166837d
Remove cuda_paths.py dependency on numba.cuda.cudadrv.runtime
rwgk Apr 30, 2025
ad1e85e
Add Forked from URLs, two SPDX-License-Identifier, Original Numba LIC…
rwgk Apr 30, 2025
47ad79f
Temporarily restore debug changes under .github/workflows, for expand…
rwgk Apr 30, 2025
1b88ec2
Restore cuda_path.py AS-IT-WAS at commit 2279bda65640b73a9a5632df878f…
rwgk Apr 30, 2025
db79ec3
Revert "Restore cuda_path.py AS-IT-WAS at commit 2279bda65640b73a9a56…
rwgk Apr 30, 2025
2bc7ef6
Force compute-sanitizer off unconditionally
rwgk Apr 30, 2025
7650b2e
Revert "Force compute-sanitizer off unconditionally"
rwgk Apr 30, 2025
b79e85b
Add timeout=10 seconds to test_path_finder.py subprocess.run() invoca…
rwgk Apr 30, 2025
f9a9e9f
Increase test_path_finder.py subprocess.run() timeout to 30 seconds:
rwgk Apr 30, 2025
7f76683
Revert "Temporarily restore debug changes under .github/workflows, fo…
rwgk Apr 30, 2025
aeaf4f0
Force compute-sanitizer off unconditionally
rwgk Apr 30, 2025
6a60161
Add: Note that the search is done on a per-library basis.
rwgk Apr 30, 2025
3277ac5
Add Note for CUDA_HOME / CUDA_PATH
rwgk Apr 30, 2025
1d4420b
Add 0. **Check if a library was loaded into the process already by so…
rwgk Apr 30, 2025
4437fcc
_find_dll_using_nvidia_bin_dirs(): reuse lib_searched_for in place of…
rwgk Apr 30, 2025
fd20253
Systematically replace all relative imports with absolute imports.
rwgk Apr 30, 2025
703988c
handle: int → ctypes.CDLL fix
rwgk Apr 30, 2025
28349a7
Make load_dl_windows.py abs_path_for_dynamic_library() implementation…
rwgk Apr 30, 2025
c55104c
Change argument name → libname for self-consistency
rwgk Apr 30, 2025
b32ed13
Systematically replace previously overlooked relative imports with ab…
rwgk Apr 30, 2025
92e7b42
Simplify code (also for self-consistency)
rwgk Apr 30, 2025
5a835d7
Expand the 3. **System Installations** section with information produ…
rwgk May 1, 2025
b910a6b
Pull out `**Environment variables**` into an added section, after man…
rwgk May 1, 2025
0fa2c83
Merge branch 'main' into path_finder_review1
rwgk May 1, 2025
fc22b1d
Revert "Force compute-sanitizer off unconditionally"
rwgk May 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions cuda_bindings/cuda/bindings/_path_finder/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# `cuda.bindings.path_finder` Module

## Public API (Work in Progress)

Currently exposes two primary interfaces:

```
cuda.bindings.path_finder._SUPPORTED_LIBNAMES # ('nvJitLink', 'nvrtc', 'nvvm')
cuda.bindings.path_finder._load_nvidia_dynamic_library(libname: str) -> LoadedDL
```

**Note:**
These APIs are prefixed with an underscore because they are considered
experimental while undergoing active development, although already
reasonably well-tested through CI pipelines.

## Library Loading Search Priority

The `load_nvidia_dynamic_library()` function implements a hierarchical search
strategy for locating NVIDIA shared libraries:

0. **Check if a library was loaded into the process already by some other means.**
- If yes, there is no alternative to skipping the rest of the search logic.
The absolute path of the already loaded library will be returned, along
with the handle to the library.

1. **Python Package Ecosystem**
- Scans `sys.path` to find libraries installed via NVIDIA Python wheels.

2. **Conda Environments**
- Leverages Conda-specific paths through our fork of `get_cuda_paths()`
from numba-cuda.

3. **Environment variables**
- Relies on `CUDA_HOME`/`CUDA_PATH` environment variables if set.

4. **System Installations**
- Checks traditional system locations through these paths:
- Linux: `/usr/local/cuda/lib64`
- Windows: `C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\vX.Y\bin`
(where X.Y is the CTK version)
- **Notably does NOT search**:
- Versioned CUDA directories like `/usr/local/cuda-12.3`
- Distribution-specific packages (RPM/DEB)
EXCEPT Debian's `nvidia-cuda-toolkit`

5. **OS Default Mechanisms**
- Falls back to native loader:
- `dlopen()` on Linux
- `LoadLibraryW()` on Windows

Note that the search is done on a per-library basis. There is no centralized
mechanism that ensures all libraries are found in the same way.

## Implementation Philosophy

The current implementation balances stability and evolution:

- **Baseline Foundation:** Uses a fork of numba-cuda's `cuda_paths.py` that has been
battle-tested in production environments.

- **Validation Infrastructure:** Comprehensive CI testing matrix being developed to cover:
- Various Linux/Windows environments
- Python packaging formats (wheels, conda)
- CUDA Toolkit versions

- **Roadmap:** Planned refactoring to:
- Unify library discovery logic
- Improve maintainability
- Better enforce search priority
- Expand platform support

## Maintenance Requirements

These key components must be updated for new CUDA Toolkit releases:

- `supported_libs.SUPPORTED_LIBNAMES`
- `supported_libs.SUPPORTED_WINDOWS_DLLS`
- `supported_libs.SUPPORTED_LINUX_SONAMES`
- `supported_libs.EXPECTED_LIB_SYMBOLS`
Loading
Loading