Run NumPy code on GPUs by changing only the import statement
Moving data processing code from the CPU to the GPU previously required writing complex C++ code, but now you only need to change the import statement. CuPy is a GPU array library that follows the NumPy and SciPy APIs. It allows existing Python code to run without modification in NVIDIA CUDA or AMD ROCm environments.
GPU migration by changing only the import statement
CuPy follows the function names and behavior of NumPy and SciPy exactly. For example, you can change import numpy as np to import cupy as cp and replace the variable name from np to cp. This causes the same logic to be executed in parallel on the GPU. You can speed up calculations by using existing Python scripts as-is, even without complex GPU programming knowledge.
Accessing low-level CUDA features and installation
You can access low-level CUDA features in addition to simple array operations. You can call existing CUDA C/C++ code from Python using RawKernels or optimize performance using Streams. Installation methods vary by platform. On Linux and Windows, you can install it using the pip install cupy-cuda12x or pip install cupy-cuda13x commands from PyPI. To use AMD ROCm 7.0, you must use the experimental pip install cupy-rocm-7-0. If you use Conda, you can install it with the conda install -c conda-forge cupy command, and if a specific CUDA version is required, you can specify the cuda-version metapackage together.
Who should use this library
It is suitable for developers who have data analysis or scientific computing code written in NumPy or SciPy and want to accelerate it on the GPU. It is particularly useful when you want to boost performance with minimal modifications in environments using NVIDIA GPUs. It can also be used experimentally in ROCm 7.0 environments for AMD GPUs. However, since ROCm support is still experimental, it is recommended to prioritize NVIDIA CUDA environments for stable production use. It is distributed under the MIT license and is developed and maintained by Preferred Networks and community contributors.