CuPy for CUDA 11.x
raw JSON → 13.6.0 verified Mon Apr 27 auth: no python
CuPy is a NumPy/SciPy-compatible array library for GPU-accelerated computing with CUDA 11.x. This package is specifically built for CUDA 11.x environments. Current version: 13.6.0. Release cadence: regular, matching the main CuPy release cycle.
pip install cupy-cuda11x Common errors
error ImportError: libcudart.so.11.0: cannot open shared object file: No such file or directory ↓
cause The installed cupy-cuda11x package expects CUDA 11.x runtime, but the system has a different or missing CUDA installation.
fix
Install the correct CUDA toolkit version (11.4+) or use a cupy-cuda package matching your CUDA version (e.g., cupy-cuda12x).
error cupy.cuda.runtime.CUDARuntimeError: cudaErrorNoDevice: no CUDA-capable device is detected ↓
cause No NVIDIA GPU is available or the GPU driver is not properly installed.
fix
Check GPU presence with
nvidia-smi. Install appropriate NVIDIA drivers. error ModuleNotFoundError: No module named 'cupy' ↓
cause CuPy has not been installed or the wrong package (e.g., cupy-cuda11x vs cupy) was not installed.
fix
Install with
pip install cupy-cuda11x and verify import with import cupy. Warnings
breaking CuPy v13 drops support for CUDA 11.0-11.3; only CUDA 11.4+ is supported. Ensure your CUDA version is 11.4 or higher. ↓
fix Upgrade CUDA to 11.4+ or use cupy-cuda11x version 12.x for older CUDA 11.x.
gotcha Installing cupy-cuda11x on a system with mismatched CUDA runtime version may cause import errors or silent fallback to CPU. Check with `nvidia-smi` and `nvcc --version`. ↓
fix Ensure that the installed CUDA toolkit version matches the package: CUDA 11.4+ for cupy-cuda11x.
gotcha CuPy arrays created on one GPU device cannot be directly accessed on another device. Use `cp.cuda.Device(n)` context manager to switch devices. ↓
fix Use `with cp.cuda.Device(1):` to perform operations on a different GPU.
deprecated The `cupy.cuda.Device` context management API is deprecated in favor of `cupy.cuda.Device.__enter__` and `__exit__`; use the `with` statement as usual. ↓
fix Use `with cupy.cuda.Device(0):` syntax; it remains the same but is no longer considered experimental.
Imports
- cupy
import cupy - cupyx
import cupyx
Quickstart
import cupy as cp
import numpy as np
# Create a GPU array
x_gpu = cp.array([1, 2, 3, 4, 5])
print(x_gpu)
# Perform operations on GPU
print(cp.sum(x_gpu))
# Create a random matrix on GPU
A = cp.random.randn(1000, 1000)
print(A.shape)
# Verify CUDA and CuPy version
print(cp.__version__)
print(cp.cuda.runtime.runtimeGetVersion())