├── cuda_core
├── cuda
│ └── core
│ │ ├── __init__.pxd
│ │ ├── _memory
│ │ ├── __init__.pxd
│ │ ├── _managed_memory_resource.pxd
│ │ ├── _graph_memory_resource.pxd
│ │ ├── _pinned_memory_resource.pxd
│ │ ├── _device_memory_resource.pxd
│ │ ├── __init__.py
│ │ ├── _buffer.pxd
│ │ └── _memory_pool.pxd
│ │ ├── _utils
│ │ ├── __init__.pxd
│ │ ├── __init__.py
│ │ └── clear_error_support.py
│ │ ├── experimental
│ │ └── __init__.pxd
│ │ ├── utils.py
│ │ ├── _kernel_arg_handler.pxd
│ │ ├── _event.pxd
│ │ ├── _launch_config.pxd
│ │ ├── _stream.pxd
│ │ ├── _include
│ │ ├── utility.hpp
│ │ └── layout.hpp
│ │ └── _context.pyx
├── tests
│ ├── example_tests
│ │ ├── __init__.py
│ │ └── test_basic_examples.py
│ ├── helpers
│ │ ├── misc.py
│ │ ├── __init__.py
│ │ ├── nanosleep_kernel.py
│ │ └── logging.py
│ ├── cython
│ │ ├── build_tests.sh
│ │ ├── test_cython.py
│ │ └── test_get_cuda_native_handle.pyx
│ └── test_system.py
├── MANIFEST.in
├── docs
│ ├── versions.json
│ ├── source
│ │ ├── license.rst
│ │ ├── release.rst
│ │ ├── _templates
│ │ │ ├── autosummary
│ │ │ │ ├── dataclass.rst
│ │ │ │ ├── namedtuple.rst
│ │ │ │ ├── cyclass.rst
│ │ │ │ ├── class.rst
│ │ │ │ └── protocol.rst
│ │ │ └── main.html
│ │ ├── release
│ │ │ ├── 0.4.2-notes.rst
│ │ │ ├── 0.3.2-notes.rst
│ │ │ ├── 0.1.0-notes.rst
│ │ │ ├── 0.4.1-notes.rst
│ │ │ └── 0.3.1-notes.rst
│ │ ├── index.rst
│ │ ├── contribute.rst
│ │ └── api_private.rst
│ ├── README.md
│ ├── Makefile
│ ├── nv-versions.json
│ └── build_docs.sh
├── pytest.ini
├── setup.py
├── DESCRIPTION.rst
└── README.md
├── cuda_python
├── README.md
├── docs
│ ├── versions.json
│ ├── source
│ │ ├── release.rst
│ │ ├── _templates
│ │ │ └── main.html
│ │ └── release
│ │ │ ├── 11.8.7-notes.rst
│ │ │ ├── 12.6.1-notes.rst
│ │ │ ├── 13.1.1-notes.rst
│ │ │ ├── 12.6.2-notes.rst
│ │ │ ├── 11.8.6-notes.rst
│ │ │ ├── 12.9.5-notes.rst
│ │ │ ├── 12.9.0-notes.rst
│ │ │ ├── 13.1.0-notes.rst
│ │ │ ├── 12.9.4-notes.rst
│ │ │ ├── 13.0.3-notes.rst
│ │ │ ├── 12.9.2-notes.rst
│ │ │ ├── 13.0.1-notes.rst
│ │ │ ├── 12.9.1-notes.rst
│ │ │ ├── 13.0.0-notes.rst
│ │ │ ├── 12.9.3-notes.rst
│ │ │ ├── 13.0.2-notes.rst
│ │ │ └── 12.8.0-notes.rst
│ ├── environment-docs.yml
│ ├── Makefile
│ ├── exts
│ │ └── release_toc.py
│ ├── build_all_docs.sh
│ └── README.md
└── setup.py
├── cuda_bindings
├── tests
│ ├── nvml
│ │ ├── README.md
│ │ ├── __init__.py
│ │ ├── test_compute_mode.py
│ │ ├── util.py
│ │ ├── test_nvlink.py
│ │ ├── test_gpu.py
│ │ └── test_init.py
│ ├── cython
│ │ ├── build_tests.bat
│ │ ├── build_tests.sh
│ │ ├── test_cython.py
│ │ └── test_ccuda.pyx
│ ├── cufile.json
│ ├── conftest.py
│ ├── utils
│ │ └── check_cyclical_import.py
│ └── test_nvrtc.py
├── cuda
│ └── bindings
│ │ ├── __init__.pxd
│ │ ├── _lib
│ │ ├── __init__.py
│ │ ├── param_packer.pxd
│ │ ├── dlfcn.pxd
│ │ └── windll.pxd
│ │ ├── _bindings
│ │ ├── __init__.py
│ │ ├── loader.pxd
│ │ └── loader.h
│ │ ├── _internal
│ │ └── __init__.py
│ │ ├── __init__.py
│ │ ├── nvrtc.pxd.in
│ │ ├── utils
│ │ └── __init__.py
│ │ ├── nvvm.pxd
│ │ └── nvjitlink.pxd
├── examples
│ ├── pytest.ini
│ └── common
│ │ ├── helper_string.py
│ │ └── helper_cuda.py
├── docs
│ ├── source
│ │ ├── _static
│ │ │ └── images
│ │ │ │ └── Nsight-Compute-CLI-625x473.png
│ │ ├── license.rst
│ │ ├── release.rst
│ │ ├── module
│ │ │ ├── utils.rst
│ │ │ └── cufile.rst
│ │ ├── _templates
│ │ │ └── main.html
│ │ ├── api.rst
│ │ ├── index.rst
│ │ ├── release
│ │ │ ├── 12.9.2-notes.rst
│ │ │ ├── 13.0.1-notes.rst
│ │ │ ├── 12.9.4-notes.rst
│ │ │ ├── 11.8.7-notes.rst
│ │ │ ├── 13.0.3-notes.rst
│ │ │ ├── 13.1.1-notes.rst
│ │ │ ├── 11.7.0-notes.rst
│ │ │ ├── 12.2.1-notes.rst
│ │ │ ├── 11.8.2-notes.rst
│ │ │ ├── 11.6.1-notes.rst
│ │ │ ├── 12.9.5-notes.rst
│ │ │ ├── 11.8.3-notes.rst
│ │ │ ├── 12.4.0-notes.rst
│ │ │ ├── 11.8.1-notes.rst
│ │ │ ├── 12.0.0-notes.rst
│ │ │ ├── 12.5.0-notes.rst
│ │ │ ├── 11.8.6-notes.rst
│ │ │ ├── 12.2.0-notes.rst
│ │ │ ├── 11.8.5-notes.rst
│ │ │ ├── 12.1.0-notes.rst
│ │ │ ├── 12.6.2-notes.rst
│ │ │ ├── 12.9.0-notes.rst
│ │ │ ├── 11.4.0-notes.rst
│ │ │ ├── 12.6.0-notes.rst
│ │ │ ├── 12.3.0-notes.rst
│ │ │ ├── 12.9.3-notes.rst
│ │ │ └── 12.8.0-notes.rst
│ │ ├── contribute.rst
│ │ └── environment_variables.rst
│ ├── versions.json
│ ├── README.md
│ ├── Makefile
│ ├── make.bat
│ └── nv-versions.json
├── MANIFEST.in
├── DESCRIPTION.rst
└── benchmarks
│ └── test_numba.py
├── cuda_pathfinder
├── cuda
│ └── pathfinder
│ │ ├── README.md
│ │ ├── _utils
│ │ ├── platform_aware.py
│ │ ├── find_site_packages_dll.py
│ │ └── find_site_packages_so.py
│ │ ├── _dynamic_libs
│ │ └── load_dl_common.py
│ │ └── __init__.py
├── docs
│ ├── source
│ │ ├── license.rst
│ │ ├── release.rst
│ │ ├── _templates
│ │ │ └── main.html
│ │ ├── release
│ │ │ ├── 1.2.1-notes.rst
│ │ │ ├── 1.3.2-notes.rst
│ │ │ ├── 1.1.0-notes.rst
│ │ │ ├── 1.2.3-notes.rst
│ │ │ ├── 1.2.2-notes.rst
│ │ │ ├── 1.3.1-notes.rst
│ │ │ ├── 1.0.0-notes.rst
│ │ │ ├── 1.3.3-notes.rst
│ │ │ ├── 1.3.0-notes.rst
│ │ │ └── 1.2.0-notes.rst
│ │ ├── index.rst
│ │ ├── api.rst
│ │ └── contribute.rst
│ ├── README.md
│ ├── Makefile
│ └── nv-versions.json
├── tests
│ ├── local_helpers.py
│ ├── test_spawned_process_runner.py
│ └── conftest.py
├── pixi.toml
└── DESCRIPTION.rst
├── .spdx-ignore
├── .coveragerc
├── ci
├── versions.yml
└── tools
│ └── setup-sanitizer
├── LICENSE.md
├── .github
├── ISSUE_TEMPLATE
│ ├── config.yml
│ └── doc_request.yml
├── copy-pr-bot.yaml
├── PULL_REQUEST_TEMPLATE.md
├── dependabot.yml
├── workflows
│ ├── triagelabel.yml
│ ├── codeql.yml
│ ├── backport.yml
│ └── guess_latest.sh
└── actions
│ └── install_unix_deps
│ └── action.yml
├── .gitattributes
├── toolshed
├── find_sonames.sh
├── conda_create_for_pathfinder_testing.sh
├── collect_site_packages_so_files.sh
├── conda_create_for_pathfinder_testing.ps1
├── run_cuda_pathfinder.py
├── collect_site_packages_dll_files.ps1
└── check_spdx.py
├── pixi.lock
├── pytest.ini
├── cuda_python_test_helpers
└── pyproject.toml
├── greptile.json
├── pixi.toml
├── conftest.py
└── SECURITY.md
/cuda_core/cuda/core/__init__.pxd:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/cuda_python/README.md:
--------------------------------------------------------------------------------
1 | ../README.md
--------------------------------------------------------------------------------
/cuda_bindings/tests/nvml/README.md:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/cuda_bindings/cuda/bindings/__init__.pxd:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/cuda_core/cuda/core/_memory/__init__.pxd:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/cuda_core/cuda/core/_utils/__init__.pxd:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/cuda_core/tests/example_tests/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/cuda_bindings/cuda/bindings/_lib/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/cuda_bindings/cuda/bindings/_bindings/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/cuda_bindings/cuda/bindings/_internal/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/cuda_bindings/examples/pytest.ini:
--------------------------------------------------------------------------------
1 | [pytest]
2 | python_files = *_test.py
3 | python_functions = main
4 | pythonpath = .
5 |
--------------------------------------------------------------------------------
/cuda_pathfinder/cuda/pathfinder/README.md:
--------------------------------------------------------------------------------
1 | ### The `cuda.pathfinder` documentation was moved
2 |
3 | Please see https://nvidia.github.io/cuda-python/cuda-pathfinder/latest/
4 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/_static/images/Nsight-Compute-CLI-625x473.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIA/cuda-python/main/cuda_bindings/docs/source/_static/images/Nsight-Compute-CLI-625x473.png
--------------------------------------------------------------------------------
/cuda_core/cuda/core/experimental/__init__.pxd:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: Apache-2.0
4 |
--------------------------------------------------------------------------------
/cuda_bindings/tests/nvml/__init__.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
--------------------------------------------------------------------------------
/cuda_core/cuda/core/_utils/__init__.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
4 |
--------------------------------------------------------------------------------
/cuda_core/MANIFEST.in:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: Apache-2.0
4 |
5 | recursive-include cuda/core *.pyx *.pxd
6 |
--------------------------------------------------------------------------------
/cuda_core/docs/versions.json:
--------------------------------------------------------------------------------
1 | {
2 | "latest" : "latest",
3 | "0.3.2" : "0.3.2",
4 | "0.3.1" : "0.3.1",
5 | "0.3.0" : "0.3.0",
6 | "0.2.0" : "0.2.0",
7 | "0.1.1" : "0.1.1",
8 | "0.1.0" : "0.1.0"
9 | }
10 |
--------------------------------------------------------------------------------
/.spdx-ignore:
--------------------------------------------------------------------------------
1 | LICENSE
2 | *.html
3 | *.json
4 | *.md
5 | *.png
6 | .gitattributes
7 | .gitignore
8 | requirements*.txt
9 | cuda_bindings/examples/*
10 |
11 | # Vendored
12 | cuda_core/cuda/core/_include/dlpack.h
13 |
14 | qa/ctk-next.drawio.svg
15 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/versions.json:
--------------------------------------------------------------------------------
1 | {
2 | "latest" : "latest",
3 | "13.0.1" : "13.0.1",
4 | "13.0.0" : "13.0.0",
5 | "12.9.0" : "12.9.0",
6 | "12.8.0" : "12.8.0",
7 | "12.6.2" : "12.6.2",
8 | "12.6.1" : "12.6.1"
9 | }
10 |
--------------------------------------------------------------------------------
/cuda_python/docs/versions.json:
--------------------------------------------------------------------------------
1 | {
2 | "latest" : "latest",
3 | "13.0.1" : "13.0.1",
4 | "13.0.0" : "13.0.0",
5 | "12.9.0" : "12.9.0",
6 | "12.8.0" : "12.8.0",
7 | "12.6.2" : "12.6.2",
8 | "12.6.1" : "12.6.1"
9 | }
10 |
--------------------------------------------------------------------------------
/cuda_core/pytest.ini:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
4 |
5 | [pytest]
6 | addopts = --showlocals
7 | norecursedirs = cython
8 |
--------------------------------------------------------------------------------
/.coveragerc:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | [report]
5 | show_missing = true
6 |
7 | [run]
8 | plugins = Cython.Coverage
9 | core = ctrace
10 |
--------------------------------------------------------------------------------
/cuda_bindings/cuda/bindings/__init__.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2021-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | from cuda.bindings import utils
5 | from cuda.bindings._version import __version__
6 |
--------------------------------------------------------------------------------
/ci/versions.yml:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: Apache-2.0
3 |
4 | backport_branch: "12.9.x"
5 |
6 | cuda:
7 | build:
8 | version: "13.1.0"
9 | prev_build:
10 | version: "12.9.1"
11 |
--------------------------------------------------------------------------------
/cuda_core/docs/source/license.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | Software License Agreement
5 | **************************
6 |
7 | .. literalinclude:: ../../LICENSE
8 | :language: text
9 |
--------------------------------------------------------------------------------
/cuda_bindings/cuda/bindings/_bindings/loader.pxd:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | cdef extern from "loader.h":
5 | int getCUDALibraryPath(char *libPath, bint isBit64)
6 |
--------------------------------------------------------------------------------
/cuda_core/docs/source/release.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | Release Notes
5 | =============
6 |
7 | .. toctree::
8 | :maxdepth: 3
9 | :glob:
10 |
11 | release/*[0-9]-notes
12 |
--------------------------------------------------------------------------------
/cuda_pathfinder/docs/source/license.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | Software License Agreement
5 | **************************
6 |
7 | .. literalinclude:: ../../LICENSE
8 | :language: text
9 |
--------------------------------------------------------------------------------
/cuda_pathfinder/docs/source/release.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | Release Notes
5 | =============
6 |
7 | .. toctree::
8 | :maxdepth: 3
9 | :glob:
10 |
11 | release/*[0-9]-notes
12 |
--------------------------------------------------------------------------------
/cuda_core/cuda/core/utils.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: Apache-2.0
4 |
5 | from cuda.core._memoryview import (
6 | StridedMemoryView, # noqa: F401
7 | args_viewable_as_strided_memory, # noqa: F401
8 | )
9 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | This repository is structured in a way that files are licensed differently
2 | - [`cuda.python`](./cuda_python/LICENSE): NVIDIA Software License
3 | - [`cuda.bindings`](./cuda_bindings/LICENSE): NVIDIA Software License
4 | - [`cuda.core`](./cuda_core/LICENSE) and everything else in this repository: Apache 2.0
5 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/license.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | Software License Agreement
5 | **************************
6 |
7 | .. literalinclude:: ../../LICENSE
8 | :language: text
9 |
--------------------------------------------------------------------------------
/cuda_python/docs/source/release.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | Release Notes
5 | =============
6 |
7 | .. toctree::
8 | :maxdepth: 3
9 | :glob:
10 |
11 | release/*[0-9]-notes
12 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/release.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | Release Notes
5 | =============
6 |
7 | .. toctree::
8 | :maxdepth: 3
9 | :glob:
10 |
11 | release/*[0-9]-notes
12 |
--------------------------------------------------------------------------------
/cuda_core/cuda/core/_memory/_managed_memory_resource.pxd:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: Apache-2.0
4 |
5 | from cuda.core._memory._memory_pool cimport _MemPool
6 |
7 |
8 | cdef class ManagedMemoryResource(_MemPool):
9 | pass
10 |
--------------------------------------------------------------------------------
/cuda_core/cuda/core/_memory/_graph_memory_resource.pxd:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: Apache-2.0
4 |
5 | from cuda.core._memory._buffer cimport MemoryResource
6 |
7 |
8 | cdef class cyGraphMemoryResource(MemoryResource):
9 | cdef:
10 | int _dev_id
11 |
--------------------------------------------------------------------------------
/cuda_core/cuda/core/_memory/_pinned_memory_resource.pxd:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: Apache-2.0
4 |
5 | from cuda.core._memory._memory_pool cimport _MemPool
6 | from cuda.core._memory._ipc cimport IPCDataForMR
7 |
8 |
9 | cdef class PinnedMemoryResource(_MemPool):
10 | pass
11 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/config.yml:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: Apache-2.0
4 |
5 | blank_issues_enabled: true
6 | contact_links:
7 | - name: Questions
8 | url: https://github.com/NVIDIA/cuda-python/discussions
9 | about: Check out our Discussions page to ask and answer questions.
10 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | cuda/_version.py export-subst
2 |
3 | * text eol=lf
4 | *.cmd text eol=crlf
5 |
6 | # we do not own any headers checked in, don't touch them
7 | *.h binary
8 | *.hpp binary
9 | # git should not convert line endings in PNG files
10 | *.png binary
11 | *.svg binary
12 | # SCM syntax highlighting & preventing 3-way merges
13 | pixi.lock merge=binary linguist-language=YAML linguist-generated=true
14 |
--------------------------------------------------------------------------------
/cuda_core/docs/source/_templates/autosummary/dataclass.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | {{ fullname | escape | underline}}
5 |
6 | .. currentmodule:: {{ module }}
7 |
8 | .. autoclass:: {{ objname }}
9 |
10 | {% block methods %}
11 | .. automethod:: __init__
12 | {% endblock %}
13 |
--------------------------------------------------------------------------------
/.github/copy-pr-bot.yaml:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: Apache-2.0
3 |
4 | # Configuration file for `copy-pr-bot` GitHub App
5 | # https://docs.gha-runners.nvidia.com/apps/copy-pr-bot/
6 |
7 | enabled: true
8 | # always require manual CI triggering, ignoring signed commits
9 | auto_sync_draft: false
10 | auto_sync_ready: false
11 |
--------------------------------------------------------------------------------
/cuda_bindings/cuda/bindings/_lib/param_packer.pxd:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | # Include "param_packer.h" so its contents get compiled into every
5 | # Cython extension module that depends on param_packer.pxd.
6 | cdef extern from "param_packer.h":
7 | int feed(void* ptr, object o, object ct)
8 |
--------------------------------------------------------------------------------
/cuda_core/cuda/core/_memory/_device_memory_resource.pxd:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: Apache-2.0
4 |
5 | from cuda.core._memory._memory_pool cimport _MemPool
6 | from cuda.core._memory._ipc cimport IPCDataForMR
7 |
8 |
9 | cdef class DeviceMemoryResource(_MemPool):
10 | pass
11 |
12 |
13 | cpdef DMR_mempool_get_access(DeviceMemoryResource, int)
14 |
--------------------------------------------------------------------------------
/cuda_core/tests/helpers/misc.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: Apache-2.0
3 |
4 |
5 | class StreamWrapper:
6 | """
7 | A wrapper around Stream for testing IsStreamT conversions.
8 | """
9 |
10 | def __init__(self, stream):
11 | self._stream = stream
12 |
13 | def __cuda_stream__(self):
14 | return self._stream.__cuda_stream__()
15 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/module/utils.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | .. module:: cuda.bindings.utils
5 |
6 | utils
7 | =====
8 |
9 | Functions
10 | ---------
11 |
12 | .. autosummary::
13 | :toctree: generated/
14 |
15 | get_cuda_native_handle
16 | get_minimal_required_cuda_ver_from_ptx_ver
17 | get_ptx_ver
18 |
--------------------------------------------------------------------------------
/cuda_core/docs/source/_templates/main.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | If this page does not refresh automatically, then please direct your browser to
10 | our latest docs.
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/cuda_bindings/MANIFEST.in:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | recursive-include cuda/ *.pyx *.pxd *.pxi
5 | # at least with setuptools 75.0.0 this folder was added erroneously
6 | # to the payload, causing file copying to the build environment failed
7 | exclude cuda/bindings cuda?bindings
8 | exclude cuda/bindings/_bindings cuda?bindings?_bindings
9 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/_templates/main.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | If this page does not refresh automatically, then please direct your browser to
10 | our latest docs.
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/cuda_core/cuda/core/_kernel_arg_handler.pxd:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: Apache-2.0
4 |
5 | from libc.stdint cimport intptr_t
6 | from libcpp cimport vector
7 |
8 |
9 | cdef class ParamHolder:
10 |
11 | cdef:
12 | vector.vector[void*] data
13 | vector.vector[void*] data_addresses
14 | object kernel_args
15 | readonly intptr_t ptr
16 |
--------------------------------------------------------------------------------
/cuda_python/docs/source/_templates/main.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | If this page does not refresh automatically, then please direct your browser to
10 | our latest docs.
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/cuda_bindings/tests/cython/build_tests.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 |
3 | REM SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
4 | REM SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
5 |
6 | setlocal
7 | set CL=%CL% /I"%CUDA_HOME%\include"
8 | REM Use -j 1 to side-step any process-pool issues and ensure deterministic single-threaded builds
9 | cythonize -3 -j 1 -i -Xfreethreading_compatible=True %~dp0test_*.pyx
10 | endlocal
11 |
--------------------------------------------------------------------------------
/toolshed/find_sonames.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
4 | #
5 | # SPDX-License-Identifier: Apache-2.0
6 |
7 | find "$@" -type f -name '*.so*' -print0 | while IFS= read -r -d '' f; do
8 | type=$(test -L "$f" && echo SYMLINK || echo FILE)
9 | soname=$(readelf -d "$f" 2>/dev/null | awk '/SONAME/ {gsub(/[][]/, "", $5); print $5; exit}')
10 | echo "$f $type ${soname:-SONAME_NOT_SET}"
11 | done
12 |
--------------------------------------------------------------------------------
/cuda_core/docs/source/_templates/autosummary/namedtuple.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | {{ fullname | escape | underline}}
5 |
6 | .. currentmodule:: {{ module }}
7 |
8 | .. autoclass:: {{ objname }}
9 | :members: __new__
10 | :special-members: __new__
11 | :exclude-members: count, index, __reduce__, __reduce_ex__, __repr__, __hash__, __str__, __getnewargs__
12 |
--------------------------------------------------------------------------------
/cuda_pathfinder/docs/source/_templates/main.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | If this page does not refresh automatically, then please direct your browser to
10 | our latest cuda.pathfinder docs.
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/cuda_bindings/cuda/bindings/_lib/dlfcn.pxd:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | cdef extern from "" nogil:
5 | void *dlopen(const char *, int)
6 | char *dlerror()
7 | void *dlsym(void *, const char *)
8 | int dlclose(void *)
9 |
10 | enum:
11 | RTLD_LAZY
12 | RTLD_NOW
13 | RTLD_GLOBAL
14 | RTLD_LOCAL
15 |
--------------------------------------------------------------------------------
/cuda_pathfinder/docs/source/release/1.2.1-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | .. py:currentmodule:: cuda.pathfinder
5 |
6 | ``cuda-pathfinder`` 1.2.1 Release notes
7 | =======================================
8 |
9 | Released on Aug 29, 2025
10 |
11 |
12 | Highlights
13 | ----------
14 |
15 | * Support cuDSS library (`PR #931 `_)
16 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/api.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | -------------------------
5 | CUDA Python API Reference
6 | -------------------------
7 |
8 | .. toctree::
9 | :maxdepth: 3
10 | :caption: CaptionHolder:
11 |
12 | module/driver
13 | module/runtime
14 | module/nvrtc
15 | module/nvjitlink
16 | module/nvvm
17 | module/cufile
18 | module/utils
19 |
--------------------------------------------------------------------------------
/cuda_core/cuda/core/_event.pxd:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: Apache-2.0
4 |
5 | from cuda.bindings cimport cydriver
6 |
7 |
8 | cdef class Event:
9 |
10 | cdef:
11 | cydriver.CUevent _handle
12 | bint _timing_disabled
13 | bint _busy_waited
14 | bint _ipc_enabled
15 | object _ipc_descriptor
16 | int _device_id
17 | object _ctx_handle
18 |
19 | cpdef close(self)
20 |
--------------------------------------------------------------------------------
/cuda_bindings/examples/common/helper_string.py:
--------------------------------------------------------------------------------
1 | # Copyright 2021-2025 NVIDIA Corporation. All rights reserved.
2 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | import sys
5 |
6 |
7 | def checkCmdLineFlag(stringRef):
8 | return any(stringRef == i and k < len(sys.argv) - 1 for i, k in enumerate(sys.argv))
9 |
10 |
11 | def getCmdLineArgumentInt(stringRef):
12 | for i, k in enumerate(sys.argv):
13 | if stringRef == i and k < len(sys.argv) - 1:
14 | return sys.argv[k + 1]
15 | return 0
16 |
--------------------------------------------------------------------------------
/cuda_pathfinder/docs/source/release/1.3.2-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | .. py:currentmodule:: cuda.pathfinder
5 |
6 | ``cuda-pathfinder`` 1.3.2 Release notes
7 | =======================================
8 |
9 | Released on Oct 29, 2025
10 |
11 | Highlights
12 | ----------
13 |
14 | * Add cuTENSOR support & bug fixes discovered while working on conda testing
15 | (`PR #1194 `_)
16 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ## Description
2 |
3 |
4 | closes
5 |
6 |
7 |
8 |
9 |
10 | ## Checklist
11 |
12 | - [ ] New or existing tests cover these changes.
13 | - [ ] The documentation is up to date with these changes.
14 |
--------------------------------------------------------------------------------
/cuda_pathfinder/tests/local_helpers.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: Apache-2.0
3 |
4 | import functools
5 | import importlib.metadata
6 | import re
7 |
8 |
9 | @functools.cache
10 | def have_distribution(name_pattern: str) -> bool:
11 | re_name_pattern = re.compile(name_pattern)
12 | return any(
13 | re_name_pattern.match(dist.metadata["Name"])
14 | for dist in importlib.metadata.distributions()
15 | if "Name" in dist.metadata
16 | )
17 |
--------------------------------------------------------------------------------
/cuda_pathfinder/docs/source/release/1.1.0-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | .. py:currentmodule:: cuda.pathfinder
5 |
6 | ``cuda-pathfinder`` 1.1.0 Release notes
7 | ========================================
8 |
9 | Released on Aug 7, 2025
10 |
11 |
12 | Highlights
13 | ----------
14 |
15 | * CTK 13.0.0 compatibility
16 | * Bug fix: load ``libnvJitLink.so.12`` from conda, not ``/usr/local/cuda`` (`PR #767 `_)
17 |
--------------------------------------------------------------------------------
/cuda_pathfinder/cuda/pathfinder/_utils/platform_aware.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: Apache-2.0
3 |
4 | import sys
5 |
6 | IS_WINDOWS = sys.platform == "win32"
7 |
8 |
9 | def quote_for_shell(s: str) -> str:
10 | if IS_WINDOWS:
11 | # This is a relatively heavy import; keep pathfinder lean if possible.
12 | from subprocess import list2cmdline
13 |
14 | return list2cmdline([s])
15 | else:
16 | import shlex
17 |
18 | return shlex.quote(s)
19 |
--------------------------------------------------------------------------------
/cuda_core/cuda/core/_memory/__init__.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: Apache-2.0
4 |
5 | from ._buffer import * # noqa: F403
6 | from ._device_memory_resource import * # noqa: F403
7 | from ._graph_memory_resource import * # noqa: F403
8 | from ._ipc import * # noqa: F403
9 | from ._legacy import * # noqa: F403
10 | from ._managed_memory_resource import * # noqa: F403
11 | from ._pinned_memory_resource import * # noqa: F403
12 | from ._virtual_memory_resource import * # noqa: F403
13 |
--------------------------------------------------------------------------------
/pixi.lock:
--------------------------------------------------------------------------------
1 | version: 6
2 | environments:
3 | cu12:
4 | channels:
5 | - url: https://conda.anaconda.org/conda-forge/
6 | options:
7 | pypi-prerelease-mode: if-necessary-or-explicit
8 | packages: {}
9 | cu13:
10 | channels:
11 | - url: https://conda.anaconda.org/conda-forge/
12 | options:
13 | pypi-prerelease-mode: if-necessary-or-explicit
14 | packages: {}
15 | default:
16 | channels:
17 | - url: https://conda.anaconda.org/conda-forge/
18 | options:
19 | pypi-prerelease-mode: if-necessary-or-explicit
20 | packages: {}
21 | packages: []
22 |
--------------------------------------------------------------------------------
/cuda_bindings/cuda/bindings/_bindings/loader.h:
--------------------------------------------------------------------------------
1 | // SPDX-FileCopyrightText: Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | // SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 | //
4 | // Please refer to the NVIDIA end user license agreement (EULA) associated
5 | // with this source code for terms and conditions that govern your use of
6 | // this software. Any use, reproduction, disclosure, or distribution of
7 | // this software and related documentation outside the terms of the EULA
8 | // is strictly prohibited.
9 | int getCUDALibraryPath(char *libPath, bool isBit64);
10 |
--------------------------------------------------------------------------------
/pytest.ini:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: Apache-2.0
3 |
4 | [pytest]
5 | addopts = --showlocals
6 | norecursedirs =
7 | cuda_bindings/examples
8 | cuda_core/examples
9 |
10 | testpaths =
11 | cuda_pathfinder/tests
12 | cuda_bindings/tests
13 | cuda_core/tests
14 | tests/integration
15 |
16 | markers =
17 | pathfinder: tests for cuda_pathfinder
18 | bindings: tests for cuda_bindings
19 | core: tests for cuda_core
20 | cython: cython tests
21 | smoke: meta-level smoke tests
22 |
--------------------------------------------------------------------------------
/cuda_pathfinder/docs/source/index.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | ``cuda.pathfinder``: Utilities for locating CUDA components
5 | ===========================================================
6 |
7 | .. toctree::
8 | :maxdepth: 2
9 | :caption: Contents:
10 |
11 | api
12 | contribute
13 | license
14 |
15 | .. toctree::
16 | :maxdepth: 2
17 |
18 | release
19 |
20 |
21 | Indices and tables
22 | ==================
23 |
24 | * :ref:`genindex`
25 | * :ref:`modindex`
26 | * :ref:`search`
27 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: Apache-2.0
4 |
5 | version: 2
6 | updates:
7 | - package-ecosystem: github-actions
8 | directory: /
9 | schedule:
10 | interval: "monthly"
11 | time: "09:00"
12 | timezone: "America/Los_Angeles"
13 |
14 | # Keep churn down: only one open PR from this ecosystem at a time
15 | open-pull-requests-limit: 1
16 |
17 | groups:
18 | actions-monthly:
19 | applies-to: version-updates
20 | patterns: ["*"]
21 | update-types: ["major", "minor", "patch"]
22 |
--------------------------------------------------------------------------------
/cuda_pathfinder/docs/source/release/1.2.3-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | .. py:currentmodule:: cuda.pathfinder
5 |
6 | ``cuda-pathfinder`` 1.2.3 Release notes
7 | =======================================
8 |
9 | Released on Sep 17, 2025
10 |
11 |
12 | Highlights
13 | ----------
14 |
15 | * Make the ``cuda.pathfinder._find_nvidia_header_directory`` API public
16 | (by removing the leading underscore) and extend the function
17 | to also support CTK library headers
18 | (`PR #956 `_)
19 |
--------------------------------------------------------------------------------
/cuda_pathfinder/docs/source/release/1.2.2-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | .. py:currentmodule:: cuda.pathfinder
5 |
6 | ``cuda-pathfinder`` 1.2.2 Release notes
7 | =======================================
8 |
9 | Released on Sep 8, 2025
10 |
11 |
12 | Highlights
13 | ----------
14 |
15 | * Support nccl library (`PR #945 `_)
16 |
17 | * Add experimental ``cuda.pathfinder._find_nvidia_headers`` API,
18 | currently limited to supporting ``nvshmem``
19 | (`PR #661 `_)
20 |
--------------------------------------------------------------------------------
/cuda_python/docs/source/release/11.8.7-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 11.8.7 Release notes
5 | ================================
6 |
7 | Released on May 6, 2025.
8 |
9 |
10 | Included components
11 | -------------------
12 |
13 | * `cuda.bindings 11.8.7 `_
14 |
15 |
16 | Highlights
17 | ----------
18 |
19 | * The ``cuda.bindings.nvvm`` Python module was added, wrapping the
20 | `libNVVM C API `_.
21 |
--------------------------------------------------------------------------------
/cuda_pathfinder/docs/source/release/1.3.1-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | .. py:currentmodule:: cuda.pathfinder
5 |
6 | ``cuda-pathfinder`` 1.3.1 Release notes
7 | =======================================
8 |
9 | Released on Oct 13, 2025
10 |
11 | Highlights
12 | ----------
13 |
14 | * supported_nvidia_libs.py updates:
15 | add nvidia-cublasmp-cu12, nvidia-cublasmp-cu13, nvidia-cudss-cu13
16 | (`PR #1089 `_)
17 |
18 | * Add ``LoadedDL.found_via``
19 | (`PR #1049 `_)
20 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/index.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | ``cuda.bindings``: Low-level Python Bindings for CUDA
5 | =====================================================
6 |
7 | .. toctree::
8 | :maxdepth: 2
9 | :caption: Contents:
10 |
11 | release
12 | install
13 | overview
14 | motivation
15 | environment_variables
16 | api
17 | tips_and_tricks
18 | support
19 | contribute
20 | conduct
21 | license
22 |
23 |
24 | Indices and tables
25 | ==================
26 |
27 | * :ref:`genindex`
28 | * :ref:`modindex`
29 | * :ref:`search`
30 |
--------------------------------------------------------------------------------
/cuda_python/docs/environment-docs.yml:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | name: cuda-python-docs
5 | channels:
6 | - conda-forge
7 | dependencies:
8 | # ATTENTION: This dependency list is duplicated in
9 | # toolshed/setup-docs-env.sh. Please KEEP THEM IN SYNC!
10 | - cython
11 | - myst-parser
12 | - numpy
13 | - numpydoc
14 | - pip
15 | - pydata-sphinx-theme
16 | - pytest
17 | - scipy
18 | - sphinx <8.2.0
19 | - sphinx-copybutton
20 | - myst-nb
21 | - enum_tools
22 | - sphinx-toolbox
23 | - pyclibrary
24 | - pip:
25 | - nvidia-sphinx-theme
26 |
--------------------------------------------------------------------------------
/cuda_core/docs/README.md:
--------------------------------------------------------------------------------
1 | # Build the documentation
2 |
3 | 1. Install the `cuda-core` package of the version that we need to document.
4 | 2. Ensure the version is included in the [`nv-versions.json`](./nv-versions.json).
5 | 3. Build the docs with `./build_docs.sh`.
6 | 4. The html artifacts should be available under both `./build/html/latest` and `./build/html/`.
7 |
8 | 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).
9 |
10 | To publish the docs with the built version, it is important to note that the html files of older versions
11 | should be kept intact, in order for the version selection (through `nv-versions.json`) to work.
12 |
--------------------------------------------------------------------------------
/cuda_python/docs/source/release/12.6.1-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python Release notes
5 | =========================
6 |
7 | Released on Oct 7, 2024
8 |
9 | Included components
10 | -------------------
11 |
12 | * `cuda.bindings 12.6.1 `_
13 |
14 | Hightlights
15 | -----------
16 | - Internal layout refactoring to prepare for the ``cuda-python`` metapackage (`Issue #90 `_,
17 | `Issue #75 `_)
18 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/README.md:
--------------------------------------------------------------------------------
1 | # Build the documentation
2 |
3 | 1. Install the `cuda-bindings` package of the version that we need to document.
4 | 2. Ensure the version is included in the [`nv-versions.json`](./nv-versions.json).
5 | 3. Build the docs with `./build_docs.sh`.
6 | 4. The html artifacts should be available under both `./build/html/latest` and `./build/html/`.
7 |
8 | 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).
9 |
10 | To publish the docs with the built version, it is important to note that the html files of older versions
11 | should be kept intact, in order for the version selection (through `nv-versions.json`) to work.
12 |
--------------------------------------------------------------------------------
/cuda_pathfinder/docs/source/api.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | .. module:: cuda.pathfinder
5 |
6 | ``cuda.pathfinder`` API Reference
7 | =================================
8 |
9 | The ``cuda.pathfinder`` module provides utilities for loading NVIDIA dynamic libraries,
10 | and experimental APIs for locating NVIDIA C/C++ header directories.
11 |
12 | .. autosummary::
13 | :toctree: generated/
14 |
15 | SUPPORTED_NVIDIA_LIBNAMES
16 | load_nvidia_dynamic_lib
17 | LoadedDL
18 | DynamicLibNotFoundError
19 |
20 | SUPPORTED_HEADERS_CTK
21 | SUPPORTED_HEADERS_NON_CTK
22 | find_nvidia_header_directory
23 |
--------------------------------------------------------------------------------
/cuda_pathfinder/docs/README.md:
--------------------------------------------------------------------------------
1 | # Build the documentation
2 |
3 | 1. Install the `cuda-pathfinder` package of the version that we need to document.
4 | 2. Ensure the version is included in the [`nv-versions.json`](./nv-versions.json).
5 | 3. Build the docs with `./build_docs.sh`.
6 | 4. The html artifacts should be available under both `./build/html/latest` and `./build/html/`.
7 |
8 | 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).
9 |
10 | To publish the docs with the built version, it is important to note that the html files of older versions
11 | should be kept intact, in order for the version selection (through `nv-versions.json`) to work.
12 |
--------------------------------------------------------------------------------
/cuda_core/cuda/core/_launch_config.pxd:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: Apache-2.0
4 |
5 | from libcpp.vector cimport vector
6 |
7 | from cuda.bindings cimport cydriver
8 |
9 |
10 | cdef class LaunchConfig:
11 | """Customizable launch options."""
12 | cdef:
13 | public tuple grid
14 | public tuple cluster
15 | public tuple block
16 | public int shmem_size
17 | public bint cooperative_launch
18 |
19 | vector[cydriver.CUlaunchAttribute] _attrs
20 |
21 | cdef cydriver.CUlaunchConfig _to_native_launch_config(self)
22 |
23 |
24 | cpdef object _to_native_launch_config(LaunchConfig config)
25 |
--------------------------------------------------------------------------------
/cuda_core/cuda/core/_stream.pxd:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: Apache-2.0
4 |
5 | from cuda.bindings cimport cydriver
6 |
7 |
8 | cdef class Stream:
9 |
10 | cdef:
11 | cydriver.CUstream _handle
12 | object _owner
13 | bint _builtin
14 | int _nonblocking
15 | int _priority
16 | cydriver.CUdevice _device_id
17 | cydriver.CUcontext _ctx_handle
18 |
19 | cpdef close(self)
20 | cdef int _get_context(self) except?-1 nogil
21 | cdef int _get_device_and_context(self) except?-1
22 |
23 |
24 | cpdef Stream default_stream()
25 | cdef Stream Stream_accept(arg, bint allow_stream_protocol=*)
26 |
--------------------------------------------------------------------------------
/cuda_core/setup.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: Apache-2.0
4 |
5 | import os
6 |
7 | import build_hooks # our build backend
8 | from setuptools import setup
9 | from setuptools.command.build_ext import build_ext as _build_ext
10 |
11 | nthreads = int(os.environ.get("CUDA_PYTHON_PARALLEL_LEVEL", os.cpu_count() // 2))
12 |
13 |
14 | class build_ext(_build_ext):
15 | def build_extensions(self):
16 | self.parallel = nthreads
17 | super().build_extensions()
18 |
19 |
20 | setup(
21 | ext_modules=build_hooks._extensions,
22 | cmdclass={
23 | "build_ext": build_ext,
24 | },
25 | zip_safe=False,
26 | )
27 |
--------------------------------------------------------------------------------
/cuda_core/docs/source/_templates/autosummary/cyclass.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | {{ fullname | escape | underline}}
5 |
6 | .. currentmodule:: {{ module }}
7 |
8 | .. autoclass:: {{ objname }}
9 |
10 | {% block attributes %}
11 | {% if attributes %}
12 | {% for item in attributes %}
13 | .. autoattribute:: {{ item }}
14 | {%- endfor %}
15 | {% endif %}
16 | {% endblock %}
17 |
18 | {% block methods %}
19 | {% if methods %}
20 | .. rubric:: {{ _('Methods') }}
21 |
22 | {% for item in methods %}
23 | .. automethod:: {{ item }}
24 | {%- endfor %}
25 |
26 | {% endif %}
27 | {% endblock %}
28 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/release/12.9.2-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | .. module:: cuda.bindings
5 |
6 | ``cuda-bindings`` 12.9.2 Release notes
7 | ======================================
8 |
9 | Released on Aug 18, 2025
10 |
11 |
12 | Highlights
13 | ----------
14 |
15 | * Make populating the internal symbol table thread-safe.
16 |
17 |
18 | Known issues
19 | ------------
20 |
21 | * Updating from older versions (v12.6.2.post1 and below) via ``pip install -U cuda-python`` might not work. Please do a clean re-installation by uninstalling ``pip uninstall -y cuda-python`` followed by installing ``pip install cuda-python``.
22 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/release/13.0.1-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | .. module:: cuda.bindings
5 |
6 | ``cuda-bindings`` 13.0.1 Release notes
7 | ======================================
8 |
9 | Released on Aug 18, 2025
10 |
11 |
12 | Highlights
13 | ----------
14 |
15 | * Make populating the internal symbol table thread-safe.
16 |
17 |
18 | Known issues
19 | ------------
20 |
21 | * Updating from older versions (v12.6.2.post1 and below) via ``pip install -U cuda-python`` might not work. Please do a clean re-installation by uninstalling ``pip uninstall -y cuda-python`` followed by installing ``pip install cuda-python``.
22 |
--------------------------------------------------------------------------------
/cuda_core/docs/source/release/0.4.2-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | .. currentmodule:: cuda.core.experimental
5 |
6 | ``cuda.core`` 0.4.2 Release Notes
7 | =================================
8 |
9 |
10 | Highlights
11 | ----------
12 |
13 | None.
14 |
15 |
16 | Breaking Changes
17 | ----------------
18 |
19 | None.
20 |
21 |
22 | New features
23 | ------------
24 |
25 | None.
26 |
27 |
28 | New examples
29 | ------------
30 |
31 | None.
32 |
33 |
34 | Fixes and enhancements
35 | ----------------------
36 |
37 | - Fixed references to the ``cuda.bindings`` module mistakenly purged globally.
38 | - Restored compatibility with ``cuda-python`` 12.6.
39 |
--------------------------------------------------------------------------------
/cuda_python/docs/source/release/13.1.1-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 13.1.1 Release notes
5 | ================================
6 |
7 | Released on Dec 9, 2025.
8 |
9 | Included components
10 | -------------------
11 |
12 | * `cuda.bindings 13.1.1 `_
13 |
14 | Known issues
15 | ------------
16 |
17 | * Updating from older versions (v12.6.2.post1 and below) via ``pip install -U cuda-python`` might not work. Please do a clean re-installation by uninstalling ``pip uninstall -y cuda-python`` followed by installing ``pip install cuda-python``.
18 |
--------------------------------------------------------------------------------
/cuda_core/docs/source/index.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | ``cuda.core``: Pythonic access to CUDA core functionality
5 | =========================================================
6 |
7 | Welcome to the documentation for ``cuda.core``.
8 |
9 | .. toctree::
10 | :maxdepth: 2
11 | :caption: Contents:
12 |
13 | getting-started
14 | install
15 | interoperability
16 | api
17 | contribute
18 |
19 | .. toctree::
20 | :maxdepth: 1
21 |
22 | conduct
23 | license
24 |
25 | .. toctree::
26 | :maxdepth: 2
27 |
28 | release
29 |
30 | Indices and tables
31 | ==================
32 |
33 | * :ref:`genindex`
34 | * :ref:`modindex`
35 | * :ref:`search`
36 |
--------------------------------------------------------------------------------
/cuda_core/docs/source/_templates/autosummary/class.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | {{ fullname | escape | underline}}
5 |
6 | .. currentmodule:: {{ module }}
7 |
8 | .. autoclass:: {{ objname }}
9 |
10 | {% block methods %}
11 | {% if methods %}
12 | .. rubric:: {{ _('Methods') }}
13 |
14 | {% for item in methods %}
15 | .. automethod:: {{ item }}
16 | {%- endfor %}
17 |
18 | {% endif %}
19 | {% endblock %}
20 |
21 | {% block attributes %}
22 | {% if attributes %}
23 | .. rubric:: {{ _('Attributes') }}
24 |
25 | {% for item in attributes %}
26 | .. autoproperty:: {{ item }}
27 | {%- endfor %}
28 | {% endif %}
29 | {% endblock %}
30 |
--------------------------------------------------------------------------------
/cuda_core/docs/source/_templates/autosummary/protocol.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | {{ fullname | escape | underline}}
5 |
6 | .. currentmodule:: {{ module }}
7 |
8 | .. autoprotocol:: {{ objname }}
9 |
10 | {% block methods %}
11 | {% if methods %}
12 | .. rubric:: {{ _('Methods') }}
13 |
14 | {% for item in methods %}
15 | .. automethod:: {{ item }}
16 | {%- endfor %}
17 |
18 | {% endif %}
19 | {% endblock %}
20 |
21 | {% block attributes %}
22 | {% if attributes %}
23 | .. rubric:: {{ _('Attributes') }}
24 |
25 | {% for item in attributes %}
26 | .. autoproperty:: {{ item }}
27 | {%- endfor %}
28 | {% endif %}
29 | {% endblock %}
30 |
--------------------------------------------------------------------------------
/cuda_bindings/tests/cython/build_tests.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
4 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
5 |
6 | UNAME=$(uname)
7 | if [ "$UNAME" == "Linux" ] ; then
8 | SCRIPTPATH=$(dirname $(realpath "$0"))
9 | export CPLUS_INCLUDE_PATH=$CUDA_HOME/include:$CPLUS_INCLUDE_PATH
10 | elif [[ "$UNAME" == CYGWIN* || "$UNAME" == MINGW* || "$UNAME" == MSYS* ]] ; then
11 | SCRIPTPATH="$(dirname $(cygpath -w $(realpath "$0")))"
12 | export CL="/I\"${CUDA_HOME}\\include\" ${CL}"
13 | else
14 | exit 1
15 | fi
16 |
17 | # Use -j 1 to side-step any process-pool issues and ensure deterministic single-threaded builds
18 | cythonize -3 -j 1 -i -Xfreethreading_compatible=True ${SCRIPTPATH}/test_*.pyx
19 |
--------------------------------------------------------------------------------
/.github/workflows/triagelabel.yml:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: Apache-2.0
4 |
5 | name: Add Triage Label
6 |
7 | on:
8 | issues:
9 | types:
10 | - reopened
11 | - opened
12 |
13 | jobs:
14 | triage:
15 | runs-on: ubuntu-latest
16 | permissions:
17 | issues: write
18 | steps:
19 | - name: Add or check for existing labels
20 | # add the triage label only if no label has been added
21 | if: ${{ github.event.issue.labels[0] == null }}
22 | run: gh issue edit "$NUMBER" --add-label "triage"
23 | env:
24 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25 | GH_REPO: ${{ github.repository }}
26 | NUMBER: ${{ github.event.issue.number }}
27 |
--------------------------------------------------------------------------------
/cuda_python/docs/source/release/12.6.2-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python Release notes
5 | =========================
6 |
7 | Released on November 5, 2024. Post 1 rebuild released on November 12, 2024.
8 |
9 | Included components
10 | -------------------
11 |
12 | * `cuda.bindings 12.6.2 `_
13 |
14 | Hightlights
15 | -----------
16 | - Resolve `Issue #215 `_: module ``cuda.ccudart`` has no attribute ``__pyx_capi__``
17 | - Resolve `Issue #226 `_: top-level Cython source files not packaged
18 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/release/12.9.4-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | .. module:: cuda.bindings
5 |
6 | ``cuda-bindings`` 12.9.4 Release notes
7 | ======================================
8 |
9 |
10 |
11 | Highlights
12 | ----------
13 |
14 |
15 | Bug fixes
16 | ---------
17 |
18 | * The graphics APIs in ``cuda.bindings.runtime`` were inadvertently disabled in 12.9.3. This has been fixed.
19 |
20 | Known issues
21 | ------------
22 |
23 | * Updating from older versions (v12.6.2.post1 and below) via ``pip install -U cuda-python`` might not work. Please do a clean re-installation by uninstalling ``pip uninstall -y cuda-python`` followed by installing ``pip install cuda-python``.
24 |
--------------------------------------------------------------------------------
/cuda_pathfinder/docs/source/release/1.0.0-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | .. py:currentmodule:: cuda.pathfinder
5 |
6 | ``cuda-pathfinder`` 1.0.0 Release notes
7 | ========================================
8 |
9 | Released on Jul 16, 2025
10 |
11 |
12 | Highlights
13 | ----------
14 |
15 | * First release of ``cuda-pathfinder`` as a stand-alone module.
16 | * Replaces ``cuda.bindings.path_finder``, which was released with ``cuda-bindings`` 12.9.0 and is now `deprecated `_.
17 | * ``cuda-pathfinder`` is a noarch package and has no dependencies (other than a Python 3.9+ interpreter).
18 |
--------------------------------------------------------------------------------
/toolshed/conda_create_for_pathfinder_testing.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
4 | # SPDX-License-Identifier: Apache-2.0
5 |
6 | if [[ $# -ne 1 ]]; then
7 | echo "Usage: $(basename "$0") ctk-major-minor-patch" 1>&2
8 | exit 1
9 | fi
10 |
11 | eval "$(conda shell.bash hook)"
12 |
13 | conda create --yes -n "pathfinder_testing_cu$1" python=3.13 cuda-toolkit="$1"
14 | conda activate "pathfinder_testing_cu$1"
15 |
16 | for cpkg in \
17 | cusparselt-dev \
18 | cutensor \
19 | libcublasmp-dev \
20 | libcudss-dev \
21 | libcufftmp-dev \
22 | libmathdx-dev \
23 | libnvshmem3 \
24 | libnvshmem-dev \
25 | libnvpl-fft-dev; do
26 | echo "CONDA INSTALL: $cpkg"
27 | conda install -y -c conda-forge "$cpkg"
28 | done
29 |
--------------------------------------------------------------------------------
/cuda_core/tests/cython/build_tests.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
4 | # SPDX-License-Identifier: Apache-2.0
5 |
6 | UNAME=$(uname)
7 | if [ "$UNAME" == "Linux" ] ; then
8 | SCRIPTPATH=$(dirname $(realpath "$0"))
9 | export CPLUS_INCLUDE_PATH=${SCRIPTPATH}/../../cuda/core/_include:$CUDA_HOME/include:$CPLUS_INCLUDE_PATH
10 | elif [[ "$UNAME" == CYGWIN* || "$UNAME" == MINGW* || "$UNAME" == MSYS* ]] ; then
11 | SCRIPTPATH="$(dirname $(cygpath -w $(realpath "$0")))"
12 | CUDA_CORE_INCLUDE_PATH=$(echo "${SCRIPTPATH}\..\..\cuda\core\_include" | sed 's/\\/\\\\/g')
13 | export CL="/I\"${CUDA_CORE_INCLUDE_PATH}\" /I\"${CUDA_HOME}\\include\" ${CL}"
14 | else
15 | exit 1
16 | fi
17 |
18 | cythonize -3 -i -Xfreethreading_compatible=True ${SCRIPTPATH}/test_*.pyx
19 |
--------------------------------------------------------------------------------
/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/load_dl_common.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: Apache-2.0
3 |
4 | from collections.abc import Callable
5 | from dataclasses import dataclass
6 |
7 | from cuda.pathfinder._dynamic_libs.supported_nvidia_libs import DIRECT_DEPENDENCIES
8 |
9 |
10 | class DynamicLibNotFoundError(RuntimeError):
11 | pass
12 |
13 |
14 | @dataclass
15 | class LoadedDL:
16 | abs_path: str | None
17 | was_already_loaded_from_elsewhere: bool
18 | _handle_uint: int # Platform-agnostic unsigned pointer value
19 | found_via: str
20 |
21 |
22 | def load_dependencies(libname: str, load_func: Callable[[str], LoadedDL]) -> None:
23 | for dep in DIRECT_DEPENDENCIES.get(libname, ()):
24 | load_func(dep)
25 |
--------------------------------------------------------------------------------
/cuda_core/cuda/core/_memory/_buffer.pxd:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: Apache-2.0
4 |
5 | from libc.stdint cimport uintptr_t
6 |
7 | from cuda.core._stream cimport Stream
8 |
9 |
10 | cdef struct _MemAttrs:
11 | int device_id
12 | bint is_device_accessible
13 | bint is_host_accessible
14 |
15 |
16 | cdef class Buffer:
17 | cdef:
18 | uintptr_t _ptr
19 | size_t _size
20 | MemoryResource _memory_resource
21 | object _ipc_data
22 | object _owner
23 | object _ptr_obj
24 | Stream _alloc_stream
25 | _MemAttrs _mem_attrs
26 | bint _mem_attrs_inited
27 |
28 |
29 | cdef class MemoryResource:
30 | pass
31 |
--------------------------------------------------------------------------------
/cuda_python/docs/source/release/11.8.6-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 11.8.6 Release notes
5 | ================================
6 |
7 | Released on January 24, 2025.
8 |
9 | Included components
10 | -------------------
11 |
12 | * `cuda.bindings 11.8.6 `_
13 |
14 | Highlights
15 | ----------
16 |
17 | - Support Python 3.13
18 | - Add optional dependencies on the CUDA NVRTC wheel
19 | - Enable discovery and loading of shared libraries from CUDA wheels
20 | - ``cuda-python`` is now a meta package, currently depending only on ``cuda-bindings`` (`see RFC `_)
21 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/release/11.8.7-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | ``cuda-bindings`` 11.8.7 Release notes
5 | ======================================
6 |
7 | Released on May 5, 2025.
8 |
9 |
10 | Highlights
11 | ----------
12 |
13 | * The ``cuda.bindings.nvvm`` Python module was added, wrapping the
14 | `libNVVM C API `_.
15 |
16 |
17 | Bug fixes
18 | ---------
19 |
20 | * Fix segfault when converting char* NULL to bytes
21 |
22 |
23 | Known issues
24 | ------------
25 |
26 | * Compute-sanitizer may report ``CUDA_ERROR_INVALID_CONTEXT`` when calling certain CUDA
27 | runtime APIs such as ``cudaGetDevice()``. This is fixed in ``cuda-bindings`` 12.9.0.
28 |
--------------------------------------------------------------------------------
/cuda_core/tests/example_tests/test_basic_examples.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: Apache-2.0
3 |
4 | # If we have subcategories of examples in the future, this file can be split along those lines
5 |
6 | import glob
7 | import os
8 |
9 | import pytest
10 | from cuda.core import Device
11 |
12 | from .utils import run_example
13 |
14 | samples_path = os.path.join(os.path.dirname(__file__), "..", "..", "examples")
15 | sample_files = glob.glob(samples_path + "**/*.py", recursive=True)
16 |
17 |
18 | @pytest.mark.parametrize("example", sample_files)
19 | class TestExamples:
20 | def test_example(self, example, deinit_cuda):
21 | run_example(samples_path, example)
22 | if Device().device_id != 0:
23 | Device(0).set_current()
24 |
--------------------------------------------------------------------------------
/cuda_python/docs/source/release/12.9.5-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 12.9.5 Release notes
5 | ================================
6 |
7 |
8 | Included components
9 | -------------------
10 |
11 | * `cuda.bindings 12.9.5 `_
12 | * `cuda.pathfinder 1.3.3 `_
13 |
14 |
15 | Known issues
16 | ------------
17 |
18 | * Updating from older versions (v12.6.2.post1 and below) via ``pip install -U cuda-python`` might not work. Please do a clean re-installation by uninstalling ``pip uninstall -y cuda-python`` followed by installing ``pip install cuda-python``.
19 |
--------------------------------------------------------------------------------
/cuda_pathfinder/tests/test_spawned_process_runner.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: Apache-2.0
3 |
4 | # Note: This only covers what is not covered already in test_nvidia_dynamic_libs_load_lib.py
5 |
6 | import pytest
7 | from spawned_process_runner import run_in_spawned_child_process
8 |
9 |
10 | def child_crashes():
11 | raise RuntimeError("this is an intentional failure")
12 |
13 |
14 | def test_rethrow_child_exception():
15 | with pytest.raises(ChildProcessError) as excinfo:
16 | run_in_spawned_child_process(child_crashes, rethrow=True)
17 |
18 | msg = str(excinfo.value)
19 | assert "Child process exited with code 1" in msg
20 | assert "this is an intentional failure" in msg
21 | assert "--- stderr-from-child-process ---" in msg
22 |
--------------------------------------------------------------------------------
/cuda_bindings/tests/cufile.json:
--------------------------------------------------------------------------------
1 | {
2 | // NOTE : Application can override custom configuration via export CUFILE_ENV_PATH_JSON=
3 | // e.g : export CUFILE_ENV_PATH_JSON="/home//cufile.json"
4 |
5 |
6 | "execution" : {
7 | // max number of workitems in the queue;
8 | "max_io_queue_depth": 128,
9 | // max number of host threads per gpu to spawn for parallel IO
10 | "max_io_threads" : 4,
11 | // enable support for parallel IO
12 | "parallel_io" : true,
13 | // minimum IO threshold before splitting the IO
14 | "min_io_threshold_size_kb" : 8192,
15 | // maximum parallelism for a single request
16 | "max_request_parallelism" : 4
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/cuda_python_test_helpers/pyproject.toml:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: Apache-2.0
3 |
4 | [build-system]
5 | requires = ["setuptools>=77.0.0"]
6 | build-backend = "setuptools.build_meta"
7 |
8 | [project]
9 | name = "cuda-python-test-helpers"
10 | version = "0.1.0"
11 | description = "Shared test helpers for CUDA Python projects"
12 | readme = {file = "README.md", content-type = "text/markdown"}
13 | authors = [{ name = "NVIDIA Corporation" }]
14 | license = "Apache-2.0"
15 | requires-python = ">=3.9"
16 | classifiers = [
17 | "Programming Language :: Python :: 3 :: Only",
18 | "Operating System :: POSIX :: Linux",
19 | ]
20 |
21 | [tool.setuptools]
22 | packages = ["cuda_python_test_helpers"]
23 |
24 | [project.urls]
25 | repository = "https://github.com/NVIDIA/cuda-python"
26 |
--------------------------------------------------------------------------------
/cuda_python/docs/source/release/12.9.0-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 12.9.0 Release notes
5 | ================================
6 |
7 | Released on May 5, 2025.
8 |
9 |
10 | Included components
11 | -------------------
12 |
13 | * `cuda.bindings 12.9.0 `_
14 |
15 |
16 | Highlights
17 | ----------
18 |
19 | * Add bindings for libNVVM
20 |
21 |
22 | Known issues
23 | ------------
24 |
25 | * Updating from older versions (v12.6.2.post1 and below) via ``pip install -U cuda-python`` might not work. Please do a clean re-installation by uninstalling ``pip uninstall -y cuda-python`` followed by installing ``pip install cuda-python``.
26 |
--------------------------------------------------------------------------------
/cuda_pathfinder/docs/source/release/1.3.3-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | .. py:currentmodule:: cuda.pathfinder
5 |
6 | ``cuda-pathfinder`` 1.3.3 Release notes
7 | =======================================
8 |
9 | Released on Dec 4, 2025
10 |
11 | Highlights
12 | ----------
13 |
14 | * Add cuSPARSELt support (`PR #1200 `_)
15 |
16 | * Purge support for CTK 11 (those became unsupported with the CTK 13.0 release in August 2025).
17 | (`PR #1315 `_)
18 |
19 | * Remove ``cudart64_65.dll`` and ``cudart64_101.dll`` from supported_nvidia_libs.py;
20 | these outdated DLLs were included accidentally.
21 | (`PR #1315 `_)
22 |
--------------------------------------------------------------------------------
/cuda_python/docs/source/release/13.1.0-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 13.1.0 Release notes
5 | ================================
6 |
7 | Released on Dec 4, 2025.
8 |
9 |
10 | Included components
11 | -------------------
12 |
13 | * `cuda.bindings 13.1.0 `_
14 | * `cuda.pathfinder 1.3.3 `_
15 |
16 |
17 | Known issues
18 | ------------
19 |
20 | * Updating from older versions (v12.6.2.post1 and below) via ``pip install -U cuda-python`` might not work. Please do a clean re-installation by uninstalling ``pip uninstall -y cuda-python`` followed by installing ``pip install cuda-python``.
21 |
--------------------------------------------------------------------------------
/cuda_python/docs/source/release/12.9.4-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 12.9.4 Release notes
5 | ================================
6 |
7 | Released on Oct 20, 2025.
8 |
9 |
10 | Included components
11 | -------------------
12 |
13 | * `cuda.bindings 12.9.4 `_
14 | * `cuda.pathfinder >=1.1.0 `_
15 |
16 |
17 | Known issues
18 | ------------
19 |
20 | * Updating from older versions (v12.6.2.post1 and below) via ``pip install -U cuda-python`` might not work. Please do a clean re-installation by uninstalling ``pip uninstall -y cuda-python`` followed by installing ``pip install cuda-python``.
21 |
--------------------------------------------------------------------------------
/cuda_python/docs/source/release/13.0.3-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 13.0.3 Release notes
5 | ================================
6 |
7 | Released on Oct 20, 2025.
8 |
9 |
10 | Included components
11 | -------------------
12 |
13 | * `cuda.bindings 13.0.3 `_
14 | * `cuda.pathfinder >=1.1.0 `_
15 |
16 |
17 | Known issues
18 | ------------
19 |
20 | * Updating from older versions (v12.6.2.post1 and below) via ``pip install -U cuda-python`` might not work. Please do a clean re-installation by uninstalling ``pip uninstall -y cuda-python`` followed by installing ``pip install cuda-python``.
21 |
--------------------------------------------------------------------------------
/cuda_core/docs/source/release/0.3.2-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | .. currentmodule:: cuda.core.experimental
5 |
6 | ``cuda.core`` 0.3.2 Release Notes
7 | =================================
8 |
9 | Released on Aug 7, 2025
10 |
11 |
12 | Highlights
13 | ----------
14 |
15 | - Support CUDA 13. ``pip install cuda-core[cu13]`` also works now.
16 | - This is the last release that officially supports CUDA 11.
17 |
18 |
19 | Breaking Changes
20 | ----------------
21 |
22 | None.
23 |
24 |
25 | New features
26 | ------------
27 |
28 | - :class:`Stream` and :class:`Event` can be subclassed now.
29 |
30 |
31 | New examples
32 | ------------
33 |
34 | None.
35 |
36 |
37 | Fixes and enhancements
38 | ----------------------
39 |
40 | - :meth:`Device.set_current` is made faster.
41 |
--------------------------------------------------------------------------------
/cuda_bindings/tests/conftest.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | import cuda.bindings.driver as cuda
5 | import pytest
6 |
7 |
8 | @pytest.fixture(scope="module")
9 | def cuda_driver():
10 | (err,) = cuda.cuInit(0)
11 | assert err == cuda.CUresult.CUDA_SUCCESS
12 |
13 |
14 | @pytest.fixture(scope="module")
15 | def device(cuda_driver):
16 | err, device = cuda.cuDeviceGet(0)
17 | assert err == cuda.CUresult.CUDA_SUCCESS
18 | return device
19 |
20 |
21 | @pytest.fixture(scope="module", autouse=True)
22 | def ctx(device):
23 | # Construct context
24 | err, ctx = cuda.cuCtxCreate(None, 0, device)
25 | assert err == cuda.CUresult.CUDA_SUCCESS
26 | yield ctx
27 | (err,) = cuda.cuCtxDestroy(ctx)
28 | assert err == cuda.CUresult.CUDA_SUCCESS
29 |
--------------------------------------------------------------------------------
/cuda_python/docs/source/release/12.9.2-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 12.9.2 Release notes
5 | ================================
6 |
7 | Released on Aug 18, 2025.
8 |
9 |
10 | Included components
11 | -------------------
12 |
13 | * `cuda.bindings 12.9.2 `_
14 | * `cuda.pathfinder 1.1.0 `_
15 |
16 |
17 | Known issues
18 | ------------
19 |
20 | * Updating from older versions (v12.6.2.post1 and below) via ``pip install -U cuda-python`` might not work. Please do a clean re-installation by uninstalling ``pip uninstall -y cuda-python`` followed by installing ``pip install cuda-python``.
21 |
--------------------------------------------------------------------------------
/cuda_python/docs/source/release/13.0.1-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 13.0.1 Release notes
5 | ================================
6 |
7 | Released on Aug 18, 2025.
8 |
9 |
10 | Included components
11 | -------------------
12 |
13 | * `cuda.bindings 13.0.1 `_
14 | * `cuda.pathfinder 1.1.0 `_
15 |
16 |
17 | Known issues
18 | ------------
19 |
20 | * Updating from older versions (v12.6.2.post1 and below) via ``pip install -U cuda-python`` might not work. Please do a clean re-installation by uninstalling ``pip uninstall -y cuda-python`` followed by installing ``pip install cuda-python``.
21 |
--------------------------------------------------------------------------------
/toolshed/collect_site_packages_so_files.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
4 | # SPDX-License-Identifier: Apache-2.0
5 |
6 | # Usage:
7 | # cd cuda-python
8 | # ./toolshed/collect_site_packages_so_files.sh
9 | # ./toolshed/make_site_packages_libdirs.py linux site_packages_so.txt
10 |
11 | set -euo pipefail
12 | fresh_venv() {
13 | python3 -m venv "$1"
14 | . "$1/bin/activate"
15 | pip install --upgrade pip
16 | }
17 | cd cuda_pathfinder/
18 | fresh_venv ../TmpCp12Venv
19 | set -x
20 | pip install --only-binary=:all: -e . --group test-cu12
21 | set +x
22 | deactivate
23 | fresh_venv ../TmpCp13Venv
24 | set -x
25 | pip install --only-binary=:all: -e . --group test-cu13
26 | set +x
27 | deactivate
28 | cd ..
29 | set -x
30 | find TmpCp12Venv TmpCp13Venv -name 'lib*.so*' | grep -e nvidia -e nvpl >site_packages_so.txt
31 |
--------------------------------------------------------------------------------
/toolshed/conda_create_for_pathfinder_testing.ps1:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION
2 | # SPDX-License-Identifier: Apache-2.0
3 |
4 | param(
5 | [Parameter(Mandatory = $true)]
6 | [string]$CudaVersion
7 | )
8 |
9 | $ErrorActionPreference = "Stop"
10 |
11 | & "$env:CONDA_EXE" "shell.powershell" "hook" | Out-String | Invoke-Expression
12 |
13 | conda create --yes -n "pathfinder_testing_cu$CudaVersion" python=3.13 "cuda-toolkit=$CudaVersion"
14 | conda activate "pathfinder_testing_cu$CudaVersion"
15 |
16 | $cpkgs = @(
17 | "cusparselt-dev",
18 | "cutensor",
19 | "libcublasmp-dev",
20 | "libcudss-dev",
21 | "libcufftmp-dev",
22 | "libmathdx-dev",
23 | "libnvshmem3",
24 | "libnvshmem-dev",
25 | "libnvpl-fft-dev"
26 | )
27 |
28 | foreach ($cpkg in $cpkgs) {
29 | Write-Host "CONDA INSTALL: $cpkg"
30 | conda install -y -c conda-forge $cpkg
31 | }
32 |
--------------------------------------------------------------------------------
/cuda_core/docs/Makefile:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: Apache-2.0
3 |
4 | # Minimal makefile for Sphinx documentation
5 | #
6 |
7 | # You can set these variables from the command line, and also
8 | # from the environment for the first two.
9 | SPHINXOPTS ?= -j auto
10 | SPHINXBUILD ?= sphinx-build
11 | SOURCEDIR = source
12 | BUILDDIR = build/html/${SPHINX_CUDA_CORE_VER}
13 |
14 | # Put it first so that "make" without argument is like "make help".
15 | help:
16 | @$(SPHINXBUILD) -b help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
17 |
18 | .PHONY: help Makefile
19 |
20 | # Catch-all target: route all unknown targets to Sphinx using the new
21 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
22 | %: Makefile
23 | @$(SPHINXBUILD) -b $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
24 |
--------------------------------------------------------------------------------
/cuda_bindings/cuda/bindings/nvrtc.pxd.in:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2021-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | # This code was automatically generated with version 13.1.0. Do not modify it directly.
5 | cimport cuda.bindings.cynvrtc as cynvrtc
6 |
7 | include "_lib/utils.pxd"
8 |
9 | {{if 'nvrtcProgram' in found_types}}
10 |
11 | cdef class nvrtcProgram:
12 | """ nvrtcProgram is the unit of compilation, and an opaque handle for a program.
13 |
14 | To compile a CUDA program string, an instance of nvrtcProgram must be created first with nvrtcCreateProgram, then compiled with nvrtcCompileProgram.
15 |
16 | Methods
17 | -------
18 | getPtr()
19 | Get memory address of class instance
20 |
21 | """
22 | cdef cynvrtc.nvrtcProgram _pvt_val
23 | cdef cynvrtc.nvrtcProgram* _pvt_ptr
24 | {{endif}}
25 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/contribute.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | Contributing
5 | ============
6 |
7 | Thank you for your interest in contributing to ``cuda-bindings``! Based on the type of contribution, it will fall into two categories:
8 |
9 | 1. You want to report a bug, feature request, or documentation issue
10 | - File an `issue `_ describing what you encountered or what you want to see changed.
11 | - The NVIDIA team will evaluate the issues and triage them, scheduling
12 | them for a release. If you believe the issue needs priority attention
13 | comment on the issue to notify the team.
14 | 2. You want to implement a feature, improvement, or bug fix:
15 | - At this time we do not accept code contributions.
16 |
--------------------------------------------------------------------------------
/cuda_pathfinder/docs/Makefile:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2021-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: Apache-2.0
3 |
4 | # Minimal makefile for Sphinx documentation
5 | #
6 |
7 | # You can set these variables from the command line, and also
8 | # from the environment for the first two.
9 | SPHINXOPTS ?= -j auto
10 | SPHINXBUILD ?= sphinx-build
11 | SOURCEDIR = source
12 | BUILDDIR = build/html/${SPHINX_CUDA_PATHFINDER_VER}
13 |
14 | # Put it first so that "make" without argument is like "make help".
15 | help:
16 | @$(SPHINXBUILD) -b help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
17 |
18 | .PHONY: help Makefile
19 |
20 | # Catch-all target: route all unknown targets to Sphinx using the new
21 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
22 | %: Makefile
23 | @$(SPHINXBUILD) -b $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
24 |
--------------------------------------------------------------------------------
/ci/tools/setup-sanitizer:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
4 | #
5 | # SPDX-License-Identifier: Apache-2.0
6 |
7 | # A utility script to set up the GitHub environment variables for the CI.
8 |
9 | set -euo pipefail
10 |
11 | # Setup comppute sanitizer if requested.
12 | if [[ "${SETUP_SANITIZER}" == 1 ]]; then
13 | COMPUTE_SANITIZER="${CUDA_HOME}/bin/compute-sanitizer"
14 | COMPUTE_SANITIZER_VERSION=$(${COMPUTE_SANITIZER} --version | grep -Eo "[0-9]{4}\.[0-9]\.[0-9]" | sed -e 's/\.//g')
15 | SANITIZER_CMD="${COMPUTE_SANITIZER} --target-processes=all --launch-timeout=0 --tool=memcheck --error-exitcode=1 --report-api-errors=no"
16 | if [[ "$COMPUTE_SANITIZER_VERSION" -ge 202111 ]]; then
17 | SANITIZER_CMD="${SANITIZER_CMD} --padding=32"
18 | fi
19 | else
20 | SANITIZER_CMD=""
21 | fi
22 | echo "SANITIZER_CMD=${SANITIZER_CMD}" >> $GITHUB_ENV
23 |
--------------------------------------------------------------------------------
/toolshed/run_cuda_pathfinder.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: Apache-2.0
4 |
5 | import sys
6 | import traceback
7 |
8 | from cuda import pathfinder
9 |
10 |
11 | def run(args):
12 | if args:
13 | libnames = args
14 | else:
15 | libnames = pathfinder.SUPPORTED_NVIDIA_LIBNAMES
16 |
17 | for libname in libnames:
18 | print(f"{libname=}")
19 | try:
20 | loaded_dl = pathfinder.load_nvidia_dynamic_lib(libname)
21 | except Exception:
22 | print(f"EXCEPTION for {libname=}:")
23 | traceback.print_exc(file=sys.stdout)
24 | else:
25 | print(f" {loaded_dl.abs_path=!r}")
26 | print(f" {loaded_dl.was_already_loaded_from_elsewhere=!r}")
27 | print()
28 |
29 |
30 | if __name__ == "__main__":
31 | run(args=sys.argv[1:])
32 |
--------------------------------------------------------------------------------
/cuda_core/cuda/core/_utils/clear_error_support.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
4 |
5 |
6 | def assert_type(obj, expected_type):
7 | """Ensure obj is of expected_type, else raise AssertionError with a clear message."""
8 | if not isinstance(obj, expected_type):
9 | raise TypeError(f"Expected type {expected_type.__name__}, but got {type(obj).__name__}")
10 |
11 |
12 | def assert_type_str_or_bytes_like(obj):
13 | """Ensure obj is of type str or bytes, else raise AssertionError with a clear message."""
14 | if not isinstance(obj, (str, bytes, bytearray)):
15 | raise TypeError(f"Expected type str or bytes or bytearray, but got {type(obj).__name__}")
16 |
17 |
18 | def raise_code_path_meant_to_be_unreachable():
19 | raise RuntimeError("This code path is meant to be unreachable.")
20 |
--------------------------------------------------------------------------------
/cuda_python/docs/Makefile:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | # Minimal makefile for Sphinx documentation
5 | #
6 |
7 | # You can set these variables from the command line, and also
8 | # from the environment for the first two.
9 | SPHINXOPTS ?= -j auto
10 | SPHINXBUILD ?= sphinx-build
11 | SOURCEDIR = source
12 | BUILDDIR = build/html/${SPHINX_CUDA_PYTHON_VER}
13 |
14 | # Put it first so that "make" without argument is like "make help".
15 | help:
16 | @$(SPHINXBUILD) -b help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
17 |
18 | .PHONY: help Makefile
19 |
20 | # Catch-all target: route all unknown targets to Sphinx using the new
21 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
22 | %: Makefile
23 | @$(SPHINXBUILD) -b $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
24 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/Makefile:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2021-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | # Minimal makefile for Sphinx documentation
5 | #
6 |
7 | # You can set these variables from the command line, and also
8 | # from the environment for the first two.
9 | SPHINXOPTS ?= -j auto
10 | SPHINXBUILD ?= sphinx-build
11 | SOURCEDIR = source
12 | BUILDDIR = build/html/${SPHINX_CUDA_BINDINGS_VER}
13 |
14 | # Put it first so that "make" without argument is like "make help".
15 | help:
16 | @$(SPHINXBUILD) -b help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
17 |
18 | .PHONY: help Makefile
19 |
20 | # Catch-all target: route all unknown targets to Sphinx using the new
21 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
22 | %: Makefile
23 | @$(SPHINXBUILD) -b $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
24 |
--------------------------------------------------------------------------------
/cuda_core/docs/source/release/0.1.0-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | ``cuda.core`` 0.1.0 Release Notes
5 | =================================
6 |
7 | Released on Nov 8, 2024
8 |
9 | Highlights
10 | ----------
11 |
12 | - Initial beta release
13 | - Supports all platforms that CUDA is supported
14 | - Supports all CUDA 11.x/12.x drivers
15 | - Supports all CUDA 11.x/12.x Toolkits
16 | - Pythonic CUDA runtime and other core functionalities
17 |
18 | Limitations
19 | -----------
20 |
21 | - All APIs are currently *experimental* and subject to change without deprecation notice.
22 | Please kindly share your feedback with us so that we can make ``cuda.core`` better!
23 | - Source code release only; ``pip``/``conda`` support is coming in a future release
24 | - Windows TCC mode is `not yet supported `_
25 |
--------------------------------------------------------------------------------
/cuda_core/cuda/core/_memory/_memory_pool.pxd:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: Apache-2.0
4 |
5 | from cuda.bindings cimport cydriver
6 | from cuda.core._memory._buffer cimport MemoryResource
7 | from cuda.core._memory._ipc cimport IPCDataForMR
8 |
9 |
10 | cdef class _MemPool(MemoryResource):
11 | cdef:
12 | int _dev_id
13 | cydriver.CUmemoryPool _handle
14 | bint _mempool_owned
15 | IPCDataForMR _ipc_data
16 | object _attributes
17 | object _peer_accessible_by
18 | object __weakref__
19 |
20 |
21 | cdef class _MemPoolOptions:
22 |
23 | cdef:
24 | bint _ipc_enabled
25 | size_t _max_size
26 | cydriver.CUmemLocationType _location
27 | cydriver.CUmemAllocationType _type
28 | bint _use_current
29 |
--------------------------------------------------------------------------------
/cuda_python/docs/source/release/12.9.1-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 12.9.1 Release notes
5 | ================================
6 |
7 | Released on Aug 6, 2025.
8 |
9 |
10 | Included components
11 | -------------------
12 |
13 | * `cuda.bindings 12.9.1 `_
14 | * `cuda.pathfinder 1.1.0 `_
15 |
16 |
17 | Highlights
18 | ----------
19 |
20 | * Add bindings for cuFile
21 |
22 |
23 | Known issues
24 | ------------
25 |
26 | * Updating from older versions (v12.6.2.post1 and below) via ``pip install -U cuda-python`` might not work. Please do a clean re-installation by uninstalling ``pip uninstall -y cuda-python`` followed by installing ``pip install cuda-python``.
27 |
--------------------------------------------------------------------------------
/cuda_python/docs/source/release/13.0.0-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 13.0.0 Release notes
5 | ================================
6 |
7 | Released on Aug 6, 2025.
8 |
9 |
10 | Included components
11 | -------------------
12 |
13 | * `cuda.bindings 13.0.0 `_
14 | * `cuda.pathfinder 1.1.0 `_
15 |
16 |
17 | Highlights
18 | ----------
19 |
20 | * Add bindings for cuFile
21 |
22 |
23 | Known issues
24 | ------------
25 |
26 | * Updating from older versions (v12.6.2.post1 and below) via ``pip install -U cuda-python`` might not work. Please do a clean re-installation by uninstalling ``pip uninstall -y cuda-python`` followed by installing ``pip install cuda-python``.
27 |
--------------------------------------------------------------------------------
/cuda_core/tests/helpers/__init__.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: Apache-2.0
3 |
4 | import os
5 | import pathlib
6 | import sys
7 |
8 | CUDA_PATH = os.environ.get("CUDA_PATH")
9 | CUDA_INCLUDE_PATH = None
10 | CCCL_INCLUDE_PATHS = None
11 | if CUDA_PATH is not None:
12 | path = os.path.join(CUDA_PATH, "include")
13 | if os.path.isdir(path):
14 | CUDA_INCLUDE_PATH = path
15 | CCCL_INCLUDE_PATHS = (path,)
16 | path = os.path.join(path, "cccl")
17 | if os.path.isdir(path):
18 | CCCL_INCLUDE_PATHS = (path,) + CCCL_INCLUDE_PATHS
19 |
20 |
21 | try:
22 | from cuda_python_test_helpers import * # noqa: F403
23 | except ImportError:
24 | # Import shared platform helpers for tests across repos
25 | sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[3] / "cuda_python_test_helpers"))
26 | from cuda_python_test_helpers import * # noqa: F403
27 |
--------------------------------------------------------------------------------
/cuda_core/cuda/core/_include/utility.hpp:
--------------------------------------------------------------------------------
1 | // SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | //
3 | // SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
4 |
5 | #pragma once
6 |
7 | #include
8 |
9 | // In cuda.bindings 12.8, the private member name was renamed from "_ptr" to "_pvt_ptr".
10 | // We want to have the C++ layer supporting all past 12.x versions, so some tricks are needed.
11 | // Since there's no std::has_member so we use SFINAE to create the same effect.
12 |
13 | template ::_pvt_ptr)>, int> = 0>
15 | inline auto& get_cuda_native_handle(const T& obj) {
16 | return *(obj->_pvt_ptr);
17 | }
18 |
19 | template ::_ptr)>, int> = 0>
21 | inline auto& get_cuda_native_handle(const T& obj) {
22 | return *(obj->_ptr);
23 | }
24 |
--------------------------------------------------------------------------------
/cuda_python/docs/source/release/12.9.3-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 12.9.3 Release notes
5 | ================================
6 |
7 | Released on Oct 9, 2025.
8 |
9 |
10 | Included components
11 | -------------------
12 |
13 | * `cuda.bindings 12.9.3 `_
14 | * `cuda.pathfinder >=1.1.0 `_
15 |
16 |
17 | Known issues
18 | ------------
19 |
20 | * Updating from older versions (v12.6.2.post1 and below) via ``pip install -U cuda-python`` might not work. Please do a clean re-installation by uninstalling ``pip uninstall -y cuda-python`` followed by installing ``pip install cuda-python``.
21 | * The graphics APIs in ``cuda.bindings.runtime`` are inadvertently disabled in 12.9.3. Users needing these APIs should update to 12.9.4.
22 |
--------------------------------------------------------------------------------
/cuda_python/docs/source/release/13.0.2-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 13.0.2 Release notes
5 | ================================
6 |
7 | Released on Oct 9, 2025.
8 |
9 |
10 | Included components
11 | -------------------
12 |
13 | * `cuda.bindings 13.0.2 `_
14 | * `cuda.pathfinder >=1.1.0 `_
15 |
16 |
17 | Known issues
18 | ------------
19 |
20 | * Updating from older versions (v12.6.2.post1 and below) via ``pip install -U cuda-python`` might not work. Please do a clean re-installation by uninstalling ``pip uninstall -y cuda-python`` followed by installing ``pip install cuda-python``.
21 | * The graphics APIs in ``cuda.bindings.runtime`` are inadvertently disabled in 13.0.2. Users needing these APIs should update to 13.0.3.
22 |
--------------------------------------------------------------------------------
/cuda_bindings/cuda/bindings/utils/__init__.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 | from typing import Any, Callable
4 |
5 | from ._ptx_utils import get_minimal_required_cuda_ver_from_ptx_ver, get_ptx_ver
6 |
7 | _handle_getters: dict[type, Callable[[Any], int]] = {}
8 |
9 |
10 | def _add_cuda_native_handle_getter(t: type, getter: Callable[[Any], int]) -> None:
11 | _handle_getters[t] = getter
12 |
13 |
14 | def get_cuda_native_handle(obj: Any) -> int:
15 | """Returns the address of the provided CUDA Python object as a Python int.
16 |
17 | Parameters
18 | ----------
19 | obj : Any
20 | CUDA Python object
21 |
22 | Returns
23 | -------
24 | int : The object address.
25 | """
26 | obj_type = type(obj)
27 | try:
28 | return _handle_getters[obj_type](obj)
29 | except KeyError:
30 | raise TypeError("Unknown type: " + str(obj_type)) from None
31 |
--------------------------------------------------------------------------------
/cuda_pathfinder/tests/conftest.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: Apache-2.0
3 |
4 |
5 | import pytest
6 |
7 |
8 | def pytest_configure(config):
9 | config.custom_info = []
10 |
11 |
12 | def pytest_terminal_summary(terminalreporter, exitstatus, config): # noqa: ARG001
13 | if not config.getoption("verbose"):
14 | return
15 | if hasattr(config.option, "iterations"): # pytest-freethreaded runs all tests at least twice
16 | return
17 | if getattr(config.option, "count", 1) > 1: # pytest-repeat
18 | return
19 |
20 | if config.custom_info:
21 | terminalreporter.write_sep("=", "INFO summary")
22 | for msg in config.custom_info:
23 | terminalreporter.line(f"INFO {msg}")
24 |
25 |
26 | @pytest.fixture
27 | def info_summary_append(request):
28 | def _append(message):
29 | request.config.custom_info.append(f"{request.node.name}: {message}")
30 |
31 | return _append
32 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/release/13.0.3-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | .. module:: cuda.bindings
5 |
6 | ``cuda-bindings`` 13.0.3 Release notes
7 | ======================================
8 |
9 |
10 |
11 | Highlights
12 | ----------
13 |
14 | * Updated the ``cuda.bindings.runtime`` module to statically link against the CUDA Runtime library from CUDA Toolkit 13.0.2.
15 | * The cuFile bindings have been updated to include new bindings available in CTK 13.0.
16 |
17 | Bug fixes
18 | ---------
19 |
20 | * The graphics APIs in ``cuda.bindings.runtime`` were inadvertently disabled in 13.0.2. This has been fixed.
21 |
22 | Known issues
23 | ------------
24 |
25 | * Updating from older versions (v12.6.2.post1 and below) via ``pip install -U cuda-python`` might not work. Please do a clean re-installation by uninstalling ``pip uninstall -y cuda-python`` followed by installing ``pip install cuda-python``.
26 |
--------------------------------------------------------------------------------
/cuda_python/docs/exts/release_toc.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | from pathlib import Path
5 |
6 | from packaging.version import Version
7 | from sphinx.directives.other import TocTree
8 |
9 |
10 | class TocTreeSorted(TocTree):
11 | """A toctree directive that sorts entries by version."""
12 |
13 | def parse_content(self, toctree):
14 | super().parse_content(toctree)
15 |
16 | if not toctree["glob"]:
17 | return
18 |
19 | entries = toctree.get("entries", [])
20 | if not entries:
21 | return
22 |
23 | entries = [(Version(Path(x[1]).name.removesuffix("-notes")), x[1]) for x in entries]
24 | entries.sort(key=lambda x: x[0], reverse=True)
25 | entries = [(str(x[0]), x[1]) for x in entries]
26 | toctree["entries"] = entries
27 |
28 |
29 | def setup(app):
30 | app.add_directive("toctree", TocTreeSorted, override=True)
31 |
--------------------------------------------------------------------------------
/cuda_core/docs/source/release/0.4.1-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | .. currentmodule:: cuda.core.experimental
5 |
6 | ``cuda.core`` 0.4.1 Release Notes
7 | =================================
8 |
9 | Released on Oct 29, 2025
10 |
11 |
12 | Highlights
13 | ----------
14 |
15 | None.
16 |
17 |
18 | Breaking Changes
19 | ----------------
20 |
21 | None.
22 |
23 |
24 | New features
25 | ------------
26 |
27 | None.
28 |
29 |
30 | New examples
31 | ------------
32 |
33 | None.
34 |
35 |
36 | Fixes and enhancements
37 | ----------------------
38 |
39 | - Fixed a segmentation fault when accessing :class:`~utils.StridedMemoryView`'s ``shape`` and ``strides`` members.
40 | - Fixed :attr:`DeviceMemoryResourceOptions.max_size` not accepting values above ``INT_MAX``.
41 | - Fixed rendering of the documentation for :class:`VirtualMemoryResourceOptions`.
42 | - Fixed NumPy version requirement for the code sample ``thread_block_cluster.py``.
43 | - Fixed VMM-related tests.
44 |
--------------------------------------------------------------------------------
/cuda_pathfinder/docs/source/contribute.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | .. _contributor_guide:
5 |
6 | Contributing
7 | ============
8 |
9 | Thank you for your interest in contributing to ``cuda-pathfinder``! Based on the type of contribution, it will fall into two categories:
10 |
11 | 1. You want to report a bug, feature request, or documentation issue
12 | - File an `issue `_ describing what you encountered or what you want to see changed.
13 | - The NVIDIA team will evaluate the issues and triage them, scheduling
14 | them for a release. If you believe the issue needs priority attention
15 | comment on the issue to notify the team.
16 | 2. You want to implement a feature, improvement, or bug fix
17 | - Please ensure that your commits are signed `following GitHub's instruction `_.
18 |
--------------------------------------------------------------------------------
/cuda_core/docs/source/contribute.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | .. _contributor_guide:
5 |
6 | Contributing
7 | ------------
8 |
9 | Thank you for your interest in contributing to ``cuda-core``! Based on the type of contribution, it will fall into two categories:
10 |
11 | 1. You want to report a bug, feature request, or documentation issue
12 |
13 | - File an `issue `_
14 | describing what you encountered or what you want to see changed.
15 | - The NVIDIA team will evaluate the issues and triage them, scheduling
16 | them for a release. If you believe the issue needs priority attention
17 | comment on the issue to notify the team.
18 |
19 | 2. You want to implement a feature, improvement, or bug fix:
20 |
21 | - Please ensure that your commits are signed `following GitHub's instruction `_.
22 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/make.bat:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 |
3 | REM SPDX-FileCopyrightText: Copyright (c) 2021-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
4 | REM SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
5 |
6 | pushd %~dp0
7 |
8 | REM Command file for Sphinx documentation
9 |
10 | if "%SPHINXBUILD%" == "" (
11 | set SPHINXBUILD=sphinx-build
12 | )
13 | set SOURCEDIR=source
14 | set BUILDDIR=build
15 |
16 | if "%1" == "" goto help
17 |
18 | %SPHINXBUILD% >NUL 2>NUL
19 | if errorlevel 9009 (
20 | echo.
21 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
22 | echo.installed, then set the SPHINXBUILD environment variable to point
23 | echo.to the full path of the 'sphinx-build' executable. Alternatively you
24 | echo.may add the Sphinx directory to PATH.
25 | echo.
26 | echo.If you don't have Sphinx installed, grab it from
27 | echo.http://sphinx-doc.org/
28 | exit /b 1
29 | )
30 |
31 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
32 | goto end
33 |
34 | :help
35 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
36 |
37 | :end
38 | popd
39 |
--------------------------------------------------------------------------------
/cuda_python/docs/build_all_docs.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
4 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
5 |
6 | set -ex
7 |
8 | # build cuda-python docs
9 | rm -rf build
10 | ./build_docs.sh $@
11 |
12 | # build cuda-bindings docs
13 | CUDA_BINDINGS_PATH=build/html/cuda-bindings
14 | mkdir -p $CUDA_BINDINGS_PATH
15 | pushd .
16 | cd ../../cuda_bindings/docs
17 | rm -rf build
18 | ./build_docs.sh $@
19 | cp -r build/html/* "$(dirs -l +1)"/$CUDA_BINDINGS_PATH
20 | popd
21 |
22 | # build cuda-core docs
23 | CUDA_CORE_PATH=build/html/cuda-core
24 | mkdir -p $CUDA_CORE_PATH
25 | pushd .
26 | cd ../../cuda_core/docs
27 | rm -rf build
28 | ./build_docs.sh $@
29 | cp -r build/html/* "$(dirs -l +1)"/$CUDA_CORE_PATH
30 | popd
31 |
32 | # build cuda-pathfinder docs
33 | CUDA_PATHFINDER_PATH=build/html/cuda-pathfinder
34 | mkdir -p $CUDA_PATHFINDER_PATH
35 | pushd .
36 | cd ../../cuda_pathfinder/docs
37 | rm -rf build
38 | ./build_docs.sh $@
39 | cp -r build/html/* "$(dirs -l +1)"/$CUDA_PATHFINDER_PATH
40 | popd
41 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/release/13.1.1-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | .. module:: cuda.bindings
5 |
6 | ``cuda-bindings`` 13.1.1 Release notes
7 | ======================================
8 |
9 | Released on Dec 9, 2025
10 |
11 | Highlights
12 | ----------
13 |
14 | * Add missing driver & runtime bindings for functions new in CTK 13.1.0
15 | (`PR #1321 `_)
16 |
17 | Experimental
18 | ------------
19 |
20 | * Experimental NVML bindings were added under ``cuda.bindings._nvml``
21 | (`PR #1284 `_)
22 |
23 | Known issues
24 | ------------
25 |
26 | * Updating from older versions (v12.6.2.post1 and below) via ``pip install -U cuda-python`` might not work. Please do a clean re-installation by uninstalling ``pip uninstall -y cuda-python`` followed by installing ``pip install cuda-python``.
27 | * The graphics APIs in ``cuda.bindings.runtime`` are inadvertently disabled in 13.0.2. Users needing these APIs should update to 13.0.3.
28 |
--------------------------------------------------------------------------------
/cuda_python/setup.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
4 |
5 | import ast
6 |
7 | from packaging.version import Version
8 | from setuptools import setup
9 | from setuptools_scm import get_version
10 |
11 | version = get_version(
12 | root="..",
13 | relative_to=__file__,
14 | # We deliberately do not want to include the version suffixes (a/b/rc) in cuda-python versioning
15 | tag_regex="^(?Pv\\d+\\.\\d+\\.\\d+)",
16 | git_describe_command=["git", "describe", "--dirty", "--tags", "--long", "--match", "v*[0-9]*"],
17 | )
18 |
19 |
20 | base_version = Version(version).base_version
21 |
22 |
23 | if base_version == version:
24 | # Tagged release
25 | matcher = "~="
26 | else:
27 | # Pre-release version
28 | matcher = "=="
29 |
30 |
31 | setup(
32 | version=version,
33 | install_requires=[
34 | f"cuda-bindings{matcher}{version}",
35 | "cuda-pathfinder~=1.1",
36 | ],
37 | extras_require={
38 | "all": [f"cuda-bindings[all]{matcher}{version}"],
39 | },
40 | )
41 |
--------------------------------------------------------------------------------
/cuda_python/docs/README.md:
--------------------------------------------------------------------------------
1 | # Build the documentation
2 |
3 | 1. Ensure the version is included in the [`versions.json`](./versions.json).
4 | 2. Build the docs with `./build_docs.sh`.
5 | 3. The html artifacts should be available under both `./build/html/latest` and `./build/html/`.
6 |
7 | Alternatively, we can build all the docs at once by running [`./build_all_docs.sh`](./build_all_docs.sh).
8 |
9 | When building the docs, some (but not all) of the urls can be rendered/examined locally by setting the environment
10 | variable `CUDA_PYTHON_DOMAIN` as follows:
11 | ```shell
12 | CUDA_PYTHON_DOMAIN="http://localhost:1234/" ./build_all_docs.sh
13 | python -m http.server -d build/html 1234
14 | ```
15 | If the docs are built on a remote machine, you can set up the ssh tunnel in a separate terminal session
16 | via
17 | ```shell
18 | ssh -L 1234:localhost:1234 username@hostname
19 | ```
20 | Then browse the built docs by visiting `http://localhost:1234/` on a local machine.
21 |
22 | To publish the docs with the built version, it is important to note that the html files of older versions
23 | should be kept intact, in order for the version selection (through `versions.json`) to work.
24 |
--------------------------------------------------------------------------------
/cuda_core/tests/cython/test_cython.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2021-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
4 |
5 | import functools
6 | import importlib
7 | import sys
8 |
9 |
10 | def py_func(func):
11 | """
12 | Wraps func in a plain Python function.
13 | """
14 |
15 | @functools.wraps(func)
16 | def wrapped(*args, **kwargs):
17 | return func(*args, **kwargs)
18 |
19 | return wrapped
20 |
21 |
22 | cython_test_modules = [
23 | "test_get_cuda_native_handle",
24 | ]
25 |
26 |
27 | for mod in cython_test_modules:
28 | try:
29 | # For each callable in `mod` with name `test_*`,
30 | # wrap the callable in a plain Python function
31 | # and set the result as an attribute of this module.
32 | mod = importlib.import_module(mod)
33 | for name in dir(mod):
34 | item = getattr(mod, name)
35 | if callable(item) and name.startswith("test_"):
36 | item = py_func(item)
37 | setattr(sys.modules[__name__], name, item)
38 | except ImportError:
39 | raise
40 |
--------------------------------------------------------------------------------
/cuda_bindings/tests/cython/test_cython.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | import functools
5 | import importlib
6 | import sys
7 |
8 |
9 | def py_func(func):
10 | """
11 | Wraps func in a plain Python function.
12 | """
13 |
14 | @functools.wraps(func)
15 | def wrapped(*args, **kwargs):
16 | return func(*args, **kwargs)
17 |
18 | return wrapped
19 |
20 |
21 | cython_test_modules = ["test_ccuda", "test_ccudart", "test_interoperability_cython"]
22 |
23 |
24 | for mod in cython_test_modules:
25 | try:
26 | # For each callable in `mod` with name `test_*`,
27 | # wrap the callable in a plain Python function
28 | # and set the result as an attribute of this module.
29 | mod = importlib.import_module(mod)
30 | for name in dir(mod):
31 | item = getattr(mod, name)
32 | if callable(item) and name.startswith("test_"):
33 | item = py_func(item)
34 | setattr(sys.modules[__name__], name, item)
35 | except ImportError:
36 | raise
37 |
--------------------------------------------------------------------------------
/cuda_core/cuda/core/_context.pyx:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: Apache-2.0
4 |
5 | from dataclasses import dataclass
6 |
7 | from cuda.core._utils.cuda_utils import driver
8 |
9 |
10 | @dataclass
11 | class ContextOptions:
12 | pass # TODO
13 |
14 |
15 | cdef class Context:
16 |
17 | cdef:
18 | readonly object _handle
19 | int _device_id
20 |
21 | def __init__(self, *args, **kwargs):
22 | raise RuntimeError("Context objects cannot be instantiated directly. Please use Device or Stream APIs.")
23 |
24 | @classmethod
25 | def _from_ctx(cls, handle: driver.CUcontext, int device_id):
26 | cdef Context ctx = Context.__new__(Context)
27 | ctx._handle = handle
28 | ctx._device_id = device_id
29 | return ctx
30 |
31 | def __eq__(self, other):
32 | if not isinstance(other, Context):
33 | return NotImplemented
34 | cdef Context _other = other
35 | return int(self._handle) == int(_other._handle)
36 |
37 | def __hash__(self) -> int:
38 | return hash(int(self._handle))
39 |
--------------------------------------------------------------------------------
/cuda_python/docs/source/release/12.8.0-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 12.8.0 Release notes
5 | ================================
6 |
7 | Released on January 24, 2025.
8 |
9 | Included components
10 | -------------------
11 |
12 | * `cuda.bindings 12.8.0 `_
13 |
14 | Highlights
15 | ----------
16 |
17 | - Support Python 3.13
18 | - Add bindings for nvJitLink (requires nvJitLink from CUDA 12.3 or above)
19 | - Add optional dependencies on CUDA NVRTC and nvJitLink wheels
20 | - Enable discovery and loading of shared libraries from CUDA wheels
21 | - ``cuda-python`` is now a meta package, currently depending only on ``cuda-bindings`` (`see RFC `_)
22 |
23 | Known issues
24 | ------------
25 |
26 | - Updating from older versions (v12.6.2.post1 and below) via ``pip install -U cuda-python`` might not work. Please do a clean re-installation by uninstalling ``pip uninstall -y cuda-python`` followed by installing ``pip install cuda-python``.
27 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/release/11.7.0-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 11.7.0 Release notes
5 | ================================
6 |
7 | Released on May 11, 2022
8 |
9 | Highlights
10 | ----------
11 | - Support CUDA Toolkit 11.7
12 |
13 | Limitations
14 | -----------
15 |
16 | CUDA Functions Not Supported in this Release
17 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18 |
19 | - Symbol APIs
20 | - cudaGraphExecMemcpyNodeSetParamsFromSymbol
21 | - cudaGraphExecMemcpyNodeSetParamsToSymbol
22 | - cudaGraphAddMemcpyNodeToSymbol
23 | - cudaGraphAddMemcpyNodeFromSymbol
24 | - cudaGraphMemcpyNodeSetParamsToSymbol
25 | - cudaGraphMemcpyNodeSetParamsFromSymbol
26 | - cudaMemcpyToSymbol
27 | - cudaMemcpyFromSymbol
28 | - cudaMemcpyToSymbolAsync
29 | - cudaMemcpyFromSymbolAsync
30 | - cudaGetSymbolAddress
31 | - cudaGetSymbolSize
32 | - cudaGetFuncBySymbol
33 | - Launch Options
34 | - cudaLaunchKernel
35 | - cudaLaunchCooperativeKernel
36 | - cudaLaunchCooperativeKernelMultiDevice
37 | - cudaSetValidDevices
38 | - cudaVDPAUSetVDPAUDevice
39 |
--------------------------------------------------------------------------------
/cuda_pathfinder/docs/nv-versions.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "version": "latest",
4 | "url": "https://nvidia.github.io/cuda-python/cuda-pathfinder/latest/"
5 | },
6 | {
7 | "version": "1.3.3",
8 | "url": "https://nvidia.github.io/cuda-python/cuda-pathfinder/1.3.3/"
9 | },
10 | {
11 | "version": "1.3.2",
12 | "url": "https://nvidia.github.io/cuda-python/cuda-pathfinder/1.3.2/"
13 | },
14 | {
15 | "version": "1.3.1",
16 | "url": "https://nvidia.github.io/cuda-python/cuda-pathfinder/1.3.1/"
17 | },
18 | {
19 | "version": "1.3.0",
20 | "url": "https://nvidia.github.io/cuda-python/cuda-pathfinder/1.3.0/"
21 | },
22 | {
23 | "version": "1.2.3",
24 | "url": "https://nvidia.github.io/cuda-python/cuda-pathfinder/1.2.3/"
25 | },
26 | {
27 | "version": "1.2.2",
28 | "url": "https://nvidia.github.io/cuda-python/cuda-pathfinder/1.2.2/"
29 | },
30 | {
31 | "version": "1.2.1",
32 | "url": "https://nvidia.github.io/cuda-python/cuda-pathfinder/1.2.1/"
33 | },
34 | {
35 | "version": "1.2.0",
36 | "url": "https://nvidia.github.io/cuda-python/cuda-pathfinder/1.2.0/"
37 | }
38 | ]
39 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/release/12.2.1-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 12.2.1 Release notes
5 | ================================
6 |
7 | Released on January 8, 2024
8 |
9 | Highlights
10 | ----------
11 | - Compatibility with Cython 3
12 |
13 | Limitations
14 | -----------
15 |
16 | CUDA Functions Not Supported in this Release
17 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18 |
19 | - Symbol APIs
20 | - cudaGraphExecMemcpyNodeSetParamsFromSymbol
21 | - cudaGraphExecMemcpyNodeSetParamsToSymbol
22 | - cudaGraphAddMemcpyNodeToSymbol
23 | - cudaGraphAddMemcpyNodeFromSymbol
24 | - cudaGraphMemcpyNodeSetParamsToSymbol
25 | - cudaGraphMemcpyNodeSetParamsFromSymbol
26 | - cudaMemcpyToSymbol
27 | - cudaMemcpyFromSymbol
28 | - cudaMemcpyToSymbolAsync
29 | - cudaMemcpyFromSymbolAsync
30 | - cudaGetSymbolAddress
31 | - cudaGetSymbolSize
32 | - cudaGetFuncBySymbol
33 | - Launch Options
34 | - cudaLaunchKernel
35 | - cudaLaunchCooperativeKernel
36 | - cudaLaunchCooperativeKernelMultiDevice
37 | - cudaSetValidDevices
38 | - cudaVDPAUSetVDPAUDevice
39 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/release/11.8.2-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 11.8.2 Release notes
5 | ================================
6 |
7 | Released on May 18, 2023
8 |
9 | Highlights
10 | ----------
11 | - Open libcuda.so.1 instead of libcuda.so
12 |
13 | Limitations
14 | -----------
15 |
16 | CUDA Functions Not Supported in this Release
17 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18 |
19 | - Symbol APIs
20 | - cudaGraphExecMemcpyNodeSetParamsFromSymbol
21 | - cudaGraphExecMemcpyNodeSetParamsToSymbol
22 | - cudaGraphAddMemcpyNodeToSymbol
23 | - cudaGraphAddMemcpyNodeFromSymbol
24 | - cudaGraphMemcpyNodeSetParamsToSymbol
25 | - cudaGraphMemcpyNodeSetParamsFromSymbol
26 | - cudaMemcpyToSymbol
27 | - cudaMemcpyFromSymbol
28 | - cudaMemcpyToSymbolAsync
29 | - cudaMemcpyFromSymbolAsync
30 | - cudaGetSymbolAddress
31 | - cudaGetSymbolSize
32 | - cudaGetFuncBySymbol
33 | - Launch Options
34 | - cudaLaunchKernel
35 | - cudaLaunchCooperativeKernel
36 | - cudaLaunchCooperativeKernelMultiDevice
37 | - cudaSetValidDevices
38 | - cudaVDPAUSetVDPAUDevice
39 |
--------------------------------------------------------------------------------
/cuda_bindings/DESCRIPTION.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | ****************************************
5 | cuda-bindings: Low-level CUDA interfaces
6 | ****************************************
7 |
8 | .. image:: https://img.shields.io/badge/NVIDIA-black?logo=nvidia
9 | :target: https://www.nvidia.com/
10 | :alt: NVIDIA
11 |
12 | `cuda.bindings `_ is a standard set of low-level interfaces, providing full coverage of and 1:1 access to the CUDA host APIs from Python. Checkout the `Overview `_ for the workflow and performance results.
13 |
14 | * `Repository `_
15 | * `Documentation `_
16 | * `Examples `_
17 | * `Issue tracker `_
18 |
19 | For the installation instruction, please refer to the `Installation `_ page.
20 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/release/11.6.1-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 11.6.1 Release notes
5 | ================================
6 |
7 | Released on March 18, 2022
8 |
9 | Highlights
10 | ----------
11 | - Fix string decomposition for WSL library load
12 |
13 | Limitations
14 | -----------
15 |
16 | CUDA Functions Not Supported in this Release
17 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18 |
19 | - Symbol APIs
20 | - cudaGraphExecMemcpyNodeSetParamsFromSymbol
21 | - cudaGraphExecMemcpyNodeSetParamsToSymbol
22 | - cudaGraphAddMemcpyNodeToSymbol
23 | - cudaGraphAddMemcpyNodeFromSymbol
24 | - cudaGraphMemcpyNodeSetParamsToSymbol
25 | - cudaGraphMemcpyNodeSetParamsFromSymbol
26 | - cudaMemcpyToSymbol
27 | - cudaMemcpyFromSymbol
28 | - cudaMemcpyToSymbolAsync
29 | - cudaMemcpyFromSymbolAsync
30 | - cudaGetSymbolAddress
31 | - cudaGetSymbolSize
32 | - cudaGetFuncBySymbol
33 | - Launch Options
34 | - cudaLaunchKernel
35 | - cudaLaunchCooperativeKernel
36 | - cudaLaunchCooperativeKernelMultiDevice
37 | - cudaSetValidDevices
38 | - cudaVDPAUSetVDPAUDevice
39 |
--------------------------------------------------------------------------------
/cuda_pathfinder/cuda/pathfinder/_utils/find_site_packages_dll.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: Apache-2.0
3 |
4 | import collections
5 | import functools
6 | import importlib.metadata
7 |
8 |
9 | @functools.cache
10 | def find_all_dll_files_via_metadata() -> dict[str, tuple[str, ...]]:
11 | results: collections.defaultdict[str, list[str]] = collections.defaultdict(list)
12 |
13 | # sort dists for deterministic output
14 |
15 | for dist in sorted(
16 | importlib.metadata.distributions(),
17 | # `get` exists before 3.12, even though the hints only exist for Python >=3.12
18 | key=lambda d: (d.metadata.get("Name", ""), d.version), # type: ignore[attr-defined]
19 | ):
20 | files = dist.files
21 | if not files:
22 | continue
23 | for relpath in sorted(files, key=lambda p: str(p)): # deterministic
24 | relname = relpath.name.lower()
25 | if not relname.endswith(".dll"):
26 | continue
27 | abs_path = str(dist.locate_file(relpath))
28 | results[relname].append(abs_path)
29 |
30 | # plain dicts; sort inner list for stability
31 | return {k: tuple(sorted(v)) for k, v in results.items()}
32 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/release/12.9.5-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | .. module:: cuda.bindings
5 |
6 | ``cuda-bindings`` 12.9.5 Release notes
7 | ======================================
8 |
9 | Highlights
10 | ----------
11 |
12 | * Added ``__cuda_stream__`` protocol support to ``driver.CUStream`` class, enabling better interoperability with libraries that expect this protocol.
13 | * Python 3.9 support was dropped (end of life).
14 |
15 | Bug fixes
16 | ---------
17 |
18 | * Fixed ``cuStreamBeginCaptureToGraph`` to allow the ``dependencyData`` argument to be optional, matching the underlying CUDA API behavior.
19 |
20 | Experimental
21 | ------------
22 |
23 | * Experimental NVML bindings were added under ``cuda.bindings._nvml``.
24 |
25 | Known issues
26 | ------------
27 |
28 | * Updating from older versions (v12.6.2.post1 and below) via ``pip install -U cuda-python`` might not work. Please do a clean re-installation by uninstalling ``pip uninstall -y cuda-python`` followed by installing ``pip install cuda-python``.
29 | * The graphics APIs in ``cuda.bindings.runtime`` are inadvertently disabled in 12.9.3. Users needing these APIs should update to 12.9.4 or higher.
30 |
--------------------------------------------------------------------------------
/cuda_bindings/tests/nvml/test_compute_mode.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 |
5 | import sys
6 |
7 | import pytest
8 | from cuda.bindings import _nvml as nvml
9 |
10 | COMPUTE_MODES = [
11 | nvml.ComputeMode.COMPUTEMODE_DEFAULT,
12 | nvml.ComputeMode.COMPUTEMODE_PROHIBITED,
13 | nvml.ComputeMode.COMPUTEMODE_EXCLUSIVE_PROCESS,
14 | ]
15 |
16 |
17 | @pytest.mark.skipif(sys.platform == "win32", reason="Test not supported on Windows")
18 | def test_compute_mode_supported_nonroot(all_devices):
19 | skip_reasons = set()
20 | for device in all_devices:
21 | try:
22 | original_compute_mode = nvml.device_get_compute_mode(device)
23 | except nvml.NotSupportedError:
24 | skip_reasons.add(f"nvmlDeviceGetComputeMode not supported for device {device}")
25 | continue
26 |
27 | for cm in COMPUTE_MODES:
28 | with pytest.raises(nvml.NoPermissionError):
29 | nvml.device_set_compute_mode(device, cm)
30 | assert original_compute_mode == nvml.device_get_compute_mode(device), "Compute mode shouldn't have changed"
31 |
32 | if skip_reasons:
33 | pytest.skip(" ; ".join(skip_reasons))
34 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/release/11.8.3-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 11.8.3 Release notes
5 | ================================
6 |
7 | Released on October 23, 2023
8 |
9 | Highlights
10 | ----------
11 | - Compatability with Cython 3
12 | - New API cudart.getLocalRuntimeVersion()
13 | - Modernize build config
14 |
15 | Limitations
16 | -----------
17 |
18 | CUDA Functions Not Supported in this Release
19 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20 |
21 | - Symbol APIs
22 | - cudaGraphExecMemcpyNodeSetParamsFromSymbol
23 | - cudaGraphExecMemcpyNodeSetParamsToSymbol
24 | - cudaGraphAddMemcpyNodeToSymbol
25 | - cudaGraphAddMemcpyNodeFromSymbol
26 | - cudaGraphMemcpyNodeSetParamsToSymbol
27 | - cudaGraphMemcpyNodeSetParamsFromSymbol
28 | - cudaMemcpyToSymbol
29 | - cudaMemcpyFromSymbol
30 | - cudaMemcpyToSymbolAsync
31 | - cudaMemcpyFromSymbolAsync
32 | - cudaGetSymbolAddress
33 | - cudaGetSymbolSize
34 | - cudaGetFuncBySymbol
35 | - Launch Options
36 | - cudaLaunchKernel
37 | - cudaLaunchCooperativeKernel
38 | - cudaLaunchCooperativeKernelMultiDevice
39 | - cudaSetValidDevices
40 | - cudaVDPAUSetVDPAUDevice
41 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/release/12.4.0-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 12.4.0 Release notes
5 | ================================
6 |
7 | Released on March 5, 2024
8 |
9 | Highlights
10 | ----------
11 | - Rebase to CUDA Toolkit 12.4
12 | - Add PyPI/Conda support for Python 12
13 |
14 | Limitations
15 | -----------
16 |
17 | CUDA Functions Not Supported in this Release
18 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19 |
20 | - Symbol APIs
21 | - cudaGraphExecMemcpyNodeSetParamsFromSymbol
22 | - cudaGraphExecMemcpyNodeSetParamsToSymbol
23 | - cudaGraphAddMemcpyNodeToSymbol
24 | - cudaGraphAddMemcpyNodeFromSymbol
25 | - cudaGraphMemcpyNodeSetParamsToSymbol
26 | - cudaGraphMemcpyNodeSetParamsFromSymbol
27 | - cudaMemcpyToSymbol
28 | - cudaMemcpyFromSymbol
29 | - cudaMemcpyToSymbolAsync
30 | - cudaMemcpyFromSymbolAsync
31 | - cudaGetSymbolAddress
32 | - cudaGetSymbolSize
33 | - cudaGetFuncBySymbol
34 | - Launch Options
35 | - cudaLaunchKernel
36 | - cudaLaunchCooperativeKernel
37 | - cudaLaunchCooperativeKernelMultiDevice
38 | - cudaSetValidDevices
39 | - cudaVDPAUSetVDPAUDevice
40 | - cudaFuncGetName
41 | - cudaFuncGetParamInfo
42 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/release/11.8.1-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 11.8.1 Release notes
5 | ================================
6 |
7 | Released on November 4, 2022
8 |
9 | Highlights
10 | ----------
11 | - Resolves `issue #27 `_
12 | - Update install instructions to use latest CTK
13 |
14 | Limitations
15 | -----------
16 |
17 | CUDA Functions Not Supported in this Release
18 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19 |
20 | - Symbol APIs
21 | - cudaGraphExecMemcpyNodeSetParamsFromSymbol
22 | - cudaGraphExecMemcpyNodeSetParamsToSymbol
23 | - cudaGraphAddMemcpyNodeToSymbol
24 | - cudaGraphAddMemcpyNodeFromSymbol
25 | - cudaGraphMemcpyNodeSetParamsToSymbol
26 | - cudaGraphMemcpyNodeSetParamsFromSymbol
27 | - cudaMemcpyToSymbol
28 | - cudaMemcpyFromSymbol
29 | - cudaMemcpyToSymbolAsync
30 | - cudaMemcpyFromSymbolAsync
31 | - cudaGetSymbolAddress
32 | - cudaGetSymbolSize
33 | - cudaGetFuncBySymbol
34 | - Launch Options
35 | - cudaLaunchKernel
36 | - cudaLaunchCooperativeKernel
37 | - cudaLaunchCooperativeKernelMultiDevice
38 | - cudaSetValidDevices
39 | - cudaVDPAUSetVDPAUDevice
40 |
--------------------------------------------------------------------------------
/.github/workflows/codeql.yml:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: Apache-2.0
4 |
5 | name: "Static Analysis: CodeQL Scan"
6 |
7 | on:
8 | push:
9 | branches:
10 | - "pull-request/[0-9]+"
11 | - "main"
12 | concurrency:
13 | group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
14 | cancel-in-progress: true
15 |
16 | jobs:
17 | analyze:
18 | name: Analyze (${{ matrix.language }})
19 | runs-on: ubuntu-latest
20 | permissions:
21 | security-events: write
22 |
23 | strategy:
24 | fail-fast: false
25 | matrix:
26 | include:
27 | - language: python
28 | build-mode: none
29 | steps:
30 | - name: Checkout repository
31 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
32 |
33 | - name: Initialize CodeQL
34 | uses: github/codeql-action/init@f47c8e6a9bd05ef3ee422fc8d8663be7fe4bdc61 # v3.31.8
35 | with:
36 | languages: ${{ matrix.language }}
37 | build-mode: ${{ matrix.build-mode }}
38 | queries: security-extended
39 |
40 | - name: Perform CodeQL Analysis
41 | uses: github/codeql-action/analyze@f47c8e6a9bd05ef3ee422fc8d8663be7fe4bdc61 # v3.31.8
42 | with:
43 | category: "/language:${{matrix.language}}"
44 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/release/12.0.0-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 12.0.0 Release notes
5 | ================================
6 |
7 | Released on December 8, 2022
8 |
9 | Highlights
10 | ----------
11 | - Rebase to CUDA Toolkit 12.0
12 | - Fix example from `MR28 `_
13 | - Apply `MR35 `_
14 |
15 | Limitations
16 | -----------
17 |
18 | CUDA Functions Not Supported in this Release
19 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20 |
21 | - Symbol APIs
22 | - cudaGraphExecMemcpyNodeSetParamsFromSymbol
23 | - cudaGraphExecMemcpyNodeSetParamsToSymbol
24 | - cudaGraphAddMemcpyNodeToSymbol
25 | - cudaGraphAddMemcpyNodeFromSymbol
26 | - cudaGraphMemcpyNodeSetParamsToSymbol
27 | - cudaGraphMemcpyNodeSetParamsFromSymbol
28 | - cudaMemcpyToSymbol
29 | - cudaMemcpyFromSymbol
30 | - cudaMemcpyToSymbolAsync
31 | - cudaMemcpyFromSymbolAsync
32 | - cudaGetSymbolAddress
33 | - cudaGetSymbolSize
34 | - cudaGetFuncBySymbol
35 | - Launch Options
36 | - cudaLaunchKernel
37 | - cudaLaunchCooperativeKernel
38 | - cudaLaunchCooperativeKernelMultiDevice
39 | - cudaSetValidDevices
40 | - cudaVDPAUSetVDPAUDevice
41 |
--------------------------------------------------------------------------------
/cuda_bindings/tests/utils/check_cyclical_import.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | """
5 | Tests whether importing a specific module leads to cyclical imports.
6 |
7 | See https://github.com/NVIDIA/cuda-python/issues/789 for more info.
8 | """
9 |
10 | import argparse
11 |
12 | orig_import = __builtins__.__import__
13 |
14 | import_stack = []
15 |
16 |
17 | def import_hook(name, globals=None, locals=None, fromlist=(), *args, **kwargs):
18 | """Approximate a custom import system that does not allow import cycles."""
19 |
20 | stack_entry = (tuple(fromlist) if fromlist is not None else None, name)
21 | if stack_entry in import_stack and name.startswith("cuda.bindings."):
22 | raise ImportError(f"Import cycle detected: {stack_entry}, stack: {import_stack}")
23 | import_stack.append(stack_entry)
24 | try:
25 | res = orig_import(name, globals, locals, fromlist, *args, **kwargs)
26 | finally:
27 | import_stack.pop()
28 | return res
29 |
30 |
31 | __builtins__.__import__ = import_hook
32 |
33 |
34 | if __name__ == "__main__":
35 | parser = argparse.ArgumentParser()
36 | parser.add_argument(
37 | "module",
38 | type=str,
39 | )
40 | args = parser.parse_args()
41 |
42 | __import__(args.module)
43 |
--------------------------------------------------------------------------------
/greptile.json:
--------------------------------------------------------------------------------
1 | {
2 | "labels": ["ai-review"],
3 | "comment": "",
4 | "fixWithAI": true,
5 | "strictness": 3,
6 | "commentTypes": [
7 | "logic"
8 | ],
9 | "instructions": "",
10 | "excludeAuthors": [
11 | "dependabot[bot]",
12 | "renovate[bot]"
13 | ],
14 | "ignorePatterns": "greptile.json\n",
15 | "summarySection": {
16 | "included": true,
17 | "collapsible": true,
18 | "defaultOpen": false
19 | },
20 | "includeBranches": [
21 | "main"
22 | ],
23 | "triggerOnUpdates": false,
24 | "issuesTableSection": {
25 | "included": false,
26 | "collapsible": false,
27 | "defaultOpen": false
28 | },
29 | "statusCommentsEnabled": false,
30 | "confidenceScoreSection": {
31 | "included": false,
32 | "collapsible": false,
33 | "defaultOpen": false
34 | },
35 | "sequenceDiagramSection": {
36 | "included": false,
37 | "collapsible": false,
38 | "defaultOpen": false
39 | },
40 | "shouldUpdateDescription": false,
41 | "customContext": {
42 | "other": [
43 | {
44 | "scope": [],
45 | "content": ""
46 | }
47 | ],
48 | "rules": [
49 | {
50 | "scope": [],
51 | "rule": ""
52 | }
53 | ],
54 | "files": [
55 | {
56 | "scope": [],
57 | "path": "",
58 | "description": ""
59 | }
60 | ]
61 | },
62 | "skipReviews": "AUTOMATIC"
63 | }
64 |
--------------------------------------------------------------------------------
/cuda_core/docs/source/api_private.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | :orphan:
5 |
6 | .. This page is to generate documentation for private classes exposed to users,
7 | i.e., users cannot instantiate them but may use their properties or methods
8 | via returned values from public APIs. These classes must be referred in
9 | public APIs returning their instances.
10 |
11 | .. currentmodule:: cuda.core
12 |
13 | CUDA runtime
14 | ------------
15 |
16 | .. autosummary::
17 | :toctree: generated/
18 |
19 | _memory._buffer.DevicePointerT
20 | _memory._virtual_memory_resource.VirtualMemoryAllocationTypeT
21 | _memory._virtual_memory_resource.VirtualMemoryLocationTypeT
22 | _memory._virtual_memory_resource.VirtualMemoryGranularityT
23 | _memory._virtual_memory_resource.VirtualMemoryAccessTypeT
24 | _memory._virtual_memory_resource.VirtualMemoryHandleTypeT
25 | _device.DeviceProperties
26 | _memory._ipc.IPCAllocationHandle
27 | _memory._ipc.IPCBufferDescriptor
28 | _module.KernelAttributes
29 | _module.KernelOccupancy
30 | _module.ParamInfo
31 | _module.MaxPotentialBlockSizeOccupancyResult
32 |
33 |
34 | CUDA protocols
35 | --------------
36 |
37 | .. autosummary::
38 | :toctree: generated/
39 | :template: protocol.rst
40 |
41 | _stream.IsStreamT
42 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/release/12.5.0-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 12.5.0 Release notes
5 | ================================
6 |
7 | Released on May 21, 2024
8 |
9 | Highlights
10 | ----------
11 | - Rebase to CUDA Toolkit 12.5
12 | - Resolve `Issue #58 `_: Interop between CUdeviceptr and Runtime
13 |
14 | Limitations
15 | -----------
16 |
17 | CUDA Functions Not Supported in this Release
18 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19 |
20 | - Symbol APIs
21 | - cudaGraphExecMemcpyNodeSetParamsFromSymbol
22 | - cudaGraphExecMemcpyNodeSetParamsToSymbol
23 | - cudaGraphAddMemcpyNodeToSymbol
24 | - cudaGraphAddMemcpyNodeFromSymbol
25 | - cudaGraphMemcpyNodeSetParamsToSymbol
26 | - cudaGraphMemcpyNodeSetParamsFromSymbol
27 | - cudaMemcpyToSymbol
28 | - cudaMemcpyFromSymbol
29 | - cudaMemcpyToSymbolAsync
30 | - cudaMemcpyFromSymbolAsync
31 | - cudaGetSymbolAddress
32 | - cudaGetSymbolSize
33 | - cudaGetFuncBySymbol
34 | - Launch Options
35 | - cudaLaunchKernel
36 | - cudaLaunchCooperativeKernel
37 | - cudaLaunchCooperativeKernelMultiDevice
38 | - cudaSetValidDevices
39 | - cudaVDPAUSetVDPAUDevice
40 | - cudaFuncGetName
41 | - cudaFuncGetParamInfo
42 |
--------------------------------------------------------------------------------
/.github/workflows/backport.yml:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: Apache-2.0
4 |
5 | name: "CI: Backport the merged PR"
6 |
7 | on:
8 | pull_request_target:
9 | types: [closed, labeled]
10 | branches:
11 | - main
12 |
13 | permissions:
14 | contents: write # so it can comment
15 | pull-requests: write # so it can create pull requests
16 |
17 | jobs:
18 | backport:
19 | name: Backport pull request
20 | if: ${{ github.repository_owner == 'nvidia' &&
21 | github.event.pull_request.merged == true &&
22 | contains( github.event.pull_request.labels.*.name, 'to-be-backported')
23 | }}
24 | runs-on: ubuntu-latest
25 | steps:
26 | - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
27 |
28 | - name: Load branch name
29 | id: get-branch
30 | run: |
31 | OLD_BRANCH=$(yq '.backport_branch' ci/versions.yml)
32 | echo "OLD_BRANCH=${OLD_BRANCH}" >> $GITHUB_ENV
33 |
34 | - name: Create backport pull requests
35 | uses: korthout/backport-action@c656f5d5851037b2b38fb5db2691a03fa229e3b2 # v4.0.1
36 | with:
37 | copy_assignees: true
38 | copy_labels_pattern: true
39 | copy_requested_reviewers: true
40 | target_branches: ${{ env.OLD_BRANCH }}
41 |
--------------------------------------------------------------------------------
/cuda_pathfinder/pixi.toml:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: Apache-2.0
4 |
5 | [workspace]
6 | channels = ["conda-forge"]
7 | platforms = ["linux-64", "linux-aarch64", "win-64"]
8 | preview = ["pixi-build"]
9 |
10 | [dependencies]
11 | cuda-pathfinder = { path = "." }
12 |
13 | [feature.test.dependencies]
14 | pytest = ">=6.2.4"
15 |
16 | [feature.cu12.system-requirements]
17 | cuda = "12"
18 |
19 | [feature.cu12.dependencies]
20 | cuda-version = ">=12.0,<13"
21 |
22 | [feature.cu13.system-requirements]
23 | cuda = "13"
24 |
25 | [feature.cu13.dependencies]
26 | cuda-version = ">=13.1,<14"
27 |
28 | [environments]
29 | default = { features = ["test"], solve-group = "default" }
30 | cu12 = { features = ["cu12", "test"], solve-group = "cu12" }
31 | cu13 = { features = ["cu13", "test"], solve-group = "cu13" }
32 |
33 | # TODO: check if these can be extracted from pyproject.toml
34 | [package]
35 | name = "cuda-pathfinder"
36 | version = "1.3.4a0"
37 |
38 | [package.build]
39 | backend = { name = "pixi-build-python", version = "*" }
40 |
41 | [package.host-dependencies]
42 | python = "*"
43 | setuptools = ">=64"
44 |
45 | [package.run-dependencies]
46 | python = ">=3.10"
47 |
48 | [target.linux.tasks.test]
49 | cmd = ["pytest", "$PIXI_PROJECT_ROOT"]
50 |
51 | [target.win-64.tasks.test]
52 | cmd = ["pytest", "%PIXI_PROJECT_ROOT%"]
53 |
--------------------------------------------------------------------------------
/toolshed/collect_site_packages_dll_files.ps1:
--------------------------------------------------------------------------------
1 | # collect_site_packages_dll_files.ps1
2 |
3 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
4 | # SPDX-License-Identifier: Apache-2.0
5 |
6 | # Usage:
7 | # cd cuda-python
8 | # powershell -File toolshed\collect_site_packages_dll_files.ps1
9 | # python .\toolshed\make_site_packages_libdirs.py windows site_packages_dll.txt
10 |
11 | $ErrorActionPreference = 'Stop'
12 |
13 | function Fresh-Venv {
14 | param(
15 | [Parameter(Mandatory=$true)]
16 | [string] $Path
17 | )
18 | & python3 -m venv $Path
19 | . (Join-Path $Path 'Scripts\Activate.ps1')
20 | python -m pip install --upgrade pip
21 | }
22 |
23 | Set-Location -Path 'cuda_pathfinder'
24 |
25 | Fresh-Venv -Path '..\TmpCp12Venv'
26 | pip install --only-binary=:all: -e . --group test-cu12
27 | deactivate
28 |
29 | Fresh-Venv -Path '..\TmpCp13Venv'
30 | pip install --only-binary=:all: -e . --group test-cu13
31 | deactivate
32 |
33 | Set-Location -Path '..'
34 |
35 | $venvs = @('TmpCp12Venv', 'TmpCp13Venv')
36 |
37 | $matches =
38 | Get-ChildItem -Path $venvs -Recurse -File -Include '*.dll' |
39 | Where-Object { $_.FullName -match '(?i)(nvidia|nvpl)' } |
40 | Select-Object -ExpandProperty FullName |
41 | Sort-Object -Unique
42 |
43 | $outFile = 'site_packages_dll.txt'
44 | $matches | Set-Content -Path $outFile -Encoding utf8
45 |
--------------------------------------------------------------------------------
/cuda_pathfinder/docs/source/release/1.3.0-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | .. py:currentmodule:: cuda.pathfinder
5 |
6 | ``cuda-pathfinder`` 1.3.0 Release notes
7 | =======================================
8 |
9 | Released on Sep 29, 2025
10 |
11 | Important update to the ``load_nvidia_dynamic_lib`` documentation
12 | -----------------------------------------------------------------
13 |
14 | The documentation for :func:`cuda.pathfinder.load_nvidia_dynamic_lib` now calls out
15 | an important behavior:
16 |
17 | * **Do not close** the OS handle returned (``LoadedDL._handle_uint``). Avoid
18 | ``dlclose`` (Linux) and ``FreeLibrary`` (Windows).
19 |
20 | * **Reason:** the function's result is cached (``functools.cache``) and shared across
21 | the process. Closing the handle can unload the module while other code still holds
22 | a reference, which may cause crashes or latent errors.
23 |
24 | This note is documentation‑only; there is no API change in 1.3.0. See issue #1011
25 | for background and discussion:
26 | https://github.com/NVIDIA/cuda-python/issues/1011
27 |
28 | Highlights
29 | ----------
30 |
31 | * Add a Conda-specific search into ``load_nvidia_dynamic_lib()``.
32 | This makes the search more intuitive and predictable.
33 | (`PR #1003 `_)
34 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/release/11.8.6-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | ``cuda-bindings`` 11.8.6 Release notes
5 | ====================================
6 |
7 | Released on January 24, 2025.
8 |
9 | Highlights
10 | ----------
11 |
12 | - Support Python 3.13
13 | - Add an optional dependency on the CUDA NVRTC wheel
14 | - Enable discovery and loading of shared libraries from CUDA wheels
15 | - ``cuda-python`` is now a meta package, currently depending only on ``cuda-bindings`` (`see RFC `_)
16 |
17 | Wheels support for optional dependencies
18 | ----------------------------------------
19 |
20 | Optional dependencies are added for packages:
21 |
22 | - nvidia-cuda-nvrtc-cu12
23 |
24 | Installing these dependencies with ``cuda-python`` can be done using:
25 |
26 | .. code-block:: shell
27 |
28 | pip install cuda-python[all]
29 |
30 | Same applies to ``cuda-bindings``.
31 |
32 | Discovery and loading of shared library dependencies from wheels
33 | ----------------------------------------------------------------
34 |
35 | Shared library search paths for wheel builds are now extended to check site-packages. This allows ``cuda-python``/``cuda-bindings`` to seamlessly use the aforementioned CUDA Toolkit wheels installed in the user's Python environment.
36 |
--------------------------------------------------------------------------------
/cuda_core/cuda/core/_include/layout.hpp:
--------------------------------------------------------------------------------
1 | // SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES.
2 | // All rights reserved.
3 | //
4 | // SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
5 |
6 | #ifndef CUDA_CORE_LAYOUT_HPP
7 | #define CUDA_CORE_LAYOUT_HPP
8 |
9 | #include
10 | #include
11 | #include
12 | #include
13 |
14 | #define STRIDED_LAYOUT_MAX_NDIM 64
15 | #define AXES_MASK_ALL 0xFFFFFFFFFFFFFFFEULL
16 |
17 | inline int64_t _c_abs(int64_t x) { return std::abs(x); }
18 |
19 | template
20 | void _swap(T &a, T &b) noexcept { std::swap(a, b); }
21 |
22 | inline void _order_from_strides(std::vector &indices, const int64_t *shape,
23 | const int64_t *strides, int ndim)
24 | {
25 | indices.resize(ndim);
26 | std::iota(indices.begin(), indices.end(), 0);
27 | if (!strides)
28 | {
29 | return;
30 | }
31 | std::sort(indices.begin(), indices.end(), [&strides, &shape](int i, int j)
32 | {
33 | int64_t stride_i = _c_abs(strides[i]);
34 | int64_t stride_j = _c_abs(strides[j]);
35 | if (stride_i != stride_j) {
36 | return stride_i > stride_j;
37 | }
38 | int64_t shape_i = shape[i];
39 | int64_t shape_j = shape[j];
40 | if (shape_i != shape_j) {
41 | return shape_i > shape_j;
42 | }
43 | return i < j; });
44 | }
45 |
46 | #endif // CUDA_CORE_LAYOUT_HPP
47 |
--------------------------------------------------------------------------------
/cuda_core/docs/nv-versions.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "version": "latest",
4 | "url": "https://nvidia.github.io/cuda-python/cuda-core/latest/"
5 | },
6 | {
7 | "version": "0.5.0",
8 | "url": "https://nvidia.github.io/cuda-python/cuda-core/0.5.0/"
9 | },
10 | {
11 | "version": "0.4.2",
12 | "url": "https://nvidia.github.io/cuda-python/cuda-core/0.4.2/"
13 | },
14 | {
15 | "version": "0.4.1",
16 | "url": "https://nvidia.github.io/cuda-python/cuda-core/0.4.1/"
17 | },
18 | {
19 | "version": "0.4.0",
20 | "url": "https://nvidia.github.io/cuda-python/cuda-core/0.4.0/"
21 | },
22 | {
23 | "version": "0.3.2",
24 | "url": "https://nvidia.github.io/cuda-python/cuda-core/0.3.2/"
25 | },
26 | {
27 | "version": "0.3.1",
28 | "url": "https://nvidia.github.io/cuda-python/cuda-core/0.3.1/"
29 | },
30 | {
31 | "version": "0.3.0",
32 | "url": "https://nvidia.github.io/cuda-python/cuda-core/0.3.0/"
33 | },
34 | {
35 | "version": "0.2.0",
36 | "url": "https://nvidia.github.io/cuda-python/cuda-core/0.2.0/"
37 | },
38 | {
39 | "version": "0.1.1",
40 | "url": "https://nvidia.github.io/cuda-python/cuda-core/0.1.1/"
41 | },
42 | {
43 | "version": "0.1.0",
44 | "url": "https://nvidia.github.io/cuda-python/cuda-core/0.1.0/"
45 | }
46 | ]
47 |
--------------------------------------------------------------------------------
/cuda_bindings/tests/nvml/util.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 |
5 | import functools
6 | import platform
7 | from pathlib import Path
8 |
9 | from cuda.bindings import _nvml as nvml
10 |
11 | current_os = platform.system()
12 | if current_os == "VMkernel":
13 | current_os = "Linux" # Treat VMkernel as Linux
14 |
15 |
16 | def is_windows(os=current_os):
17 | return os == "Windows"
18 |
19 |
20 | def is_linux(os=current_os):
21 | return os == "Linux"
22 |
23 |
24 | @functools.cache
25 | def is_wsl(os=current_os):
26 | return os == "Linux" and "microsoft" in Path("/proc/version").read_text().lower()
27 |
28 |
29 | def is_vgpu(device):
30 | """
31 | Returns True if device in vGPU virtualization mode
32 | """
33 | return nvml.device_get_virtualization_mode(device) == nvml.GpuVirtualizationMode.VGPU
34 |
35 |
36 | def supports_ecc(device):
37 | try:
38 | (cur_ecc, pend_ecc) = nvml.device_get_ecc_mode(device)
39 | return cur_ecc != nvml.EnableState.FEATURE_DISABLED
40 | except nvml.NotSupportedError as e:
41 | return False
42 |
43 |
44 | def supports_nvlink(device):
45 | fields = nvml.FieldValue(1)
46 | fields[0].field_id = nvml.FI.DEV_NVLINK_GET_STATE
47 | return nvml.device_get_field_values(device, fields)[0].nvml_return == nvml.Return.SUCCESS
48 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/environment_variables.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | Environment Variables
5 | =====================
6 |
7 | Runtime Environment Variables
8 | -----------------------------
9 |
10 | - ``CUDA_PYTHON_CUDA_PER_THREAD_DEFAULT_STREAM`` : When set to 1, the default stream is the per-thread default stream. When set to 0, the default stream is the legacy default stream. This defaults to 0, for the legacy default stream. See `Stream Synchronization Behavior `_ for an explanation of the legacy and per-thread default streams.
11 |
12 |
13 | Build-Time Environment Variables
14 | --------------------------------
15 |
16 | - ``CUDA_HOME`` or ``CUDA_PATH``: Specifies the location of the CUDA Toolkit.
17 |
18 | - ``CUDA_PYTHON_PARSER_CACHING`` : bool, toggles the caching of parsed header files during the cuda-bindings build process. If caching is enabled (``CUDA_PYTHON_PARSER_CACHING`` is True), the cache path is set to ./cache_, where is derived from the cuda toolkit libraries used to build cuda-bindings.
19 |
20 | - ``CUDA_PYTHON_PARALLEL_LEVEL`` (previously ``PARALLEL_LEVEL``) : int, sets the number of threads used in the compilation of extension modules. Not setting it or setting it to 0 would disable parallel builds.
21 |
--------------------------------------------------------------------------------
/pixi.toml:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: Apache-2.0
4 |
5 | [workspace]
6 | channels = ["conda-forge"]
7 | platforms = ["linux-64", "linux-aarch64", "win-64"]
8 |
9 | [feature.cu12.dependencies]
10 | [feature.cu13.dependencies]
11 |
12 | [environments]
13 | cu12 = { features = ["cu12"] }
14 | cu13 = { features = ["cu13"] }
15 |
16 | [activation.env]
17 | PIXI_ENVIRONMENT_NAME = "${PIXI_ENVIRONMENT_NAME/default/cu13}"
18 |
19 | # Test Tasks
20 | # Runs tests across all sub-packages: pathfinder → bindings → core (dependency order)
21 | # Each sub-package has its own pixi.toml; the -e environment propagates via PIXI_ENVIRONMENT_NAME
22 | #
23 | # Usage: pixi run test | pixi run -e cu12 test | pixi run -e cu13 test
24 | [target.linux.tasks.test-pathfinder]
25 | cmd = [
26 | "pixi",
27 | "run",
28 | "--manifest-path",
29 | "$PIXI_PROJECT_ROOT/cuda_pathfinder",
30 | "test",
31 | ]
32 |
33 | [target.linux.tasks.test-bindings]
34 | cmd = [
35 | "pixi",
36 | "run",
37 | "--manifest-path",
38 | "$PIXI_PROJECT_ROOT/cuda_bindings",
39 | "test",
40 | ]
41 |
42 | [target.linux.tasks.test-core]
43 | cmd = ["pixi", "run", "--manifest-path", "$PIXI_PROJECT_ROOT/cuda_core", "test"]
44 |
45 | [target.linux.tasks.test]
46 | depends-on = [
47 | { task = "test-pathfinder" },
48 | { task = "test-bindings" },
49 | { task = "test-core" },
50 | ]
51 |
--------------------------------------------------------------------------------
/cuda_bindings/benchmarks/test_numba.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2021-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | import numpy as np
5 | import pytest
6 |
7 | try:
8 | from numba import cuda
9 |
10 | skip_tests = False
11 | except ImportError:
12 | skip_tests = True
13 |
14 |
15 | def launch_empty(kernel, stream):
16 | kernel[1, 1, stream]()
17 |
18 |
19 | def launch(kernel, stream, arg):
20 | kernel[1, 1, stream](arg)
21 |
22 |
23 | # Measure launch latency with no parmaeters
24 | @pytest.mark.skipif(skip_tests, reason="Numba is not installed")
25 | @pytest.mark.benchmark(group="numba", min_rounds=1000)
26 | def test_launch_latency_empty_kernel(benchmark):
27 | stream = cuda.stream()
28 |
29 | @cuda.jit
30 | def empty_kernel():
31 | return
32 |
33 | benchmark(launch_empty, empty_kernel, stream)
34 |
35 | cuda.synchronize()
36 |
37 |
38 | # Measure launch latency with a single parameter
39 | @pytest.mark.skipif(skip_tests, reason="Numba is not installed")
40 | @pytest.mark.benchmark(group="numba", min_rounds=1000)
41 | def test_launch_latency_small_kernel(benchmark):
42 | stream = cuda.stream()
43 |
44 | arg = cuda.device_array(1, dtype=np.float32, stream=stream)
45 |
46 | @cuda.jit
47 | def small_kernel(array):
48 | array[0] = 0.0
49 |
50 | benchmark(launch, small_kernel, stream, arg)
51 |
52 | cuda.synchronize()
53 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/release/12.2.0-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 12.2.0 Release notes
5 | ================================
6 |
7 | Released on June 28, 2023
8 |
9 | Highlights
10 | ----------
11 | - Rebase to CUDA Toolkit 12.2
12 | - Resolve `Issue #44 `_: nogil must be at the end of the function signature line
13 | - Resolve `Issue #45 `_: Error with pyparsing when no CUDA is found
14 |
15 | Limitations
16 | -----------
17 |
18 | CUDA Functions Not Supported in this Release
19 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20 |
21 | - Symbol APIs
22 | - cudaGraphExecMemcpyNodeSetParamsFromSymbol
23 | - cudaGraphExecMemcpyNodeSetParamsToSymbol
24 | - cudaGraphAddMemcpyNodeToSymbol
25 | - cudaGraphAddMemcpyNodeFromSymbol
26 | - cudaGraphMemcpyNodeSetParamsToSymbol
27 | - cudaGraphMemcpyNodeSetParamsFromSymbol
28 | - cudaMemcpyToSymbol
29 | - cudaMemcpyFromSymbol
30 | - cudaMemcpyToSymbolAsync
31 | - cudaMemcpyFromSymbolAsync
32 | - cudaGetSymbolAddress
33 | - cudaGetSymbolSize
34 | - cudaGetFuncBySymbol
35 | - Launch Options
36 | - cudaLaunchKernel
37 | - cudaLaunchCooperativeKernel
38 | - cudaLaunchCooperativeKernelMultiDevice
39 | - cudaSetValidDevices
40 | - cudaVDPAUSetVDPAUDevice
41 |
--------------------------------------------------------------------------------
/cuda_core/docs/source/release/0.3.1-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | .. currentmodule:: cuda.core.experimental
5 |
6 | ``cuda.core`` 0.3.1 Release Notes
7 | =================================
8 |
9 | Released on July 2, 2025
10 |
11 |
12 | Highlights
13 | ----------
14 |
15 | - Add a :doc:`Getting Started <../getting-started>` page.
16 | - :class:`Stream` and :class:`Event` creation and some operations are made faster.
17 |
18 |
19 | Breaking Changes
20 | ----------------
21 |
22 | None.
23 |
24 |
25 | New features
26 | ------------
27 |
28 | None.
29 |
30 |
31 | New examples
32 | ------------
33 |
34 | - Add a `CUDA graph `_ example.
35 | - Add a `memory resource `_ example.
36 |
37 |
38 | Fixes and enhancements
39 | ----------------------
40 |
41 | - Fix installing optional dependencies ``cuda-core[cu11]`` and ``cuda-core[cu12]`` not including all needed packages.
42 | - :class:`Buffer` allocated from a :class:`LegacyPinnedMemoryResource` can be passed as a kernel launch argument.
43 | - Fix the handling for insufficient driver versions when querying :attr:`Kernel.num_arguments` and :attr:`Kernel.arguments_info`.
44 | - Fix WSL detection in the test suite.
45 | - Improve compatibility with newer driver versions.
46 |
--------------------------------------------------------------------------------
/cuda_core/DESCRIPTION.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | *******************************************************
5 | cuda-core: Pythonic access to CUDA core functionalities
6 | *******************************************************
7 |
8 | .. image:: https://img.shields.io/badge/NVIDIA-black?logo=nvidia
9 | :target: https://www.nvidia.com/
10 | :alt: NVIDIA
11 |
12 | `cuda.core `_ bridges Python's productivity with CUDA's performance through intuitive and pythonic APIs. The mission is to provide users full access to all of the core CUDA features in Python, such as runtime control, compiler and linker.
13 |
14 | * `Repository `_
15 | * `Documentation `_
16 | * `Examples `_
17 | * `Issue tracker `_
18 |
19 | ``cuda.core`` is currently under active development. Feedback and suggestions are welcome!
20 |
21 |
22 | Installation
23 | ============
24 |
25 | .. code-block:: bash
26 |
27 | pip install cuda-core[cu12]
28 |
29 | Please refer to the `installation instructions `_ for different ways of installing ``cuda.core``, including building from source.
30 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/nv-versions.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "version": "latest",
4 | "url": "https://nvidia.github.io/cuda-python/cuda-bindings/latest/"
5 | },
6 | {
7 | "version": "13.1.1",
8 | "url": "https://nvidia.github.io/cuda-python/cuda-bindings/13.1.1/"
9 | },
10 | {
11 | "version": "13.1.0",
12 | "url": "https://nvidia.github.io/cuda-python/cuda-bindings/13.1.0/"
13 | },
14 | {
15 | "version": "13.0.3",
16 | "url": "https://nvidia.github.io/cuda-python/cuda-bindings/13.0.3/"
17 | },
18 | {
19 | "version": "13.0.2",
20 | "url": "https://nvidia.github.io/cuda-python/cuda-bindings/13.0.2/"
21 | },
22 | {
23 | "version": "13.0.1",
24 | "url": "https://nvidia.github.io/cuda-python/cuda-bindings/13.0.1/"
25 | },
26 | {
27 | "version": "13.0.0",
28 | "url": "https://nvidia.github.io/cuda-python/cuda-bindings/13.0.0/"
29 | },
30 | {
31 | "version": "12.9.0",
32 | "url": "https://nvidia.github.io/cuda-python/cuda-bindings/12.9.0/"
33 | },
34 | {
35 | "version": "12.8.0",
36 | "url": "https://nvidia.github.io/cuda-python/cuda-bindings/12.8.0/"
37 | },
38 | {
39 | "version": "12.6.2",
40 | "url": "https://nvidia.github.io/cuda-python/cuda-bindings/12.6.2/"
41 | },
42 | {
43 | "version": "12.6.1",
44 | "url": "https://nvidia.github.io/cuda-python/cuda-bindings/12.6.1/"
45 | }
46 | ]
47 |
--------------------------------------------------------------------------------
/cuda_bindings/tests/nvml/test_nvlink.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 |
5 | from cuda.bindings import _nvml as nvml
6 |
7 |
8 | def test_nvlink_get_link_count(all_devices):
9 | """
10 | Checks that the link count of the device is same.
11 | """
12 | for device in all_devices:
13 | fields = nvml.FieldValue(1)
14 | fields[0].field_id = nvml.FI.DEV_NVLINK_LINK_COUNT
15 | value = nvml.device_get_field_values(device, fields)[0]
16 | assert value.nvml_return == nvml.Return.SUCCESS or value.nvml_return == nvml.Return.ERROR_NOT_SUPPORTED, (
17 | f"Unexpected return {value.nvml_return} for link count field query"
18 | )
19 |
20 | # Use the alternative argument to device_get_field_values
21 | value = nvml.device_get_field_values(device, [nvml.FI.DEV_NVLINK_LINK_COUNT])[0]
22 | assert value.nvml_return == nvml.Return.SUCCESS or value.nvml_return == nvml.Return.ERROR_NOT_SUPPORTED, (
23 | f"Unexpected return {value.nvml_return} for link count field query"
24 | )
25 |
26 | # The feature_nvlink_supported detection is not robust, so we
27 | # can't be more specific about how many links we should find.
28 | if value.nvml_return == nvml.Return.SUCCESS:
29 | assert value.value.ui_val <= nvml.NVLINK_MAX_LINKS, f"Unexpected link count {value.value.ui_val}"
30 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/release/11.8.5-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 11.8.5 Release notes
5 | ================================
6 |
7 | Released on November 5, 2024. Post 1 rebuild released on November 12, 2024.
8 |
9 | Highlights
10 | ----------
11 | - Resolve `Issue #215 `_: module ``cuda.ccudart`` has no attribute ``__pyx_capi__``
12 | - Resolve `Issue #226 `_: top-level Cython source files not packaged
13 |
14 | Limitations
15 | -----------
16 |
17 | CUDA Functions Not Supported in this Release
18 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19 |
20 | - Symbol APIs
21 | - cudaGraphExecMemcpyNodeSetParamsFromSymbol
22 | - cudaGraphExecMemcpyNodeSetParamsToSymbol
23 | - cudaGraphAddMemcpyNodeToSymbol
24 | - cudaGraphAddMemcpyNodeFromSymbol
25 | - cudaGraphMemcpyNodeSetParamsToSymbol
26 | - cudaGraphMemcpyNodeSetParamsFromSymbol
27 | - cudaMemcpyToSymbol
28 | - cudaMemcpyFromSymbol
29 | - cudaMemcpyToSymbolAsync
30 | - cudaMemcpyFromSymbolAsync
31 | - cudaGetSymbolAddress
32 | - cudaGetSymbolSize
33 | - cudaGetFuncBySymbol
34 | - Launch Options
35 | - cudaLaunchKernel
36 | - cudaLaunchCooperativeKernel
37 | - cudaLaunchCooperativeKernelMultiDevice
38 | - cudaSetValidDevices
39 | - cudaVDPAUSetVDPAUDevice
40 |
--------------------------------------------------------------------------------
/cuda_bindings/tests/test_nvrtc.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2021-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | import pytest
5 | from cuda.bindings import nvrtc
6 |
7 |
8 | def ASSERT_DRV(err):
9 | if isinstance(err, nvrtc.nvrtcResult):
10 | if err != nvrtc.nvrtcResult.NVRTC_SUCCESS:
11 | raise RuntimeError(f"Nvrtc Error: {err}")
12 | else:
13 | raise RuntimeError(f"Unknown error type: {err}")
14 |
15 |
16 | def nvrtcVersionLessThan(major, minor):
17 | err, major_version, minor_version = nvrtc.nvrtcVersion()
18 | ASSERT_DRV(err)
19 | return major_version < major or (major == major_version and minor_version < minor)
20 |
21 |
22 | @pytest.mark.skipif(nvrtcVersionLessThan(11, 3), reason="When nvrtcGetSupportedArchs was introduced")
23 | def test_nvrtcGetSupportedArchs():
24 | err, supportedArchs = nvrtc.nvrtcGetSupportedArchs()
25 | ASSERT_DRV(err)
26 | assert len(supportedArchs) != 0
27 |
28 |
29 | @pytest.mark.skipif(nvrtcVersionLessThan(12, 1), reason="Preempt Segmentation Fault (see #499)")
30 | def test_nvrtcGetLoweredName_failure():
31 | err, name = nvrtc.nvrtcGetLoweredName(None, b"I'm an elevated name!")
32 | assert err == nvrtc.nvrtcResult.NVRTC_ERROR_INVALID_PROGRAM
33 | assert name is None
34 | err, name = nvrtc.nvrtcGetLoweredName(0, b"I'm another elevated name!")
35 | assert err == nvrtc.nvrtcResult.NVRTC_ERROR_INVALID_PROGRAM
36 | assert name is None
37 |
--------------------------------------------------------------------------------
/cuda_bindings/tests/cython/test_ccuda.pyx:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2021-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | # distutils: language=c++
5 | from libc.string cimport (
6 | memset,
7 | memcmp
8 | )
9 | cimport cuda.bindings.cydriver as ccuda
10 |
11 | def test_ccuda_memcpy():
12 | # Init CUDA
13 | err = ccuda.cuInit(0)
14 | assert(err == 0)
15 |
16 | # Get device
17 | cdef ccuda.CUdevice device
18 | err = ccuda.cuDeviceGet(&device, 0)
19 | assert(err == 0)
20 |
21 | # Construct context
22 | cdef ccuda.CUcontext ctx
23 | err = ccuda.cuCtxCreate(&ctx, NULL, 0, device)
24 | assert(err == 0)
25 |
26 | # Allocate dev memory
27 | cdef ccuda.CUdeviceptr dptr
28 | err = ccuda.cuMemAlloc(&dptr, 1024)
29 | assert(err == 0)
30 |
31 | # Set h1 and h2 memory to be different
32 | cdef char[1024] hptr1
33 | memset(hptr1, 1, 1024)
34 | cdef char[1024] hptr2
35 | memset(hptr2, 2, 1024)
36 | assert(memcmp(hptr1, hptr2, 1024) != 0)
37 |
38 | # h1 to D
39 | err = ccuda.cuMemcpyHtoD(dptr, hptr1, 1024)
40 | assert(err == 0)
41 |
42 | # D to h2
43 | err = ccuda.cuMemcpyDtoH(hptr2, dptr, 1024)
44 | assert(err == 0)
45 |
46 | # Validate h1 == h2
47 | assert(memcmp(hptr1, hptr2, 1024) == 0)
48 |
49 | # Cleanup
50 | err = ccuda.cuMemFree(dptr)
51 | assert(err == 0)
52 | err = ccuda.cuCtxDestroy(ctx)
53 | assert(err == 0)
54 |
--------------------------------------------------------------------------------
/conftest.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: Apache-2.0
3 |
4 | import os
5 |
6 | import pytest
7 |
8 |
9 | def pytest_collection_modifyitems(config, items):
10 | cuda_home = os.environ.get("CUDA_HOME")
11 | for item in items:
12 | nodeid = item.nodeid.replace("\\", "/")
13 |
14 | # Package markers by path
15 | if nodeid.startswith("cuda_pathfinder/tests/") or "/cuda_pathfinder/tests/" in nodeid:
16 | item.add_marker(pytest.mark.pathfinder)
17 | if nodeid.startswith("cuda_bindings/tests/") or "/cuda_bindings/tests/" in nodeid:
18 | item.add_marker(pytest.mark.bindings)
19 | if nodeid.startswith("cuda_core/tests/") or "/cuda_core/tests/" in nodeid:
20 | item.add_marker(pytest.mark.core)
21 |
22 | # Smoke tests
23 | if nodeid.startswith("tests/integration/") or "/tests/integration/" in nodeid:
24 | item.add_marker(pytest.mark.smoke)
25 |
26 | # Cython tests (any tests/cython subtree)
27 | if (
28 | "/tests/cython/" in nodeid
29 | or nodeid.endswith("/tests/cython")
30 | or ("/cython/" in nodeid and "/tests/" in nodeid)
31 | ):
32 | item.add_marker(pytest.mark.cython)
33 |
34 | # Gate core cython tests on CUDA_HOME
35 | if "core" in item.keywords and not cuda_home:
36 | item.add_marker(pytest.mark.skip(reason="CUDA_HOME not set; skipping core cython tests"))
37 |
--------------------------------------------------------------------------------
/cuda_pathfinder/cuda/pathfinder/__init__.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: Apache-2.0
3 |
4 | """cuda.pathfinder public APIs"""
5 |
6 | from cuda.pathfinder._version import __version__ # noqa: F401
7 |
8 | from cuda.pathfinder._dynamic_libs.load_dl_common import DynamicLibNotFoundError as DynamicLibNotFoundError
9 | from cuda.pathfinder._dynamic_libs.load_dl_common import LoadedDL as LoadedDL
10 | from cuda.pathfinder._dynamic_libs.load_nvidia_dynamic_lib import load_nvidia_dynamic_lib as load_nvidia_dynamic_lib
11 | from cuda.pathfinder._dynamic_libs.supported_nvidia_libs import (
12 | SUPPORTED_LIBNAMES as SUPPORTED_NVIDIA_LIBNAMES, # noqa: F401
13 | )
14 | from cuda.pathfinder._headers.find_nvidia_headers import find_nvidia_header_directory as find_nvidia_header_directory
15 | from cuda.pathfinder._headers.supported_nvidia_headers import SUPPORTED_HEADERS_CTK as _SUPPORTED_HEADERS_CTK
16 |
17 | # Indirections to help Sphinx find the docstrings.
18 | #: Mapping from short CUDA Toolkit (CTK) library names to their canonical
19 | #: header basenames (used to validate a discovered include directory).
20 | #: Example: ``"cublas" → "cublas.h"``. The key set is platform-aware
21 | #: (e.g., ``"cufile"`` may be Linux-only).
22 | SUPPORTED_HEADERS_CTK = _SUPPORTED_HEADERS_CTK
23 |
24 | # Backward compatibility: _find_nvidia_header_directory was added in release 1.2.2.
25 | # It will be removed in release 1.2.4.
26 | _find_nvidia_header_directory = find_nvidia_header_directory
27 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/release/12.1.0-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 12.1.0 Release notes
5 | ================================
6 |
7 | Released on February 28, 2023
8 |
9 | Highlights
10 | ----------
11 | - Rebase to CUDA Toolkit 12.1
12 | - Resolve `Issue #41 `_: Add support for Python 3.11
13 | - Resolve `Issue #42 `_: Dropping Python 3.7
14 | - Resolve `Issue #43 `_: Trim Conda package dependencies
15 |
16 | Limitations
17 | -----------
18 |
19 | CUDA Functions Not Supported in this Release
20 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
21 |
22 | - Symbol APIs
23 | - cudaGraphExecMemcpyNodeSetParamsFromSymbol
24 | - cudaGraphExecMemcpyNodeSetParamsToSymbol
25 | - cudaGraphAddMemcpyNodeToSymbol
26 | - cudaGraphAddMemcpyNodeFromSymbol
27 | - cudaGraphMemcpyNodeSetParamsToSymbol
28 | - cudaGraphMemcpyNodeSetParamsFromSymbol
29 | - cudaMemcpyToSymbol
30 | - cudaMemcpyFromSymbol
31 | - cudaMemcpyToSymbolAsync
32 | - cudaMemcpyFromSymbolAsync
33 | - cudaGetSymbolAddress
34 | - cudaGetSymbolSize
35 | - cudaGetFuncBySymbol
36 | - Launch Options
37 | - cudaLaunchKernel
38 | - cudaLaunchCooperativeKernel
39 | - cudaLaunchCooperativeKernelMultiDevice
40 | - cudaSetValidDevices
41 | - cudaVDPAUSetVDPAUDevice
42 |
--------------------------------------------------------------------------------
/.github/workflows/guess_latest.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3 | #
4 | # SPDX-License-Identifier: Apache-2.0
5 |
6 | # URL to search
7 | URL="https://developer.download.nvidia.com/compute/cuda/redist/"
8 |
9 | # Ensure exactly one argument is provided
10 | if [ "$#" -ne 1 ]; then
11 | echo "Usage: $0 "
12 | exit 1
13 | fi
14 |
15 | # Accept major version as the first argument
16 | MAJOR_VERSION="$1"
17 |
18 | # Fetch the directory listing and extract the latest version number
19 | get_latest_version() {
20 | # Get the HTML content of the page
21 | local html_content=$(wget -q -O - "$URL")
22 |
23 | # Extract links matching the pattern redistrib_?.?.?.json
24 | local files=$(echo "$html_content" | grep -oP "redistrib_${MAJOR_VERSION}\.[0-9]+\.[0-9]+\.json" | cut -d'"' -f2)
25 |
26 | # If files were found, extract the version numbers and find the latest
27 | if [ -n "$files" ]; then
28 | # Extract just the version numbers using regex
29 | local versions=$(echo "$files" | grep -oP "redistrib_\K${MAJOR_VERSION}\.[0-9]+\.[0-9]+(?=\.json)")
30 |
31 | # Sort the versions and get the latest
32 | local latest_version=$(echo "$versions" | sort -V | tail -n 1)
33 | echo "$latest_version"
34 | else
35 | echo "No files matching the pattern were found."
36 | return 1
37 | fi
38 | }
39 |
40 | # Call the function and store the result
41 | latest_version=$(get_latest_version)
42 | echo $latest_version
43 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/release/12.6.2-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 12.6.2 Release notes
5 | ================================
6 |
7 | Released on November 5, 2024. Post 1 rebuild released on November 12, 2024.
8 |
9 | Highlights
10 | ----------
11 | - Resolve `Issue #215 `_: module ``cuda.ccudart`` has no attribute ``__pyx_capi__``
12 | - Resolve `Issue #226 `_: top-level Cython source files not packaged
13 |
14 | Limitations
15 | -----------
16 |
17 | CUDA Functions Not Supported in this Release
18 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19 |
20 | - Symbol APIs
21 | - cudaGraphExecMemcpyNodeSetParamsFromSymbol
22 | - cudaGraphExecMemcpyNodeSetParamsToSymbol
23 | - cudaGraphAddMemcpyNodeToSymbol
24 | - cudaGraphAddMemcpyNodeFromSymbol
25 | - cudaGraphMemcpyNodeSetParamsToSymbol
26 | - cudaGraphMemcpyNodeSetParamsFromSymbol
27 | - cudaMemcpyToSymbol
28 | - cudaMemcpyFromSymbol
29 | - cudaMemcpyToSymbolAsync
30 | - cudaMemcpyFromSymbolAsync
31 | - cudaGetSymbolAddress
32 | - cudaGetSymbolSize
33 | - cudaGetFuncBySymbol
34 | - Launch Options
35 | - cudaLaunchKernel
36 | - cudaLaunchCooperativeKernel
37 | - cudaLaunchCooperativeKernelMultiDevice
38 | - cudaSetValidDevices
39 | - cudaVDPAUSetVDPAUDevice
40 | - cudaFuncGetName
41 | - cudaFuncGetParamInfo
42 |
--------------------------------------------------------------------------------
/cuda_pathfinder/docs/source/release/1.2.0-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | .. py:currentmodule:: cuda.pathfinder
5 |
6 | ``cuda-pathfinder`` 1.2.0 Release notes
7 | ========================================
8 |
9 | Released on Aug 29, 2025
10 |
11 |
12 | Highlights
13 | ----------
14 |
15 | * Reverse tabulated names to achieve new → old search order (`PR #921 `_)
16 |
17 | - ``SUPPORTED_LINUX_SONAMES`` and ``SUPPORTED_WINDOWS_DLLS`` lists of DSOs are searched from new → old
18 |
19 | * Support non-CTK Nvidia libraries (`PR #864 `_)
20 |
21 | - Adds support for non-CTK Nvidia libraries: ``mathdx``, ``cufftMp``, ``nvshmem_host``, ``nvpl_fftw``
22 |
23 | * ``RTLD_DI_LINKMAP``-based new implementation of ``abs_path_for_dynamic_library()`` (`PR #834 `_)
24 |
25 | - Eliminates ``supported_nvidia_libs.EXPECTED_LIB_SYMBOLS`` entirely, providing major simplification
26 | - Step towards resolving library discovery issues
27 | - Includes minor fixes and cleanup
28 |
29 | * Make ``add_dll_directory()`` and ``load_dependencies()`` side-effects more deterministic (`PR #855 `_)
30 |
31 | - Improves stability in general and supports nvmath specifically
32 | - Proactive change to improve library loading consistency
33 | - Drops boilerplate docstrings for private functions
34 |
--------------------------------------------------------------------------------
/.github/actions/install_unix_deps/action.yml:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: Apache-2.0
4 |
5 | name: Install dependencies on Ubuntu
6 |
7 | description: Install needed dependencies, regardless if using GitHub- or self- hosted runners, container, sudo or not.
8 |
9 | inputs:
10 | dependencies:
11 | required: true
12 | type: string
13 | dependent_exes:
14 | required: true
15 | type: string
16 |
17 | runs:
18 | using: composite
19 | steps:
20 | - name: Install dependencies
21 | shell: bash --noprofile --norc -xeuo pipefail {0}
22 | run: |
23 | dependencies=(${{ inputs.dependencies }})
24 | dependent_exes=(${{ inputs.dependent_exes }})
25 |
26 | not_found=0
27 | for dep in ${dependent_exes[@]}; do
28 | if ! (command -v $dep 2>&1 >/dev/null); then
29 | not_found=1
30 | break
31 | fi
32 | done
33 | if [[ $not_found == 0 ]]; then
34 | echo "All dependencies are found. Do nothing."
35 | exit 0
36 | fi
37 | if ! (command -v sudo 2>&1 >/dev/null); then
38 | if [[ $EUID == 0 ]]; then
39 | alias SUDO=""
40 | else
41 | echo "The following oprations require root access."
42 | exit 1
43 | fi
44 | else
45 | alias SUDO="sudo"
46 | fi
47 | shopt -s expand_aliases
48 | SUDO apt update
49 | SUDO apt install -y ${dependencies[@]}
50 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/release/12.9.0-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | ``cuda-bindings`` 12.9.0 Release notes
5 | ======================================
6 |
7 | Released on May 5, 2025
8 |
9 |
10 | Highlights
11 | ----------
12 |
13 | * The ``cuda.bindings.nvvm`` Python module was added, wrapping the
14 | `libNVVM C API `_
15 | * Source build error checking added for missing required headers
16 | * Statically link CUDA Runtime instead of reimplementing it
17 | * Move stream callback wrappers to the Python layer
18 | * Return code construction is made faster
19 |
20 |
21 | Bug fixes
22 | ---------
23 |
24 | * Fix segfault when converting char* NULL to bytes
25 | * Failed API calls return None for non error code tuple elements
26 | * Compute-sanitizer may report ``CUDA_ERROR_INVALID_CONTEXT`` when calling certain CUDA
27 | runtime APIs such as ``cudaGetDevice()``
28 |
29 |
30 | Miscellaneous
31 | -------------
32 |
33 | * Benchmark suite is updated
34 | * Improvements in the introductory code samples
35 | * Fix performance hint warnings raised by Cython 3
36 | * Improvements in the Overview page
37 |
38 |
39 | Known issues
40 | ------------
41 |
42 | * Updating from older versions (v12.6.2.post1 and below) via ``pip install -U cuda-python`` might not work. Please do a clean re-installation by uninstalling ``pip uninstall -y cuda-python`` followed by installing ``pip install cuda-python``.
43 |
--------------------------------------------------------------------------------
/cuda_core/tests/helpers/nanosleep_kernel.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: Apache-2.0
3 |
4 | from cuda.core import (
5 | LaunchConfig,
6 | Program,
7 | ProgramOptions,
8 | launch,
9 | )
10 |
11 |
12 | class NanosleepKernel:
13 | """
14 | Manages a kernel that sleeps for a specified duration using clock64().
15 | """
16 |
17 | def __init__(self, device, sleep_duration_ms: int = 20):
18 | """
19 | Initialize the nanosleep kernel.
20 |
21 | Args:
22 | device: CUDA device to compile the kernel for
23 | sleep_duration_ms: Duration to sleep in milliseconds (default: 20)
24 | """
25 | code = f"""
26 | extern "C"
27 | __global__ void nanosleep_kernel() {{
28 | // The maximum sleep duration is approximately 1 millisecond.
29 | unsigned int one_ms = 1000000U;
30 | for (unsigned int i = 0; i < {sleep_duration_ms}; ++i) {{
31 | __nanosleep(one_ms);
32 | }}
33 | }}
34 | """
35 | program_options = ProgramOptions(std="c++17", arch=f"sm_{device.arch}")
36 | prog = Program(code, code_type="c++", options=program_options)
37 | mod = prog.compile("cubin")
38 | self.kernel = mod.get_kernel("nanosleep_kernel")
39 |
40 | def launch(self, stream):
41 | """Launch the nanosleep kernel on the given stream."""
42 | config = LaunchConfig(grid=1, block=1)
43 | launch(stream, config, self.kernel)
44 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/release/11.4.0-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 11.4.0 Release notes
5 | ================================
6 |
7 | Released on August 16, 2021
8 |
9 | Highlights
10 | ----------
11 | - Initial EA release for CUDA Python
12 | - Supports all platforms that CUDA is supported
13 | - Supports all CUDA 11.x releases
14 | - Low-level CUDA Cython bindings and Python wrappers
15 |
16 | Limitations
17 | -----------
18 |
19 | - Source code release only; Python packages coming in a future release.
20 |
21 | CUDA Functions Not Supported in this Release
22 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
23 |
24 | - cudaGetTextureReference
25 | - cudaGetSurfaceReference
26 | - cudaBindTexture
27 | - cudaBindTexture2D
28 | - cudaBindTextureToArray
29 | - cudaBindTextureToMipmappedArray
30 | - cudaLaunchKernel
31 | - cudaLaunchCooperativeKernel
32 | - cudaLaunchCooperativeKernelMultiDevice
33 | - cudaMemcpyToSymbol
34 | - cudaMemcpyFromSymbol
35 | - cudaMemcpyToSymbolAsync
36 | - cudaMemcpyFromSymbolAsync
37 | - cudaGetSymbolAddress
38 | - cudaGetSymbolSize
39 | - cudaUnbindTexture
40 | - cudaGetTextureAlignmentOffset
41 | - cudaBindSurfaceToArray
42 | - cudaGetFuncBySymbol
43 | - cudaSetValidDevices
44 | - cudaGraphExecMemcpyNodeSetParamsFromSymbol
45 | - cudaGraphExecMemcpyNodeSetParamsToSymbol
46 | - cudaGraphAddMemcpyNodeToSymbol
47 | - cudaGraphAddMemcpyNodeFromSymbol
48 | - cudaGraphMemcpyNodeSetParamsToSymbol
49 | - cudaGraphMemcpyNodeSetParamsFromSymbol
50 |
--------------------------------------------------------------------------------
/cuda_pathfinder/DESCRIPTION.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: Apache-2.0
3 |
4 | *******************************************************
5 | cuda-pathfinder: Utilities for locating CUDA components
6 | *******************************************************
7 |
8 | .. image:: https://img.shields.io/badge/NVIDIA-black?logo=nvidia
9 | :target: https://www.nvidia.com/
10 | :alt: NVIDIA
11 |
12 | `cuda.pathfinder `_
13 | aims to be a one-stop solution for locating CUDA components. Currently
14 | it supports locating and loading dynamic libraries (``.so``, ``.dll``), and
15 | locating CTK header directories. Support for other artifacts is in progress.
16 |
17 | * `Documentation `_
18 | * `Releases `_
19 | * `Repository `_
20 | * `Issue tracker `_ (select component ``cuda.pathfinder``)
21 |
22 | ``cuda.pathfinder`` is under active development. Feedback and suggestions are welcome.
23 |
24 |
25 | Installation
26 | ============
27 |
28 | .. code-block:: bash
29 |
30 | pip install cuda-pathfinder
31 |
32 | ``cuda-pathfinder`` is `CUDA Toolkit (CTK) `_
33 | version-agnostic. It follows the general CUDA Toolkit support policy: the
34 | two most recent major versions are supported simultaneously.
35 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/doc_request.yml:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: Apache-2.0
4 |
5 | name: Documentation Request
6 | description: Suggest an idea to improve cuda-python
7 | title: '[DOC]: '
8 | labels: ['doc']
9 |
10 | body:
11 | - type: checkboxes
12 | id: check-duplicates
13 | attributes:
14 | label: Is this a duplicate?
15 | description: Check for duplicate issues.
16 | options:
17 | - label: I confirmed there appear to be no [duplicate issues](https://github.com/NVIDIA/cuda-python/issues) for this bug and that I agree to the [Code of Conduct](CODE_OF_CONDUCT.md)
18 | required: true
19 |
20 | - type: dropdown
21 | id: new_or_correction
22 | attributes:
23 | label: Is this for new documentation, or an update to existing docs?
24 | options:
25 | - New
26 | - Update
27 | validations:
28 | required: true
29 |
30 | - type: textarea
31 | id: problem
32 | attributes:
33 | label: Describe the incorrect/future/missing documentation
34 | placeholder: "Example: A code snippet mentions function foo(args) but I cannot find any documentation on it."
35 | validations:
36 | required: true
37 |
38 | - type: textarea
39 | id: search_locs
40 | attributes:
41 | label: If this is a correction, please provide a link to the incorrect documentation. If this is a new documentation request, please link to where you have looked.
42 | placeholder: |
43 | https://nvidia.github.io/cuda-python/latest/
44 |
--------------------------------------------------------------------------------
/cuda_core/tests/helpers/logging.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: Apache-2.0
3 |
4 | import time
5 |
6 |
7 | class TimestampedLogger:
8 | """
9 | A logger that prefixes each output with a timestamp, containing the elapsed
10 | time since the logger was created.
11 |
12 | Example:
13 |
14 | import multiprocess as mp
15 | import time
16 |
17 | def main():
18 | log = TimestampedLogger(prefix="parent: ")
19 | log("begin")
20 | process = mp.Process(target=child_main, args=(log,))
21 | process.start()
22 | process.join()
23 | log("done")
24 |
25 | def child_main(log):
26 | log.prefix = " child: "
27 | log("begin")
28 | time.sleep(1)
29 | log("done")
30 |
31 | if __name__ == "__main__":
32 | main()
33 |
34 | Possible output:
35 |
36 | [ 0.003 ms] parent: begin
37 | [ 819.464 ms] child: begin
38 | [ 1819.666 ms] child: done
39 | [ 1882.954 ms] parent: done
40 | """
41 |
42 | def __init__(self, prefix=None, start_time=None, enabled=True):
43 | self.prefix = "" if prefix is None else prefix
44 | self.start_time = start_time if start_time is not None else time.time_ns()
45 | self.enabled = enabled
46 |
47 | def __call__(self, msg):
48 | if self.enabled:
49 | now = (time.time_ns() - self.start_time) * 1e-6
50 | print(f"[{now:>10.3f} ms] {self.prefix}{msg}")
51 |
--------------------------------------------------------------------------------
/cuda_core/tests/cython/test_get_cuda_native_handle.pyx:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
4 |
5 | # distutils: language = c++
6 | # distutils: extra_compile_args = -std=c++17
7 |
8 | from libc.stdint cimport intptr_t
9 |
10 | from cuda.bindings.driver cimport (CUstream as pyCUstream,
11 | CUevent as pyCUevent)
12 | from cuda.bindings.nvrtc cimport nvrtcProgram as pynvrtcProgram
13 | from cuda.bindings.cydriver cimport CUstream, CUevent
14 | from cuda.bindings.cynvrtc cimport nvrtcProgram
15 |
16 | from cuda.core import Device, Program
17 |
18 |
19 | cdef extern from "utility.hpp":
20 | void* get_cuda_native_handle[T](T)
21 |
22 |
23 | def test_get_cuda_native_handle():
24 | dev = Device(0)
25 | dev.set_current()
26 |
27 | s = dev.create_stream()
28 | cdef pyCUstream s_py = s.handle
29 | cdef CUstream s_c = get_cuda_native_handle(s_py)
30 | assert (s_c) == (int(s_py))
31 |
32 | e = s.record()
33 | cdef pyCUevent e_py = e.handle
34 | cdef CUevent e_c = get_cuda_native_handle(e_py)
35 | assert (e_c) == (int(e_py))
36 |
37 | prog = Program("extern \"C\" __global__ void dummy() {}", "c++")
38 | assert prog.backend == "NVRTC"
39 | cdef pynvrtcProgram prog_py = prog.handle
40 | cdef nvrtcProgram prog_c = get_cuda_native_handle(prog_py)
41 | assert (prog_c) == (int(prog_py))
42 |
43 | prog.close()
44 | e.close()
45 | s.close()
46 |
--------------------------------------------------------------------------------
/cuda_bindings/tests/nvml/test_gpu.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | import pytest
5 | from cuda.bindings import _nvml as nvml
6 |
7 | from . import util
8 |
9 |
10 | def test_gpu_get_module_id(nvml_init):
11 | # Unique module IDs cannot exceed the number of GPUs on the system
12 | device_count = nvml.device_get_count_v2()
13 |
14 | for i in range(device_count):
15 | device = nvml.device_get_handle_by_index_v2(i)
16 | uuid = nvml.device_get_uuid(device)
17 |
18 | if util.is_vgpu(device):
19 | continue
20 |
21 | module_id = nvml.device_get_module_id(device)
22 | assert isinstance(module_id, int)
23 |
24 |
25 | def test_gpu_get_platform_info(all_devices):
26 | skip_reasons = set()
27 | for device in all_devices:
28 | if util.is_vgpu(device):
29 | skip_reasons.add(f"Not supported on vGPU device {device}")
30 | continue
31 |
32 | # TODO
33 | # if device.feature_dict.board.chip < board_class.Architecture.Blackwell:
34 | # test_utils.skip_test("Not supported on chip before Blackwell")
35 |
36 | try:
37 | platform_info = nvml.device_get_platform_info(device)
38 | except nvml.NotSupportedError:
39 | skip_reasons.add(f"Not supported returned, linkely NVLink is disable for {device}")
40 | continue
41 |
42 | assert isinstance(platform_info, nvml.PlatformInfo_v2)
43 |
44 | if skip_reasons:
45 | pytest.skip(" ; ".join(skip_reasons))
46 |
--------------------------------------------------------------------------------
/cuda_bindings/cuda/bindings/_lib/windll.pxd:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | from libc.stddef cimport wchar_t
5 | from libc.stdint cimport uintptr_t
6 | from cpython cimport PyUnicode_AsWideCharString, PyMem_Free
7 |
8 | cdef extern from "windows.h" nogil:
9 | ctypedef void* HMODULE
10 | ctypedef void* HANDLE
11 | ctypedef void* FARPROC
12 | ctypedef unsigned long DWORD
13 | ctypedef const wchar_t *LPCWSTR
14 | ctypedef const char *LPCSTR
15 | ctypedef int BOOL
16 |
17 | cdef DWORD LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800
18 |
19 | HMODULE _LoadLibraryExW "LoadLibraryExW"(
20 | LPCWSTR lpLibFileName,
21 | HANDLE hFile,
22 | DWORD dwFlags
23 | )
24 |
25 | FARPROC _GetProcAddress "GetProcAddress"(HMODULE hModule, LPCSTR lpProcName)
26 |
27 | BOOL _FreeLibrary "FreeLibrary"(HMODULE hLibModule)
28 |
29 | cdef inline uintptr_t LoadLibraryExW(str path, HANDLE hFile, DWORD dwFlags):
30 | cdef uintptr_t result
31 | cdef wchar_t* wpath = PyUnicode_AsWideCharString(path, NULL)
32 | with nogil:
33 | result = _LoadLibraryExW(
34 | wpath,
35 | hFile,
36 | dwFlags
37 | )
38 | PyMem_Free(wpath)
39 | return result
40 |
41 | cdef inline FARPROC GetProcAddress(uintptr_t hModule, const char* lpProcName) nogil:
42 | return _GetProcAddress(hModule, lpProcName)
43 |
44 | cdef inline BOOL FreeLibrary(uintptr_t hLibModule) nogil:
45 | return _FreeLibrary(hLibModule)
46 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/release/12.6.0-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 12.6.0 Release notes
5 | ================================
6 |
7 | Released on August 1, 2024
8 |
9 | Highlights
10 | ----------
11 | - Rebase to CUDA Toolkit 12.6
12 | - Resolve `Issue #32 `_: Add 'pywin32' as Windows requirement
13 | - Resolve `Issue #72 `_: Allow both lists and tuples as parameter
14 | - Resolve `Issue #73 `_: Fix 'cuLibraryLoadData' processing of parameters
15 |
16 | Limitations
17 | -----------
18 |
19 | CUDA Functions Not Supported in this Release
20 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
21 |
22 | - Symbol APIs
23 | - cudaGraphExecMemcpyNodeSetParamsFromSymbol
24 | - cudaGraphExecMemcpyNodeSetParamsToSymbol
25 | - cudaGraphAddMemcpyNodeToSymbol
26 | - cudaGraphAddMemcpyNodeFromSymbol
27 | - cudaGraphMemcpyNodeSetParamsToSymbol
28 | - cudaGraphMemcpyNodeSetParamsFromSymbol
29 | - cudaMemcpyToSymbol
30 | - cudaMemcpyFromSymbol
31 | - cudaMemcpyToSymbolAsync
32 | - cudaMemcpyFromSymbolAsync
33 | - cudaGetSymbolAddress
34 | - cudaGetSymbolSize
35 | - cudaGetFuncBySymbol
36 | - Launch Options
37 | - cudaLaunchKernel
38 | - cudaLaunchCooperativeKernel
39 | - cudaLaunchCooperativeKernelMultiDevice
40 | - cudaSetValidDevices
41 | - cudaVDPAUSetVDPAUDevice
42 | - cudaFuncGetName
43 | - cudaFuncGetParamInfo
44 |
--------------------------------------------------------------------------------
/cuda_bindings/cuda/bindings/nvvm.pxd:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
4 | #
5 | # This code was automatically generated across versions from 12.0.1 to 13.1.0. Do not modify it directly.
6 |
7 | from libc.stdint cimport intptr_t
8 |
9 | from .cynvvm cimport *
10 |
11 |
12 | ###############################################################################
13 | # Types
14 | ###############################################################################
15 |
16 | ctypedef nvvmProgram Program
17 |
18 |
19 | ###############################################################################
20 | # Enum
21 | ###############################################################################
22 |
23 | ctypedef nvvmResult _Result
24 |
25 |
26 | ###############################################################################
27 | # Functions
28 | ###############################################################################
29 |
30 | cpdef str get_error_string(int result)
31 | cpdef tuple version()
32 | cpdef tuple ir_version()
33 | cpdef intptr_t create_program() except? 0
34 | cpdef add_module_to_program(intptr_t prog, buffer, size_t size, name)
35 | cpdef lazy_add_module_to_program(intptr_t prog, buffer, size_t size, name)
36 | cpdef compile_program(intptr_t prog, int num_options, options)
37 | cpdef verify_program(intptr_t prog, int num_options, options)
38 | cpdef size_t get_compiled_result_size(intptr_t prog) except? 0
39 | cpdef get_compiled_result(intptr_t prog, buffer)
40 | cpdef size_t get_program_log_size(intptr_t prog) except? 0
41 | cpdef get_program_log(intptr_t prog, buffer)
42 |
--------------------------------------------------------------------------------
/cuda_bindings/examples/common/helper_cuda.py:
--------------------------------------------------------------------------------
1 | # Copyright 2021-2025 NVIDIA Corporation. All rights reserved.
2 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | from common.helper_string import checkCmdLineFlag, getCmdLineArgumentInt
5 | from cuda.bindings import driver as cuda
6 | from cuda.bindings import nvrtc
7 | from cuda.bindings import runtime as cudart
8 |
9 |
10 | def _cudaGetErrorEnum(error):
11 | if isinstance(error, cuda.CUresult):
12 | err, name = cuda.cuGetErrorName(error)
13 | return name if err == cuda.CUresult.CUDA_SUCCESS else ""
14 | elif isinstance(error, cudart.cudaError_t):
15 | return cudart.cudaGetErrorName(error)[1]
16 | elif isinstance(error, nvrtc.nvrtcResult):
17 | return nvrtc.nvrtcGetErrorString(error)[1]
18 | else:
19 | raise RuntimeError(f"Unknown error type: {error}")
20 |
21 |
22 | def checkCudaErrors(result):
23 | if result[0].value:
24 | raise RuntimeError(f"CUDA error code={result[0].value}({_cudaGetErrorEnum(result[0])})")
25 | if len(result) == 1:
26 | return None
27 | elif len(result) == 2:
28 | return result[1]
29 | else:
30 | return result[1:]
31 |
32 |
33 | def findCudaDevice():
34 | devID = 0
35 | if checkCmdLineFlag("device="):
36 | devID = getCmdLineArgumentInt("device=")
37 | checkCudaErrors(cudart.cudaSetDevice(devID))
38 | return devID
39 |
40 |
41 | def findCudaDeviceDRV():
42 | devID = 0
43 | if checkCmdLineFlag("device="):
44 | devID = getCmdLineArgumentInt("device=")
45 | checkCudaErrors(cuda.cuInit(0))
46 | cuDevice = checkCudaErrors(cuda.cuDeviceGet(devID))
47 | return cuDevice
48 |
--------------------------------------------------------------------------------
/cuda_core/tests/test_system.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: Apache-2.0
3 |
4 | try:
5 | from cuda.bindings import driver, runtime
6 | except ImportError:
7 | from cuda import cuda as driver
8 | from cuda import cudart as runtime
9 |
10 | from cuda.core import Device, system
11 | from cuda.core._utils.cuda_utils import handle_return
12 |
13 |
14 | def test_system_singleton():
15 | system1 = system
16 | system2 = system
17 | assert id(system1) == id(system2), "system is not a singleton"
18 |
19 |
20 | def test_driver_version():
21 | driver_version = system.get_driver_version()
22 | version = handle_return(driver.cuDriverGetVersion())
23 | expected_driver_version = (version // 1000, (version % 1000) // 10)
24 | assert driver_version == expected_driver_version, "Driver version does not match expected value"
25 |
26 |
27 | def test_num_devices():
28 | num_devices = system.get_num_devices()
29 | expected_num_devices = handle_return(runtime.cudaGetDeviceCount())
30 | assert num_devices == expected_num_devices, "Number of devices does not match expected value"
31 |
32 |
33 | def test_devices():
34 | devices = Device.get_all_devices()
35 | expected_num_devices = handle_return(runtime.cudaGetDeviceCount())
36 | expected_devices = tuple(Device(device_id) for device_id in range(expected_num_devices))
37 | assert len(devices) == len(expected_devices), "Number of devices does not match expected value"
38 | for device, expected_device in zip(devices, expected_devices):
39 | assert device.device_id == expected_device.device_id, "Device ID does not match expected value"
40 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/release/12.3.0-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | CUDA Python 12.3.0 Release notes
5 | ================================
6 |
7 | Released on October 19, 2023
8 |
9 | Highlights
10 | ----------
11 | - Rebase to CUDA Toolkit 12.3
12 | - Resolve `Issue #16 `_: cuda.cudart.cudaRuntimeGetVersion() hard-codes the runtime version, rather than querying the runtime
13 | - New API cudart.getLocalRuntimeVersion()
14 | - Resolve `Issue #48 `_: Dropping Python 3.8
15 | - Resolve `Issue #51 `_: Dropping package releases for ppc64 on PYPI and conda-nvidia channel
16 |
17 | Limitations
18 | -----------
19 |
20 | CUDA Functions Not Supported in this Release
21 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
22 |
23 | - Symbol APIs
24 | - cudaGraphExecMemcpyNodeSetParamsFromSymbol
25 | - cudaGraphExecMemcpyNodeSetParamsToSymbol
26 | - cudaGraphAddMemcpyNodeToSymbol
27 | - cudaGraphAddMemcpyNodeFromSymbol
28 | - cudaGraphMemcpyNodeSetParamsToSymbol
29 | - cudaGraphMemcpyNodeSetParamsFromSymbol
30 | - cudaMemcpyToSymbol
31 | - cudaMemcpyFromSymbol
32 | - cudaMemcpyToSymbolAsync
33 | - cudaMemcpyFromSymbolAsync
34 | - cudaGetSymbolAddress
35 | - cudaGetSymbolSize
36 | - cudaGetFuncBySymbol
37 | - Launch Options
38 | - cudaLaunchKernel
39 | - cudaLaunchCooperativeKernel
40 | - cudaLaunchCooperativeKernelMultiDevice
41 | - cudaSetValidDevices
42 | - cudaVDPAUSetVDPAUDevice
43 | - cudaFuncGetName
44 |
--------------------------------------------------------------------------------
/cuda_bindings/tests/nvml/test_init.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | import sys
5 |
6 | import pytest
7 | from cuda.bindings import _nvml as nvml
8 |
9 |
10 | def assert_nvml_is_initialized():
11 | assert nvml.device_get_count_v2() > 0
12 |
13 |
14 | def assert_nvml_is_uninitialized():
15 | with pytest.raises(nvml.UninitializedError):
16 | nvml.device_get_count_v2()
17 |
18 |
19 | @pytest.mark.skipif(sys.platform == "win32", reason="Test not supported on Windows")
20 | def test_init_ref_count():
21 | """
22 | Verifies that we can call NVML shutdown and init(2) multiple times, and that ref counting works
23 | """
24 | with pytest.raises(nvml.UninitializedError):
25 | nvml.shutdown()
26 |
27 | assert_nvml_is_uninitialized()
28 |
29 | for i in range(3):
30 | # Init 5 times
31 | for j in range(5):
32 | nvml.init_v2()
33 | assert_nvml_is_initialized()
34 |
35 | # Shutdown 4 times, NVML should remain initailized
36 | for j in range(4):
37 | nvml.shutdown()
38 | assert_nvml_is_initialized()
39 |
40 | # Shutdown the final time
41 | nvml.shutdown()
42 | assert_nvml_is_uninitialized()
43 |
44 |
45 | def test_init_check_index(nvml_init):
46 | """
47 | Verifies that the index from nvmlDeviceGetIndex is correct
48 | """
49 | dev_count = nvml.device_get_count_v2()
50 | for idx in range(dev_count):
51 | handle = nvml.device_get_handle_by_index_v2(idx)
52 | # Verify that the index matches
53 | assert idx == nvml.device_get_index(handle)
54 |
--------------------------------------------------------------------------------
/toolshed/check_spdx.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: Apache-2.0
3 |
4 | import os
5 | import sys
6 |
7 | import pathspec
8 |
9 | # Intentionally puzzling together EXPECTED_SPDX_BYTES so that we don't overlook
10 | # if the identifiers are missing in this file.
11 | EXPECTED_SPDX_BYTES = (
12 | b"-".join((b"SPDX", b"License", b"Identifier: ")),
13 | b"-".join((b"SPDX", b"FileCopyrightText: ")),
14 | )
15 |
16 | SPDX_IGNORE_FILENAME = ".spdx-ignore"
17 |
18 |
19 | def load_spdx_ignore():
20 | if os.path.exists(SPDX_IGNORE_FILENAME):
21 | with open(SPDX_IGNORE_FILENAME, encoding="utf-8") as f:
22 | lines = f.readlines()
23 | else:
24 | lines = []
25 | lines.append(SPDX_IGNORE_FILENAME + "\n")
26 | return pathspec.PathSpec.from_lines("gitwildmatch", lines)
27 |
28 |
29 | def has_spdx_or_is_empty(filepath):
30 | with open(filepath, "rb") as f:
31 | blob = f.read()
32 | if len(blob.strip()) == 0:
33 | return True
34 | good = True
35 | for expected_bytes in EXPECTED_SPDX_BYTES:
36 | if expected_bytes not in blob:
37 | print(f"MISSING {expected_bytes.decode()}{filepath!r}")
38 | good = False
39 | return good
40 |
41 |
42 | def main(args):
43 | assert args, "filepaths expected to be passed from pre-commit"
44 |
45 | ignore_spec = load_spdx_ignore()
46 |
47 | returncode = 0
48 | for filepath in args:
49 | if ignore_spec.match_file(filepath):
50 | continue
51 | if not has_spdx_or_is_empty(filepath):
52 | returncode = 1
53 | return returncode
54 |
55 |
56 | if __name__ == "__main__":
57 | sys.exit(main(sys.argv[1:]))
58 |
--------------------------------------------------------------------------------
/cuda_core/docs/build_docs.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
4 | # SPDX-License-Identifier: Apache-2.0
5 |
6 | set -ex
7 |
8 | if [[ "$#" == "0" ]]; then
9 | LATEST_ONLY="0"
10 | elif [[ "$#" == "1" && "$1" == "latest-only" ]]; then
11 | LATEST_ONLY="1"
12 | else
13 | echo "usage: ./build_docs.sh [latest-only]"
14 | exit 1
15 | fi
16 |
17 | # SPHINX_CUDA_CORE_VER is used to create a subdir under build/html
18 | # (the Makefile file for sphinx-build also honors it if defined)
19 | if [[ -z "${SPHINX_CUDA_CORE_VER}" ]]; then
20 | export SPHINX_CUDA_CORE_VER=$(python -c "from importlib.metadata import version; print(version('cuda-core'))" \
21 | | awk -F'+' '{print $1}')
22 | fi
23 |
24 | # build the docs (in parallel)
25 | SPHINXOPTS="-j 4 -d build/.doctrees" make html
26 |
27 | # for debugging/developing (conf.py), please comment out the above line and
28 | # use the line below instead, as we must build in serial to avoid getting
29 | # obsecure Sphinx errors
30 | #SPHINXOPTS="-v" make html
31 |
32 | # to support version dropdown menu
33 | cp ./versions.json build/html
34 | cp ./nv-versions.json build/html
35 |
36 | # to have a redirection page (to the latest docs)
37 | cp source/_templates/main.html build/html/index.html
38 |
39 | # ensure that the latest docs is the one we built
40 | if [[ $LATEST_ONLY == "0" ]]; then
41 | cp -r build/html/${SPHINX_CUDA_CORE_VER} build/html/latest
42 | else
43 | mv build/html/${SPHINX_CUDA_CORE_VER} build/html/latest
44 | fi
45 |
46 | # ensure that the Sphinx reference uses the latest docs
47 | cp build/html/latest/objects.inv build/html
48 |
49 | # clean up previously auto-generated files
50 | rm -rf source/generated/
51 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/release/12.9.3-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | .. module:: cuda.bindings
5 |
6 | ``cuda-bindings`` 12.9.3 Release notes
7 | ======================================
8 |
9 | Released on Oct 9, 2025
10 |
11 |
12 | Highlights
13 | ----------
14 |
15 | * This is the last release that officially supports Python 3.9.
16 | * Python 3.14 is supported.
17 | * **Experimental** free-threaded builds for Python 3.13/3.14 are made available. Any bugs can be reported to `our GitHub repo `_. More details are available in our :ref:`support` docs.
18 | * Automatic CUDA library path detection based on ``CUDA_HOME``, eliminating the need to manually set ``LIBRARY_PATH`` environment variables for installation.
19 | * The Python overhead of calling functions in CUDA bindings in ``driver``, ``runtime`` and ``nvrtc`` has been reduced by approximately 30%.
20 | * On Windows, the ``pywin32`` dependency has been removed. The necessary Windows API functions are now accessed directly.
21 | * Updated the ``cuda.bindings.runtime`` module to statically link against the CUDA Runtime library from CUDA Toolkit 12.9.1.
22 | * ``cyruntime.getLocalRuntimeVersion`` now uses pathfinder to find the CUDA runtime.
23 |
24 |
25 | Known issues
26 | ------------
27 |
28 | * Updating from older versions (v12.6.2.post1 and below) via ``pip install -U cuda-python`` might not work. Please do a clean re-installation by uninstalling ``pip uninstall -y cuda-python`` followed by installing ``pip install cuda-python``.
29 | * The graphics APIs in ``cuda.bindings.runtime`` are inadvertently disabled in 12.9.3. Users needing these APIs should update to 12.9.4.
30 |
--------------------------------------------------------------------------------
/cuda_core/README.md:
--------------------------------------------------------------------------------
1 | # `cuda.core`: (experimental) Pythonic CUDA module
2 |
3 | Currently under active development; see [the documentation](https://nvidia.github.io/cuda-python/cuda-core/latest/) for more details.
4 |
5 | ## Installing
6 |
7 | Please refer to the [Installation page](https://nvidia.github.io/cuda-python/cuda-bindings/latest/install.html) for instructions and required/optional dependencies.
8 |
9 | ## Developing
10 |
11 | This subpackage adheres to the developing practices described in the parent metapackage [CONTRIBUTING.md](https://github.com/NVIDIA/cuda-python/blob/main/CONTRIBUTING.md).
12 |
13 | ## Testing
14 |
15 | To run these tests:
16 | * `python -m pytest tests/` with editable installations
17 | * `pytest tests/` with installed packages
18 |
19 | Alternatively, from the repository root you can use a simple script:
20 |
21 | * `./scripts/run_tests.sh core` to run only `cuda_core` tests
22 | * `./scripts/run_tests.sh` to run all package tests (pathfinder → bindings → core)
23 | * `./scripts/run_tests.sh smoke` to run meta-level smoke tests under `tests/integration`
24 |
25 | ### Cython Unit Tests
26 |
27 | Cython tests are located in `tests/cython` and need to be built. These builds have the same CUDA Toolkit header requirements as [those of cuda.bindings](https://nvidia.github.io/cuda-python/cuda-bindings/latest/install.html#requirements) where the major.minor version must match `cuda.bindings`. To build them:
28 |
29 | 1. Set up environment variable `CUDA_HOME` with the path to the CUDA Toolkit installation.
30 | 2. Run `build_tests` script located in `tests/cython` appropriate to your platform. This will both cythonize the tests and build them.
31 |
32 | To run these tests:
33 | * `python -m pytest tests/cython/` with editable installations
34 | * `pytest tests/cython/` with installed packages
35 |
--------------------------------------------------------------------------------
/cuda_bindings/cuda/bindings/nvjitlink.pxd:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | #
3 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
4 | #
5 | # This code was automatically generated across versions from 12.0.1 to 13.1.0. Do not modify it directly.
6 |
7 | from libc.stdint cimport intptr_t, uint32_t
8 |
9 | from .cynvjitlink cimport *
10 |
11 |
12 | ###############################################################################
13 | # Types
14 | ###############################################################################
15 |
16 | ctypedef nvJitLinkHandle Handle
17 |
18 |
19 | ###############################################################################
20 | # Enum
21 | ###############################################################################
22 |
23 | ctypedef nvJitLinkResult _Result
24 | ctypedef nvJitLinkInputType _InputType
25 |
26 |
27 | ###############################################################################
28 | # Functions
29 | ###############################################################################
30 |
31 | cpdef intptr_t create(uint32_t num_options, options) except -1
32 | cpdef add_data(intptr_t handle, int input_type, data, size_t size, name)
33 | cpdef add_file(intptr_t handle, int input_type, file_name)
34 | cpdef complete(intptr_t handle)
35 | cpdef size_t get_linked_cubin_size(intptr_t handle) except? 0
36 | cpdef get_linked_cubin(intptr_t handle, cubin)
37 | cpdef size_t get_linked_ptx_size(intptr_t handle) except? 0
38 | cpdef get_linked_ptx(intptr_t handle, ptx)
39 | cpdef size_t get_error_log_size(intptr_t handle) except? 0
40 | cpdef get_error_log(intptr_t handle, log)
41 | cpdef size_t get_info_log_size(intptr_t handle) except? 0
42 | cpdef get_info_log(intptr_t handle, log)
43 | cpdef tuple version()
44 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security
2 |
3 | NVIDIA is dedicated to the security and trust of our software products and services,
4 | including all source code repositories managed through our organization.
5 |
6 | If you need to report a security issue, please use the appropriate contact points outlined
7 | below. **Please do not report security vulnerabilities through GitHub/GitLab.**
8 |
9 | ## Reporting Potential Security Vulnerability in CUDA Python
10 |
11 | To report a potential security vulnerability in CUDA Python:
12 |
13 | - Web: [Security Vulnerability Submission
14 | Form](https://www.nvidia.com/object/submit-security-vulnerability.html)
15 | - E-Mail:
16 | - We encourage you to use the following PGP key for secure email communication: [NVIDIA
17 | public PGP Key for communication](https://www.nvidia.com/en-us/security/pgp-key)
18 | - Please include the following information:
19 | - Product/Driver name and version/branch that contains the vulnerability
20 | - Type of vulnerability (code execution, denial of service, buffer overflow, etc.)
21 | - Instructions to reproduce the vulnerability
22 | - Proof-of-concept or exploit code
23 | - Potential impact of the vulnerability, including how an attacker could exploit the
24 | vulnerability
25 |
26 | While NVIDIA currently does not have a bug bounty program, we do offer acknowledgement when
27 | an externally reported security issue is addressed under our coordinated vulnerability
28 | disclosure policy. Please visit our [Product Security Incident Response Team
29 | (PSIRT)](https://www.nvidia.com/en-us/security/psirt-policies/) policies page for more
30 | information.
31 |
32 | ## NVIDIA Product Security
33 |
34 | For all security-related concerns, please visit NVIDIA's Product Security portal at
35 | .
36 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/release/12.8.0-notes.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | ``cuda-bindings`` 12.8.0 Release notes
5 | ====================================
6 |
7 | Released on January 24, 2025.
8 |
9 | Highlights
10 | ----------
11 |
12 | - Support Python 3.13
13 | - Add bindings for nvJitLink (requires nvJitLink from CUDA 12.3 or above)
14 | - Add optional dependencies on CUDA NVRTC and nvJitLink wheels
15 | - Enable discovery and loading of shared libraries from CUDA wheels
16 | - ``cuda-python`` is now a meta package, currently depending only on ``cuda-bindings`` (`see RFC `_)
17 |
18 | Wheels support for optional dependencies
19 | ----------------------------------------
20 |
21 | Optional dependencies are added for packages:
22 |
23 | - nvidia-cuda-nvrtc-cu12
24 | - nvidia-nvjitlink-cu12
25 |
26 | Installing these dependencies with ``cuda-python`` can be done using:
27 |
28 | .. code-block:: shell
29 |
30 | pip install cuda-python[all]
31 |
32 | Same applies to ``cuda-bindings``.
33 |
34 | Discovery and loading of shared library dependencies from wheels
35 | ----------------------------------------------------------------
36 |
37 | Shared library search paths for wheel builds are now extended to check site-packages. This allows ``cuda-python``/``cuda-bindings`` to seamlessly use the aforementioned CUDA Toolkit wheels installed in the user's Python environment.
38 |
39 | Known issues
40 | ------------
41 |
42 | - Updating from older versions (v12.6.2.post1 and below) via ``pip install -U cuda-python`` might not work. Please do a clean re-installation by uninstalling ``pip uninstall -y cuda-python`` followed by installing ``pip install cuda-python``.
43 |
--------------------------------------------------------------------------------
/cuda_pathfinder/cuda/pathfinder/_utils/find_site_packages_so.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | # SPDX-License-Identifier: Apache-2.0
3 |
4 | import collections
5 | import functools
6 | import importlib.metadata
7 | import re
8 |
9 | _SO_RE = re.compile(r"\.so(?:$|\.)") # matches libfoo.so or libfoo.so.1.2.3
10 |
11 |
12 | def split_so_version_suffix(so_filename: str) -> tuple[str, str]:
13 | idx = so_filename.rfind(".so")
14 | assert idx > 0, so_filename
15 | idx += 3
16 | return (so_filename[:idx], so_filename[idx:])
17 |
18 |
19 | @functools.cache
20 | def find_all_so_files_via_metadata() -> dict[str, dict[str, tuple[str, ...]]]:
21 | results: collections.defaultdict[str, collections.defaultdict[str, list[str]]] = collections.defaultdict(
22 | lambda: collections.defaultdict(list)
23 | )
24 |
25 | # sort dists for deterministic output
26 | for dist in sorted(
27 | importlib.metadata.distributions(),
28 | # `get` exists before 3.12, even though the hints only exist for Python >=3.12
29 | key=lambda d: (d.metadata.get("Name", ""), d.version), # type: ignore[attr-defined]
30 | ):
31 | files = dist.files
32 | if not files:
33 | continue
34 | for relpath in sorted(files, key=lambda p: str(p)): # deterministic
35 | relname = relpath.name
36 | if not _SO_RE.search(relname):
37 | continue
38 | so_basename, so_version_suffix = split_so_version_suffix(relname)
39 | abs_path = str(dist.locate_file(relpath))
40 | results[so_basename][so_version_suffix].append(abs_path)
41 |
42 | # plain dicts; sort inner lists for stability
43 | return {k: {kk: tuple(sorted(vv)) for kk, vv in v.items()} for k, v in results.items()}
44 |
--------------------------------------------------------------------------------
/cuda_bindings/docs/source/module/cufile.rst:
--------------------------------------------------------------------------------
1 | .. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 | .. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3 |
4 | .. default-role:: cpp:any
5 | .. module:: cuda.bindings.cufile
6 |
7 | cufile
8 | ======
9 |
10 | The ``cuda.bindings.cufile`` Python module wraps the
11 | `cuFile C APIs `_.
12 | Supported on Linux only.
13 |
14 | Currently using this module requires NumPy to be present. Any recent NumPy 1.x or 2.x should work.
15 |
16 |
17 | Functions
18 | ---------
19 |
20 | .. autosummary::
21 | :toctree: generated/
22 |
23 | handle_register
24 | handle_deregister
25 | buf_register
26 | buf_deregister
27 | read
28 | write
29 | driver_open
30 | use_count
31 | driver_get_properties
32 | driver_set_poll_mode
33 | driver_set_max_direct_io_size
34 | driver_set_max_cache_size
35 | driver_set_max_pinned_mem_size
36 | batch_io_set_up
37 | batch_io_submit
38 | batch_io_get_status
39 | batch_io_cancel
40 | batch_io_destroy
41 | read_async
42 | write_async
43 | stream_register
44 | stream_deregister
45 | get_version
46 | get_parameter_size_t
47 | get_parameter_bool
48 | get_parameter_string
49 | set_parameter_size_t
50 | set_parameter_bool
51 | set_parameter_string
52 | op_status_error
53 | driver_close
54 |
55 |
56 | Types
57 | -----
58 |
59 | .. autosummary::
60 | :toctree: generated/
61 |
62 | IOEvents
63 | Descr
64 | IOParams
65 | OpError
66 | DriverStatusFlags
67 | DriverControlFlags
68 | FeatureFlags
69 | FileHandleType
70 | Opcode
71 | Status
72 | BatchMode
73 | SizeTConfigParameter
74 | BoolConfigParameter
75 | StringConfigParameter
76 | cuFileError
77 |
--------------------------------------------------------------------------------