skillfed

pycuda

Python wrapper for Nvidia CUDA

pycuda v2026.1 86.5K downloads/30d#13,862 on PyPI2,050
Permissive license MIT Active released

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 pycuda

uv

uv add pycuda

poetry

poetry add pycuda

Installing 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

Development Status :: 5 - Production/StableEnvironment :: ConsoleIntended Audience :: DevelopersIntended Audience :: Other AudienceIntended Audience :: Science/ResearchLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishProgramming Language :: C++Programming Language :: PythonProgramming Language :: Python :: 3Topic :: Scientific/EngineeringTopic :: Scientific/Engineering :: MathematicsTopic :: Scientific/Engineering :: PhysicsTopic :: Scientific/Engineering :: Visualization

Tags

GPU computing pythonCUDA python wrappernvidia GPU accelerationparallel computation pythonGPU array operationsCUDA driver bindingspython GPU programming
gpu-computingcudahigh-performance

More Scientific/Engineering packages