-
Notifications
You must be signed in to change notification settings - Fork 217
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
Merged
Merged
Changes from 26 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
6e6d961
Initial plan
Copilot 5aee727
Create Sphinx documentation infrastructure for cuda.pathfinder
Copilot b1fbe08
Fix title underline and test pathfinder documentation build
Copilot 12c065f
Address all review feedback - fix references, remove unnecessary file…
Copilot e86e775
Add cuda-pathfinder documentation link to CI doc preview
Copilot 237df56
[pre-commit.ci] auto code formatting
pre-commit-ci[bot] 288a55b
Update cuda-core and cuda-bindings README to reference nv-versions.json
Copilot 169cfa8
Merge branch 'main' into copilot/fix-760
leofang 6f432c9
Refactor pathfinder documentation based on review feedback
Copilot 7f1e84e
Add release notes for cuda-pathfinder versions 1.0.0 and 1.1.0
Copilot d252872
Fix SPDX license identifiers and add 1.1.1 release notes for PRs #834…
Copilot 1f12c27
Restore _templates/main.html file as requested in review feedback
Copilot 224156d
Change format as requested by Leo
rwgk 9164130
Remove stray cuda/pathfinder/README.md URL in cuda_python/docs/source…
rwgk 3f10ec8
Merge branch 'main' into copilot/fix-760
rwgk 1006e2b
Rename release 1.1.1 to 1.X.Y
rwgk d096d21
Add version 1.0.0 in cuda_pathfinder/docs/nv-versions.json
rwgk 89d3564
Merge branch 'main' into copilot/fix-760
leofang 3d5d28b
Remove unused cuda_pathfinder/docs/make.bat
rwgk ecc5c19
Revert "Add version 1.0.0 in cuda_pathfinder/docs/nv-versions.json"
rwgk 100f18a
Reduce divergence between cuda_bindings/docs/source/contribute.rst an…
rwgk 1c0d6e8
Merge branch 'main' into copilot/fix-760
rwgk aebd77e
New pre-commit fixes (related to PR #901)
rwgk a7c8f89
Also remove version 1.1.0 from cuda_pathfinder/docs/nv-versions.json
rwgk 06bc1db
Reduce cuda/pathfinder/README.md to a mere pointer to the sphinx-gene…
rwgk d5c5b79
Add the Search order section from the old README as a new section in …
rwgk b324515
Leo's edits to new part of load_nvidia_dynamic_lib docstring
rwgk 5713624
Merge branch 'main' into copilot/fix-760
rwgk 3d9ca9e
Add more empty lines in load_nvidia_dynamic_lib docstring
rwgk 28d83dd
Remove `**` around Linux, Windows (for consistency)
rwgk ea8bd9a
Fix existing (on main) pre-commit error
rwgk c08ce51
Add `*/docs/source/generated/` to .gitignore
rwgk a97918e
Add toolshed/setup-docs-env.sh
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
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 |
|---|---|---|
| @@ -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. |
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,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. |
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,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/ |
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,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) |
leofang marked this conversation as resolved.
Show resolved
Hide resolved
|
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,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. |
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,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 |
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,6 @@ | ||
| [ | ||
| { | ||
| "version": "latest", | ||
| "url": "https://nvidia.github.io/cuda-python/cuda-pathfinder/latest/" | ||
| } | ||
| ] |
leofang marked this conversation as resolved.
Show resolved
Hide resolved
|
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,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.
Show resolved
Hide resolved
leofang marked this conversation as resolved.
Show resolved
Hide resolved
|
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,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 |
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,95 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2012-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # Configuration file for the Sphinx documentation builder. | ||
| # | ||
| # This file only contains a selection of the most common options. For a full | ||
| # list see the documentation: | ||
| # https://www.sphinx-doc.org/en/master/usage/configuration.html | ||
|
|
||
| # -- Path setup -------------------------------------------------------------- | ||
|
|
||
| # If extensions (or modules to document with autodoc) are in another directory, | ||
| # add these directories to sys.path here. If the directory is relative to the | ||
| # documentation root, use os.path.abspath to make it absolute, like shown here. | ||
| import os | ||
|
|
||
| # import sys | ||
| # sys.path.insert(0, os.path.abspath('.')) | ||
|
|
||
|
|
||
| # -- Project information ----------------------------------------------------- | ||
|
|
||
| project = "cuda.pathfinder" | ||
| copyright = "2025, NVIDIA" | ||
| author = "NVIDIA" | ||
|
|
||
| # The full version, including alpha/beta/rc tags | ||
| release = os.environ["SPHINX_CUDA_PATHFINDER_VER"] | ||
|
|
||
|
|
||
| # -- General configuration --------------------------------------------------- | ||
|
|
||
| # Add any Sphinx extension module names here, as strings. They can be | ||
| # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom | ||
| # ones. | ||
| extensions = [ | ||
| "sphinx.ext.autodoc", | ||
| "sphinx.ext.autosummary", | ||
| "sphinx.ext.napoleon", | ||
| "sphinx.ext.intersphinx", | ||
| "myst_nb", | ||
| "enum_tools.autoenum", | ||
| "sphinx_copybutton", | ||
| ] | ||
|
|
||
| nb_execution_mode = "off" | ||
|
|
||
| numfig = True | ||
|
|
||
| # Add any paths that contain templates here, relative to this directory. | ||
| templates_path = ["_templates"] | ||
|
|
||
| # List of patterns, relative to source directory, that match files and | ||
| # directories to ignore when looking for source files. | ||
| # This pattern also affects html_static_path and html_extra_path. | ||
| exclude_patterns = [] | ||
|
|
||
| # -- Options for HTML output ------------------------------------------------- | ||
|
|
||
| # The theme to use for HTML and HTML Help pages. See the documentation for | ||
| # a list of builtin themes. | ||
| html_baseurl = "docs" | ||
| html_theme = "nvidia_sphinx_theme" | ||
| html_theme_options = { | ||
| "switcher": { | ||
| "json_url": "https://nvidia.github.io/cuda-python/cuda-pathfinder/nv-versions.json", | ||
| "version_match": release, | ||
| }, | ||
| # Add light/dark mode and documentation version switcher | ||
| "navbar_center": [ | ||
| "version-switcher", | ||
| "navbar-nav", | ||
| ], | ||
| } | ||
| if os.environ.get("CI"): | ||
| if int(os.environ.get("BUILD_PREVIEW", 0)): | ||
| PR_NUMBER = f"{os.environ['PR_NUMBER']}" | ||
| PR_TEXT = f'<a href="https://github.com/NVIDIA/cuda-python/pull/{PR_NUMBER}">PR {PR_NUMBER}</a>' | ||
| html_theme_options["announcement"] = f"<em>Warning</em>: This documentation is only a preview for {PR_TEXT}!" | ||
| elif int(os.environ.get("BUILD_LATEST", 0)): | ||
| html_theme_options["announcement"] = ( | ||
| "<em>Warning</em>: This documentation is built from the development branch!" | ||
| ) | ||
|
|
||
| # Add any paths that contain custom static files (such as style sheets) here, | ||
| # relative to this directory. They are copied after the builtin static files, | ||
| # so a file named "default.css" will overwrite the builtin "default.css". | ||
| html_static_path = ["_static"] | ||
|
|
||
| # skip cmdline prompts | ||
| copybutton_exclude = ".linenos, .gp" | ||
|
|
||
| intersphinx_mapping = { | ||
| "python": ("https://docs.python.org/3/", None), | ||
| } |
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.