cuda.bindings is a standard set of low-level interfaces, providing full coverage of and access to the CUDA host APIs from Python. Checkout the Overview for the workflow and performance results.
cuda.bindings is a subpackage of cuda-python.
cuda.bindings can be installed from:
- PyPI
- Conda (conda-forge/nvidia channels)
- Source builds
Differences between these options are described in Installation documentation. Each package guarantees minor version compatibility.
cuda.bindings is supported on all the same platforms as CUDA. Specific dependencies are as follows:
- Driver: Linux (450.80.02 or later) Windows (456.38 or later)
- CUDA Toolkit 12.x
Only the NVRTC and nvJitLink redistributable components are required from the CUDA Toolkit, which can be obtained via PyPI, Conda, or local installers (as described in the CUDA Toolkit Windows and Linux Installation Guides).
We use pre-commit to manage various tools to help development and ensure consistency.
pip install pre-commitRun this command before checking in the code changes
pre-commit run -a --show-diff-on-failureto ensure the code formatting is in line of the requirements (as listed in pyproject.toml).
This repository implements a security check to prevent the CI system from running untrusted code. A part of the security check consists of checking if the git commits are signed. See here and here for more details, including how to sign your commits.
Latest dependencies can be found in requirements.txt.
Multiple testing options are available:
- Python Unit Tests
- Cython Unit Tests
- Samples
- Benchmark
Responsible for validating different binding usage patterns. Unit test test_kernelParams.py is particularly special since it demonstrates various approaches in setting up kernel launch parameters.
To run these tests:
python -m pytest tests/against editable installationspytest tests/against installed packages
Cython tests are located in tests/cython and need to be built. These builds have the same CUDA Toolkit header requirements as Installing from Source where the major.minor version must match cuda.bindings. To build them:
- Setup environment variable
CUDA_HOMEwith the path to the CUDA Toolkit installation. - Run
build_testsscript located intest/cythonappropriate to your platform. This will both cythonize the tests and build them.
To run these tests:
python -m pytest tests/cython/against editable installationspytest tests/cython/against installed packages
Various CUDA Samples that were rewritten using CUDA Python are located in examples.
In addition, extra examples are included:
examples/extra/jit_program_test.py: Demonstrates the use of the API to compile and launch a kernel on the device. Includes device memory allocation / deallocation, transfers between host and device, creation and usage of streams, and context management.examples/extra/numba_emm_plugin.py: Implements a Numba External Memory Management plugin, showing that this CUDA Python Driver API can coexist with other wrappers of the driver API.
To run these samples:
python -m pytest tests/cython/against editable installationspytest tests/cython/against installed packages
Allows for analyzing binding performance using plugin pytest-benchmark.
To run these benchmarks:
python -m pytest --benchmark-only benchmarks/against editable installationspytest --benchmark-only benchmarks/against installed packages