pycuda
Python wrapper for Nvidia CUDA
What it is and what it does
PyCUDA is a Python wrapper around Nvidia's CUDA driver API that lets you write GPU-accelerated code without leaving Python. It abstracts away low-level CUDA complexity while exposing the full power of the driver API when needed. The package uses RAII (Resource Acquisition Is Initialization) to tie GPU memory and context cleanup to Python object lifetimes, eliminating manual resource management and preventing leaks. It includes high-level abstractions like SourceModule for compiling CUDA kernels and GPUArray for working with GPU memory, plus automatic error translation from CUDA errors into Python exceptions.
The core layer is written in C++, so the convenience abstractions carry minimal overhead. PyCUDA depends on pytools, platformdirs, and mako for code generation and utility functions. It requires Python 3.8+ and an Nvidia GPU with the CUDA toolkit installed; installation involves compiling C++ code, making setup more involved than pure-Python packages. The project is actively maintained with a long history since 2008 and carries no known security vulnerabilities.
Use it for:
- Accelerate numerical simulations and scientific computing by offloading compute-intensive kernels to GPU.
- Build custom CUDA kernels for machine learning preprocessing or inference steps not covered by high-level frameworks.
- Prototype GPU algorithms in Python before optimizing them in C++ or CUDA.
- Interoperate between Python code and existing CUDA libraries or OpenGL graphics pipelines.
- Manage GPU memory and multi-GPU coordination in research or data-processing pipelines.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
PyCUDA provides Pythonic bindings to Nvidia's CUDA API, letting you write GPU-accelerated code in Python with automatic memory management, error handling, and access to CUDA's full driver API.
Yes, if you have an Nvidia GPU and need direct, low-level access to CUDA from Python. The high install friction (compiled C++ component, CUDA toolkit requirement) and active maintenance make it suitable for serious GPU computing work. Skip it if you need quick prototyping without system-level setup, or if you can use higher-level frameworks like CuPy or PyTorch instead.
Install
pycuda on PyPI
pip
pip install pycudauv
uv add pycudapoetry
poetry add pycudaInstalling pycuda
Before you install
Installation friction is high—the package requires a compiled C++ component and CUDA toolkit presence on the system. Maintenance is active with recent commits and a stable release cadence since 2008, but the high barrier to entry means setup demands careful environment preparation.
License in practice
MIT license (permissive) places no restrictions on use, modification, or distribution. You can integrate PyCUDA into commercial or proprietary projects without licensing obligations.
Quickstart
pip install pycuda
import pycuda.driver as cuda
import pycuda.autoinit
from pycuda.compiler import SourceModule
mod = SourceModule("""__global__ void add(float *a, float *b) { ... }""")
add = mod.get_function("add")
Requires Nvidia CUDA toolkit installed on the system and a compatible Nvidia GPU; compilation during install needs a C++ compiler and CUDA headers.
Verify before relying
- Whether the package works with recent CUDA versions (12.x+) or has known compatibility gaps.
- Performance characteristics compared to alternatives like CuPy or Numba for typical workloads.
- Whether the C++ base layer introduces significant overhead for small kernels or memory transfers.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (~=3.8) |
| Install friction | high — source build required |
| Runtime dependencies | 3 — pytools, platformdirs, mako |
| Maintenance | actively maintained — 211 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 86,454/month — #13,862 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pycuda-2026.1.tar.gz
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
nvidia-cuda-runtimeProvides NVIDIA CUDA Runtime native libraries…
unclear · top 1,000 on PyPI
pyopenclPyOpenCL provides Python bindings to OpenCL,…
permissive · top 15,000 on PyPI
cuda-pythoncuda-python is a metapackage providing Pythonic…
unclear · top 5,000 on PyPI
nvidia-cuda-crtProvides NVIDIA CUDA C Runtime libraries for…
unclear · top 5,000 on PyPI
nvidia-cuda-runtime-cu11Provides CUDA 11 runtime native libraries for…
unclear · top 5,000 on PyPI
nvshmem4py-cu13Provides a Python interface to NVSHMEM,…
unclear · top 15,000 on PyPI
cuda-coreProvides Pythonic APIs to access CUDA core…
permissive · top 5,000 on PyPI
nvidia-cuda-runtime-cu12Provides NVIDIA CUDA 12 runtime native…
unclear · top 1,000 on PyPI
nvidia-ml-py3Provides Python bindings to NVIDIA's Management…
permissive · top 15,000 on PyPI
nvidia-ml-pyPython wrapper around NVIDIA's Management…
permissive · top 5,000 on PyPI