|
1 | | -`cuda.bindings.path_finder` |
2 | | -=========================== |
| 1 | +# `cuda.bindings.path_finder` Module |
3 | 2 |
|
4 | | -Currently, the only two (semi-)public APIs are: |
| 3 | +## Public API (Work in Progress) |
5 | 4 |
|
6 | | -* `cuda.bindings.path_finder._SUPPORTED_LIBNAMES` (currently `('nvJitLink', 'nvrtc', 'nvvm')`) |
| 5 | +Currently exposes two primary interfaces: |
7 | 6 |
|
8 | | -* `cuda.bindings.path_finder._load_nvidia_dynamic_library(libname: str) -> LoadedDL` |
| 7 | +``` |
| 8 | +cuda.bindings.path_finder._SUPPORTED_LIBNAMES # ('nvJitLink', 'nvrtc', 'nvvm') |
| 9 | +cuda.bindings.path_finder._load_nvidia_dynamic_library(libname: str) -> LoadedDL |
| 10 | +``` |
9 | 11 |
|
10 | | -These APIs are prefixed with an underscore because they are STILL A WORK IN PROGRESS, |
11 | | -although already fairly well tested. |
| 12 | +**Note:** |
| 13 | +These APIs are prefixed with an underscore because they are considered |
| 14 | +experimental while undergoing active development, although already |
| 15 | +reasonably well-tested through CI pipelines. |
12 | 16 |
|
13 | | -`load_nvidia_dynamic_library()` is meant to become the one, central, go-to API for |
14 | | -loading NVIDIA shared libraries from Python. |
| 17 | +## Library Loading Search Priority |
15 | 18 |
|
| 19 | +The `load_nvidia_dynamic_library()` function implements a hierarchical search |
| 20 | +strategy for locating NVIDIA shared libraries: |
16 | 21 |
|
17 | | -Search Priority |
18 | | ---------------- |
| 22 | +1. **Python Package Ecosystem** |
| 23 | + - Scans `sys.path` to find libraries installed via NVIDIA Python wheels |
19 | 24 |
|
20 | | -The _intended_ search priority for locating NVIDIA dynamic libraries is: |
| 25 | +2. **Conda Environments** |
| 26 | + - Leverages Conda-specific paths through our fork of `get_cuda_paths()` from Numba |
21 | 27 |
|
22 | | -* *site-packages* — Traversal of Python's `sys.path` (in order), which for all practical |
23 | | - purposes amounts to a search for libraries installed from NVIDIA wheels. |
| 28 | +3. **System Installations** |
| 29 | + - Checks traditional system locations via the same `get_cuda_paths()` implementation |
24 | 30 |
|
25 | | -* *Conda* — Currently mplemented via `get_cuda_paths()` as forked from numba/cuda/cuda_paths.py |
| 31 | +4. **OS Default Mechanisms** |
| 32 | + - Falls back to native loader: |
| 33 | + - `dlopen()` on Linux |
| 34 | + - `LoadLibraryW()` on Windows |
26 | 35 |
|
27 | | -* *System* — Also implemented via `get_cuda_paths()` |
| 36 | +## Implementation Philosophy |
28 | 37 |
|
29 | | -* *OS-provided search* — `dlopen()` (Linux) or `LoadLibraryW()` (Windows) mechanisms |
| 38 | +The current implementation balances stability and evolution: |
30 | 39 |
|
| 40 | +- **Baseline Foundation:** Uses a fork of Numba's `cuda_paths.py` that has been |
| 41 | + battle-tested in production environments |
31 | 42 |
|
32 | | -Currently, our fork of cuda_paths.py is intentionally used as-is. |
33 | | -cuda_paths.py has a long and convoluted development history, but that also means |
34 | | -the product is time-tested. Our strategy for evolving the implementation is: |
| 43 | +- **Validation Infrastructure:** Comprehensive CI testing matrix being developed to cover: |
| 44 | + - Various Linux/Windows environments |
| 45 | + - Python packaging formats (wheels, conda) |
| 46 | + - CUDA Toolkit versions |
35 | 47 |
|
36 | | -* Establish a minimal viable product as a baseline (current stage). |
| 48 | +- **Roadmap:** Planned refactoring to: |
| 49 | + - Unify library discovery logic |
| 50 | + - Improve maintainability |
| 51 | + - Better enforce search priority |
| 52 | + - Expand platform support |
37 | 53 |
|
38 | | -* Establish a comprehensive testing infrastructure (GitHub Actions / CI) to |
39 | | - cover all sorts of environments that we want to support. |
| 54 | +## Maintenance Requirements |
40 | 55 |
|
41 | | -* Combine, refactor, and clean up find_nvidia_dynamic_library.py & cuda_paths.py |
42 | | - to achieve a more maintainable and robust implementation of the intended |
43 | | - dynamic library search priority. |
| 56 | +These key components must be updated for new CUDA Toolkit releases: |
| 57 | + |
| 58 | +- `supported_libs.SUPPORTED_LIBNAMES` |
| 59 | +- `supported_libs.SUPPORTED_WINDOWS_DLLS` |
| 60 | +- `supported_libs.SUPPORTED_LINUX_SONAMES` |
| 61 | +- `supported_libs.EXPECTED_LIB_SYMBOLS` |
0 commit comments