cuda-bindings provides low-level Python wrappers for the NVIDIA CUDA C driver and runtime APIs. It is a core component of the broader NVIDIA 'CUDA Python' initiative, aiming to unify and simplify GPU-accelerated computing in Python. The current version is 13.2.0, with releases often tied to CUDA Toolkit versions and ongoing development to integrate Python as a first-class language in the CUDA ecosystem.
pip install cuda-bindingsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the CUDA driver, query the number of available CUDA devices, and print basic information for each, such as its name and total memory. It leverages the low-level CUDA C APIs exposed by `cuda-bindings`.
Ensure that your installed NVIDIA GPU driver, CUDA Toolkit, and `cuda-bindings` Python package are compatible. Consult the NVIDIA CUDA Python documentation for compatibility matrices.
Perform a clean re-installation by first uninstalling with `pip uninstall -y cuda-python` (or `pip uninstall -y cuda-bindings`) followed by a fresh `pip install cuda-python` (or `pip install cuda-bindings`).
Be prepared to work with C types (e.g., `ctypes`) and manage GPU resources explicitly. For many common scientific computing or deep learning tasks, higher-level libraries might offer a simpler abstraction. Consider `cuda.core` for more Pythonic access to CUDA runtime functionalities if raw C API interaction is not strictly necessary.
Monitor GPU memory usage (`nvidia-smi`). Reduce batch sizes, optimize memory allocation patterns, and ensure correct buffer sizing and indexing in custom CUDA kernels. Explicitly free unused GPU memory if applicable.
Ensure the `cuda-python` package is installed using `pip install cuda-python` (or `pip install cuda-bindings`). If installed, verify that the Python environment (e.g., virtual environment) where the script is run has access to the installed package.
Verify the availability of pre-built wheels for your specific Python version and operating system/architecture on the `cuda-python` PyPI project page. If no wheels are available, consider using a supported Python version or a `glibc`-based Linux distribution. Building `cuda-bindings` from source is generally not supported or recommended due to its low-level nature and tight coupling with CUDA Toolkits.