Python bindings for CUDA · cuda.core + cuda.bindings · drive the GPU from Python · verified against cuda-python 13.x (2026)

CUDA Python cheat sheet

CUDA Python (cuda-python) is NVIDIA's official Python interface to CUDA. It's now a metapackage of independently versioned parts: cuda.bindings — thin, 1:1 Python bindings to the CUDA Driver, Runtime, and NVRTC C APIs; and cuda.core — a higher-level, Pythonic layer (Device, Stream, Program, launch) that hides the boilerplate. Use it to compile and launch your own CUDA C++ kernels, manage device memory, and interop with CuPy/Numba/PyTorch. Targets cuda-python 13.x (CUDA 12/13), Python 3.9+.

setup & device run kernels (cuda.core) low-level bindings streams & interop math libs & ecosystem gotcha most common

Verified 2026-08-31 against nvidia.github.io/cuda-python (cuda-python 13.x = cuda.bindings + cuda.core; CUDA 12.x & 13.x). cuda.core lives under the cuda.core.experimental namespace (API still stabilizing). Not a kernel-writing DSL — for that see Numba/Warp; this drives CUDA from Python.

Outline

Reach for cuda.core for a clean Device/Stream/launch workflow; drop to cuda.bindings when you need an exact C API call. Interop lets you share memory with CuPy/Torch instead of copying.

Setup & device

  1. 1Install & the split
  2. 2Device & context

Run kernels (cuda.core)

  1. 3Compile a kernel
  2. 4Launch config & launch
  3. 5Memory & buffers

Low-level bindings

  1. 6Runtime API
  2. 7Driver & NVRTC
  3. 8Error checking

Streams & interop

  1. 9Streams & events
  2. 10Array interop

Math libs & ecosystem

  1. 11nvmath-python
  2. 12Choosing a tool

Setup & Device

Install the metapackage (or just the part you need); select a GPU.

1Install & the splitmetapackage
2Device & contextcuda.core

Run Kernels (cuda.core)

Compile CUDA C++ at runtime, configure the grid, and launch.

3Compile a kernelNVRTC, made easy
4Launch config & launchgrid × block
5Memory & buffersallocate & copy

Low-level Bindings

1:1 access to the CUDA C APIs when you need exact control.

6Runtime APIcudart, in Python
7Driver & NVRTCthe low road
8Error checkingcheck every call

Streams & Interop

Overlap work with streams/events; share GPU memory instead of copying.

9Streams & eventsconcurrency
10Array interopno-copy sharing

Math Libs & Ecosystem

Reach for prebuilt GPU math, and know which tool fits the job.

11nvmath-pythonGPU math libraries
12Choosing a toolthe landscape

Worth memorizing

cuda-pythonmetapackage = cuda.bindings + cuda.core
cuda.core.experimentalhigh-level Device/Stream/launch
cuda.bindings.{driver,runtime,nvrtc}1:1 C APIs
Device(0).set_current()select a GPU
Program(...).compileNVRTC-compile CUDA C++ at runtime
LaunchConfig + launchreplaces <<<grid,block>>>
dev.allocate / copy_fromdevice Buffer + async copies
stream.sync()wait before reading results
bindings return (err, ...)check the error code yourself
__cuda_array_interface__ / DLPackzero-copy interop
nvmath-pythoncuBLAS/cuFFT/cuSOLVER, pythonic
write kernels in Python?Numba @cuda.jit / Warp, not this