Skip to content
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
6e6d961
Initial plan
Copilot Aug 21, 2025
5aee727
Create Sphinx documentation infrastructure for cuda.pathfinder
Copilot Aug 21, 2025
b1fbe08
Fix title underline and test pathfinder documentation build
Copilot Aug 21, 2025
12c065f
Address all review feedback - fix references, remove unnecessary file…
Copilot Aug 21, 2025
e86e775
Add cuda-pathfinder documentation link to CI doc preview
Copilot Aug 21, 2025
237df56
[pre-commit.ci] auto code formatting
pre-commit-ci[bot] Aug 21, 2025
288a55b
Update cuda-core and cuda-bindings README to reference nv-versions.json
Copilot Aug 21, 2025
169cfa8
Merge branch 'main' into copilot/fix-760
leofang Aug 21, 2025
6f432c9
Refactor pathfinder documentation based on review feedback
Copilot Aug 22, 2025
7f1e84e
Add release notes for cuda-pathfinder versions 1.0.0 and 1.1.0
Copilot Aug 23, 2025
d252872
Fix SPDX license identifiers and add 1.1.1 release notes for PRs #834…
Copilot Aug 23, 2025
1f12c27
Restore _templates/main.html file as requested in review feedback
Copilot Aug 25, 2025
224156d
Change format as requested by Leo
rwgk Aug 25, 2025
9164130
Remove stray cuda/pathfinder/README.md URL in cuda_python/docs/source…
rwgk Aug 25, 2025
3f10ec8
Merge branch 'main' into copilot/fix-760
rwgk Aug 25, 2025
1006e2b
Rename release 1.1.1 to 1.X.Y
rwgk Aug 25, 2025
d096d21
Add version 1.0.0 in cuda_pathfinder/docs/nv-versions.json
rwgk Aug 25, 2025
89d3564
Merge branch 'main' into copilot/fix-760
leofang Aug 25, 2025
3d5d28b
Remove unused cuda_pathfinder/docs/make.bat
rwgk Aug 25, 2025
ecc5c19
Revert "Add version 1.0.0 in cuda_pathfinder/docs/nv-versions.json"
rwgk Aug 25, 2025
100f18a
Reduce divergence between cuda_bindings/docs/source/contribute.rst an…
rwgk Aug 25, 2025
1c0d6e8
Merge branch 'main' into copilot/fix-760
rwgk Aug 25, 2025
aebd77e
New pre-commit fixes (related to PR #901)
rwgk Aug 25, 2025
a7c8f89
Also remove version 1.1.0 from cuda_pathfinder/docs/nv-versions.json
rwgk Aug 25, 2025
06bc1db
Reduce cuda/pathfinder/README.md to a mere pointer to the sphinx-gene…
rwgk Aug 25, 2025
d5c5b79
Add the Search order section from the old README as a new section in …
rwgk Aug 25, 2025
b324515
Leo's edits to new part of load_nvidia_dynamic_lib docstring
rwgk Aug 26, 2025
5713624
Merge branch 'main' into copilot/fix-760
rwgk Aug 26, 2025
3d9ca9e
Add more empty lines in load_nvidia_dynamic_lib docstring
rwgk Aug 26, 2025
28d83dd
Remove `**` around Linux, Windows (for consistency)
rwgk Aug 26, 2025
ea8bd9a
Fix existing (on main) pre-commit error
rwgk Aug 26, 2025
c08ce51
Add `*/docs/source/generated/` to .gitignore
rwgk Aug 26, 2025
a97918e
Add toolshed/setup-docs-env.sh
rwgk Aug 26, 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
3 changes: 2 additions & 1 deletion .github/actions/doc_preview/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ runs:
:---:
| <p></p> :rocket: View preview at <br> https://nvidia.github.io/cuda-python/pr-preview/pr-${{ inputs.pr-number }}/ <br>
| <br> https://nvidia.github.io/cuda-python/pr-preview/pr-${{ inputs.pr-number }}/cuda-core/ <br>
| <br> https://nvidia.github.io/cuda-python/pr-preview/pr-${{ inputs.pr-number }}/cuda-bindings/ <br><br>
| <br> https://nvidia.github.io/cuda-python/pr-preview/pr-${{ inputs.pr-number }}/cuda-bindings/ <br>
| <br> https://nvidia.github.io/cuda-python/pr-preview/pr-${{ inputs.pr-number }}/cuda-pathfinder/ <br><br>
| <h6><br> Preview will be ready when the GitHub Pages deployment is complete. <br><br></h6>

# The steps below are executed only when building on main.
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ on:
# - cuda-core
# - cuda-bindings
# - cuda-python
# - cuda-pathfinder
# - all
git-tag:
description: "Target git tag to build docs for"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CUDA Python is the home for accessing NVIDIA’s CUDA platform from Python. It c

* [cuda.core](https://nvidia.github.io/cuda-python/cuda-core/latest): Pythonic access to CUDA Runtime and other core functionalities
* [cuda.bindings](https://nvidia.github.io/cuda-python/cuda-bindings/latest): Low-level Python bindings to CUDA C APIs
* [cuda.pathfinder](https://github.com/NVIDIA/cuda-python/blob/main/cuda_pathfinder/cuda/pathfinder/README.md): Utilities for locating CUDA components installed in the user's Python environment
* [cuda.pathfinder](https://nvidia.github.io/cuda-python/cuda-pathfinder/latest): Utilities for locating CUDA components installed in the user's Python environment
* [cuda.cccl.cooperative](https://nvidia.github.io/cccl/python/cooperative): A Python module providing CCCL's reusable block-wide and warp-wide *device* primitives for use within Numba CUDA kernels
* [cuda.cccl.parallel](https://nvidia.github.io/cccl/python/parallel): A Python module for easy access to CCCL's highly efficient and customizable parallel algorithms, like `sort`, `scan`, `reduce`, `transform`, etc. that are callable on the *host*
* [numba.cuda](https://nvidia.github.io/numba-cuda/): Numba's target for CUDA GPU programming by directly compiling a restricted subset of Python code into CUDA kernels and device functions following the CUDA execution model.
Expand Down
4 changes: 2 additions & 2 deletions cuda_bindings/docs/README.md
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.
4 changes: 2 additions & 2 deletions cuda_core/docs/README.md
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.
46 changes: 2 additions & 44 deletions cuda_pathfinder/cuda/pathfinder/README.md
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
Expand Up @@ -53,16 +53,50 @@ def _load_lib_no_cache(libname: str) -> LoadedDL:

@functools.cache
def load_nvidia_dynamic_lib(libname: str) -> LoadedDL:
"""Load a NVIDIA dynamic library by name.
"""Load an NVIDIA dynamic library by name.

Args:
libname: The name of the library to load (e.g. "cudart", "nvvm", etc.)
libname (str): The short name of the library to load (e.g., ``"cudart"``,
``"nvvm"``, etc.).

Returns:
A LoadedDL object containing the library handle and path
LoadedDL: Object containing the OS library handle and absolute path.

Raises:
RuntimeError: If the library cannot be found or loaded
DynamicLibNotFoundError: If the library cannot be found or loaded.
RuntimeError: If Python is not 64-bit.

Search order:
0. **Already loaded in the current process**
- If a matching library is already loaded by some other component,
return its absolute path and handle and skip the rest of the search.

1. **NVIDIA Python wheels**
- Scan installed distributions (``site-packages``) to find libraries
shipped in NVIDIA wheels.

2. **OS default mechanisms / Conda environments**
- Fall back to the native loader:
- Linux: ``dlopen()``
- Windows: ``LoadLibraryW()``
- Conda installations are commonly discovered via:
- **Linux**: ``$ORIGIN/../lib`` in the ``RPATH`` of the ``python`` binary
(note: this can take precedence over ``LD_LIBRARY_PATH`` and
``/etc/ld.so.conf.d/``).
- **Windows**: ``%CONDA_PREFIX%\\Library\\bin`` on the system ``PATH``.
- CUDA Toolkit (CTK) system installs with system config updates are often
discovered via:
- **Linux**: ``/etc/ld.so.conf.d/*cuda*.conf``
- **Windows**: ``C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\vX.Y\\bin``
on the system ``PATH``.

3. **Environment variables**
- If set, use ``CUDA_HOME`` or ``CUDA_PATH`` (in that order).

Notes:
The search is performed **per library**. There is currently no mechanism to
guarantee that multiple libraries are all resolved from the same location.

"""
pointer_size_bits = struct.calcsize("P") * 8
if pointer_size_bits != 64:
Expand Down
23 changes: 23 additions & 0 deletions cuda_pathfinder/docs/Makefile
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)
11 changes: 11 additions & 0 deletions cuda_pathfinder/docs/README.md
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.
50 changes: 50 additions & 0 deletions cuda_pathfinder/docs/build_docs.sh
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
6 changes: 6 additions & 0 deletions cuda_pathfinder/docs/nv-versions.json
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/"
}
]
13 changes: 13 additions & 0 deletions cuda_pathfinder/docs/source/_templates/main.html
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>
20 changes: 20 additions & 0 deletions cuda_pathfinder/docs/source/api.rst
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
95 changes: 95 additions & 0 deletions cuda_pathfinder/docs/source/conf.py
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),
}
Loading
Loading