Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 321
Add Sphinx documentation for cuda.pathfinder#884
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
6e6d9615aee727b1fbe0812c065fe86e775237df56288a55b169cfa86f432c97f1e84ed2528721f12c27224156d91641303f10ec81006e2bd096d2189d35643d5d28becc5c19100f18a1c0d6e8aebd77ea7c8f8906bc1dbd5c5b79b32451557136243d9ca9e28d83ddea8bd9ac08ce51a97918eFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -115,6 +115,7 @@ instance/ | ||
| # Sphinx documentation | ||
| docs_src/_build/ | ||
| */docs/source/generated/ | ||
| # PyBuilder | ||
| .pybuilder/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,11 @@ | ||
| # Build the documentation | ||
| 1. Install the `cuda-bindings` package of the version that we need to document. | ||
| 2. Ensure the version is included in the [`versions.json`](./versions.json). | ||
| 2. Ensure the version is included in the [`nv-versions.json`](./nv-versions.json). | ||
| 3. Build the docs with `./build_docs.sh`. | ||
| 4. The html artifacts should be available under both `./build/html/latest` and `./build/html/<version>`. | ||
| Alternatively, we can build all the docs at once by running [`cuda_python/docs/build_all_docs.sh`](../../cuda_python/docs/build_all_docs.sh). | ||
| To publish the docs with the built version, it is important to note that the html files of older versions | ||
| should be kept intact, in order for the version selection (through `versions.json`) to work. | ||
| should be kept intact, in order for the version selection (through `nv-versions.json`) to work. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,11 @@ | ||
| # Build the documentation | ||
| 1. Install the `cuda-core` package of the version that we need to document. | ||
| 2. Ensure the version is included in the [`versions.json`](./versions.json). | ||
| 2. Ensure the version is included in the [`nv-versions.json`](./nv-versions.json). | ||
| 3. Build the docs with `./build_docs.sh`. | ||
| 4. The html artifacts should be available under both `./build/html/latest` and `./build/html/<version>`. | ||
| Alternatively, we can build all the docs at once by running [`cuda_python/docs/build_all_docs.sh`](../../cuda_python/docs/build_all_docs.sh). | ||
| To publish the docs with the built version, it is important to note that the html files of older versions | ||
| should be kept intact, in order for the version selection (through `versions.json`) to work. | ||
| should be kept intact, in order for the version selection (through `nv-versions.json`) to work. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,45 +1,3 @@ | ||
| #`cuda.pathfinder` Module | ||
| ### The `cuda.pathfinder` documentation was moved | ||
| ## Public API for loading NVIDIA Dynamic Libs | ||
| * `cuda.pathfinder.SUPPORTED_NVIDIA_LIBNAMES` (`tuple[str]`) | ||
| * `cuda.pathfinder.load_nvidia_dynamic_lib(libname: str) -> LoadedDL` | ||
| * `cuda.pathfinder.LoadedDL`: | ||
| * `abs_path` (`str`) | ||
| * `was_already_loaded_from_elsewhere` (`bool`) | ||
| * `cuda.pathfinder.DynamicLibNotFoundError` (inherits from `RuntimeError`) | ||
| ## Dynamic Library Loading Search Priority | ||
| The `cuda.pathfinder.load_nvidia_dynamic_lib` 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. **NVIDIA Python wheels** | ||
| - Scans all site-packages to find libraries installed via NVIDIA Python wheels. | ||
| 2. **OS default mechanisms / Conda environments** | ||
| - Falls back to native loader: | ||
| - `dlopen()` on Linux | ||
| - `LoadLibraryW()` on Windows | ||
| - Conda installations are expected to be discovered: | ||
| - Linux: Via `$ORIGIN/../lib` on `RPATH` (of the `python` binary; | ||
| note that this preempts `LD_LIBRARY_PATH` and `/etc/ld.so.conf.d/`) | ||
| - Windows: Via `%CONDA_PREFIX%\Library\bin` on system `PATH` | ||
| - CTK installations with system config updates are expected to be discovered: | ||
| - Linux: Via `/etc/ld.so.conf.d/*cuda*.conf` | ||
| - Windows: Via `C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\vX.Y\bin` on system `PATH` | ||
| 3. **Environment variables** | ||
| - Relies on `CUDA_HOME` or `CUDA_PATH` environment variables if set | ||
| (in that order). | ||
| Note that the search is done on a per-library basis. Currently there is no | ||
| centralized mechanism that ensures all libraries are found in the same way. | ||
| Please see https://nvidia.github.io/cuda-python/cuda-pathfinder/latest/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2021-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # Minimal makefile for Sphinx documentation | ||
| # | ||
| # You can set these variables from the command line, and also | ||
| # from the environment for the first two. | ||
| SPHINXOPTS ?= -j auto | ||
| SPHINXBUILD ?= sphinx-build | ||
| SOURCEDIR = source | ||
| BUILDDIR = build/html/${SPHINX_CUDA_PATHFINDER_VER} | ||
| # Put it first so that "make" without argument is like "make help". | ||
| help: | ||
| @$(SPHINXBUILD) -b help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
| .PHONY: help Makefile | ||
| # Catch-all target: route all unknown targets to Sphinx using the new | ||
| # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | ||
| %: Makefile | ||
| @$(SPHINXBUILD) -b $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Build the documentation | ||
| 1. Install the `cuda-pathfinder` package of the version that we need to document. | ||
| 2. Ensure the version is included in the [`nv-versions.json`](./nv-versions.json). | ||
| 3. Build the docs with `./build_docs.sh`. | ||
| 4. The html artifacts should be available under both `./build/html/latest` and `./build/html/<version>`. | ||
| Alternatively, we can build all the docs at once by running [`cuda_python/docs/build_all_docs.sh`](../../cuda_python/docs/build_all_docs.sh). | ||
| To publish the docs with the built version, it is important to note that the html files of older versions | ||
| should be kept intact, in order for the version selection (through `nv-versions.json`) to work. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| #!/bin/bash | ||
| # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| set -ex | ||
| if [[ "$#" == "0" ]]; then | ||
| LATEST_ONLY="0" | ||
| elif [[ "$#" == "1" && "$1" == "latest-only" ]]; then | ||
| LATEST_ONLY="1" | ||
| else | ||
| echo "usage: ./build_docs.sh [latest-only]" | ||
| exit 1 | ||
| fi | ||
| # SPHINX_CUDA_PATHFINDER_VER is used to create a subdir under build/html | ||
| # (the Makefile file for sphinx-build also honors it if defined). | ||
| # If there's a post release (ex: .post1) we don't want it to show up in the | ||
| # version selector or directory structure. | ||
| if [[ -z "${SPHINX_CUDA_PATHFINDER_VER}" ]]; then | ||
| export SPHINX_CUDA_PATHFINDER_VER=$(python -c "from importlib.metadata import version; \ | ||
| ver = '.'.join(str(version('cuda-pathfinder')).split('.')[:3]); \ | ||
| print(ver)" \ | ||
| | awk -F'+' '{print $1}') | ||
| fi | ||
| # build the docs (in parallel) | ||
| SPHINXOPTS="-j 4 -d build/.doctrees" make html | ||
| # for debugging/developing (conf.py), please comment out the above line and | ||
| # use the line below instead, as we must build in serial to avoid getting | ||
| # obsecure Sphinx errors | ||
| #SPHINXOPTS="-v" make html | ||
| # to support version dropdown menu | ||
| cp ./nv-versions.json build/html | ||
| # to have a redirection page (to the latest docs) | ||
| cp source/_templates/main.html build/html/index.html | ||
| # ensure that the latest docs is the one we built | ||
| if [[ $LATEST_ONLY == "0" ]]; then | ||
| cp -r build/html/${SPHINX_CUDA_PATHFINDER_VER} build/html/latest | ||
| else | ||
| mv build/html/${SPHINX_CUDA_PATHFINDER_VER} build/html/latest | ||
| fi | ||
| # ensure that the Sphinx reference uses the latest docs | ||
| cp build/html/latest/objects.inv build/html |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| [ | ||
| { | ||
| "version": "latest", | ||
| "url": "https://nvidia.github.io/cuda-python/cuda-pathfinder/latest/" | ||
| } | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <!DOCTYPE HTML> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <meta http-equiv="refresh" content="0; url=latest/" /> | ||
| <link rel="canonical" href="latest/" /> | ||
| </head> | ||
| <body> | ||
| <p>If this page does not refresh automatically, then please direct your browser to | ||
| <a href="latest/">our latest cuda.pathfinder docs</a>. | ||
| </p> | ||
| </body> | ||
| </html> |
leofang marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. leofang marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| .. SPDX-License-Identifier: Apache-2.0 | ||
| .. module:: cuda.pathfinder | ||
| ``cuda.pathfinder`` API Reference | ||
| ================================= | ||
| The ``cuda.pathfinder`` module provides utilities for loading NVIDIA dynamic libraries. | ||
| Public API | ||
| ----------- | ||
| .. autosummary:: | ||
| :toctree: generated/ | ||
| SUPPORTED_NVIDIA_LIBNAMES | ||
| load_nvidia_dynamic_lib | ||
| LoadedDL | ||
| DynamicLibNotFoundError |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.