Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

cuda.bindings: Low-level CUDA interfaces

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.

Installing

CUDA Python 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.

Runtime Dependencies

CUDA Python is supported on all platforms that CUDA is supported. Specific dependencies are as follows:

  • Driver: Linux (450.80.02 or later) Windows (456.38 or later)
  • CUDA Toolkit 12.0 to 12.6

Only the NVRTC redistributable component is required from the CUDA Toolkit. CUDA Toolkit Documentation Installation Guides can be used for guidance. Note that the NVRTC component in the Toolkit can be obtained via PYPI, Conda or Local Installer.

Supported Python Versions

CUDA Python follows NEP 29 for supported Python version guarantee.

Before dropping support, an issue will be raised to look for feedback.

Source builds work for multiple Python versions, however pre-build PyPI and Conda packages are only provided for a subset:

  • Python 3.9 to 3.12

Developing

We use pre-commit to manage various tools to help development and ensure consistency.

pip install pre-commit

Code linting

Run this command before checking in the code changes

pre-commit run -a --show-diff-on-failure

to ensure the code formatting is in line of the requirements (as listed in pyproject.toml).

Code signing

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.

Testing

Latest dependencies can be found in requirements.txt.

Multiple testing options are available:

  • Cython Unit Tests
  • Python Unit Tests
  • Samples
  • Benchmark

Python Unit Tests

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 local builds
  • pytest tests/ against installed packages

Cython Unit Tests

Cython tests are located in tests/cython and need to be built. Furthermore they need CUDA Toolkit headers matching the major-minor of CUDA Python. To build them:

  1. Setup environment variable CUDA_HOME with the path to the CUDA Toolkit installation.
  2. Run build_tests script located in test/cython appropriate to your platform. This will both cythonize the tests and build them.

To run these tests:

  • python -m pytest tests/cython/ against local builds
  • pytest tests/cython/ against installed packages

Samples

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 local builds
  • pytest tests/cython/ against installed packages

Benchmark (WIP)

Benchmarks were used for performance analysis during initial release of CUDA Python. Today they need to be updated the 12.x toolkit and are work in progress.

The intended way to run these benchmarks was:

  • python -m pytest --benchmark-only benchmark/ against local builds
  • pytest --benchmark-only benchmark/ against installed packages