Overview

CuPy 12.0, released on April 15, 2023, ensures compatibility with NumPy 1.24 and improves GPU operation performance.

Main Features

NumPy 1.24 compatibility

CuPy 12.0 aligns with the NumPy 1.24 API, making it easy to switch from CPU to GPU with minimal code changes.

python
import cupy as cp

# Same API as NumPy, executed on GPU
x = cp.random.randn(10000, 10000)
y = cp.random.randn(10000, 10000)

# Matrix multiplication on GPU
z = cp.matmul(x, y)
print(f'Shape: {z.shape}')  # (10000, 10000)
print(f'Mean: {z.mean():.4f}')

Improved performance

CUDA kernels have been optimized for reduction operations and elementwise functions, offering significant gains on recent GPUs.

python
import cupy as cp
import numpy as np

# CPU -> GPU transfer
data_cpu = np.random.randn(1000000)
data_gpu = cp.asarray(data_cpu)

# Computation on GPU
result_gpu = cp.fft.fft(data_gpu)

# GPU -> CPU transfer
result_cpu = cp.asnumpy(result_gpu)
print(f'Elements: {len(result_cpu)}')

Sources