Overview

CuPy 10.0, released on January 20, 2022, adds Python 3.10 and CUDA 11 support for accelerated GPU computing.

Main Features

Python 3.10 and CUDA 11 support

CuPy 10.0 is compatible with Python 3.10 and CUDA 11, enabling the latest NVIDIA GPU features with modern Python code.

python
import cupy as cp

# Create arrays on GPU
a = cp.random.randn(1000, 1000)
b = cp.random.randn(1000, 1000)

# Matrix multiplication on GPU
c = a @ b
print(c.shape)  # (1000, 1000)
print(type(c))  # <class 'cupy.ndarray'>

Custom kernels

CuPy allows defining custom CUDA kernels directly in Python with RawKernel, providing fine-grained control over GPU computation.

python
import cupy as cp

# Custom CUDA kernel
add_kernel = cp.RawKernel(r'''
extern "C" __global__
void add(const float* x, const float* y, float* z, int n) {
    int tid = blockDim.x * blockIdx.x + threadIdx.x;
    if (tid < n) z[tid] = x[tid] + y[tid];
}
''', 'add')

n = 1024
x = cp.random.randn(n, dtype=cp.float32)
y = cp.random.randn(n, dtype=cp.float32)
z = cp.empty(n, dtype=cp.float32)
add_kernel((n // 256,), (256,), (x, y, z, n))

Sources