cupy README

The project's README from github.com/cupy/cupy. As one markdown file: README.md.

CuPy : NumPy & SciPy for GPU

pypi Conda GitHub license Matrix Twitter Medium

Website | Install | Tutorial | Examples | Documentation | API Reference | Forum

CuPy is a NumPy/SciPy-compatible array library for GPU-accelerated computing with Python. CuPy acts as a drop-in replacement to run existing NumPy/SciPy code on NVIDIA CUDA or AMD ROCm platforms.

>>> import cupy as cp
>>> x = cp.arange(6).reshape(2, 3).astype('f')
>>> x
array([[ 0.,  1.,  2.],
       [ 3.,  4.,  5.]], dtype=float32)
>>> x.sum(axis=1)
array([  3.,  12.], dtype=float32)

CuPy also provides access to low-level CUDA features. You can pass ndarray to existing CUDA C/C++ programs via RawKernels, use Streams for performance, or even call CUDA Runtime APIs directly.

Installation

Pip

Binary packages (wheels) are available for Linux and Windows on PyPI. Choose the right package for your platform.

Platform Architecture Command
CUDA 12.x x86_64 / aarch64 pip install cupy-cuda12x
CUDA 13.x x86_64 / aarch64 pip install cupy-cuda13x
ROCm 7.0 (experimental) x86_64 pip install cupy-rocm-7-0

[!NOTE]
To install pre-releases, append --pre -U -f https://pip.cupy.dev/pre (e.g., pip install cupy-cuda12x --pre -U -f https://pip.cupy.dev/pre).

Conda

Binary packages are also available for Linux and Windows on Conda-Forge.

Platform Architecture Command
CUDA x86_64 / aarch64 / ppc64le conda install -c conda-forge cupy

If you need a slim installation (without also getting CUDA dependencies installed), you can do conda install -c conda-forge cupy-core.

If you need to use a particular CUDA version (say 12.0), you can use the cuda-version metapackage to select the version, e.g. conda install -c conda-forge cupy cuda-version=12.0.

[!NOTE]
If you encounter any problem with CuPy installed from conda-forge, please feel free to report to cupy-feedstock, and we will help investigate if it is just a packaging issue in conda-forge's recipe or a real issue in CuPy.

Docker

Use NVIDIA Container Toolkit to run CuPy container images.

$ docker run --gpus all -it cupy/cupy

Resources

[^1]: cuSignal is now part of CuPy starting v13.0.0.

License

MIT License (see LICENSE file).

CuPy is designed based on NumPy's API and SciPy's API (see docs/source/license.rst file).

CuPy is being developed and maintained by Preferred Networks and community contributors.

Reference

Ryosuke Okuta, Yuya Unno, Daisuke Nishino, Shohei Hido and Crissman Loomis. CuPy: A NumPy-Compatible Library for NVIDIA GPU Calculations. Proceedings of Workshop on Machine Learning Systems (LearningSys) in The Thirty-first Annual Conference on Neural Information Processing Systems (NIPS), (2017). [PDF]

@inproceedings{cupy_learningsys2017,
  author       = "Okuta, Ryosuke and Unno, Yuya and Nishino, Daisuke and Hido, Shohei and Loomis, Crissman",
  title        = "CuPy: A NumPy-Compatible Library for NVIDIA GPU Calculations",
  booktitle    = "Proceedings of Workshop on Machine Learning Systems (LearningSys) in The Thirty-first Annual Conference on Neural Information Processing Systems (NIPS)",
  year         = "2017",
  url          = "http://learningsys.org/nips17/assets/papers/paper_16.pdf"
}

cupy (cupy/cupy)

Searching Database…

12.4K ·GitHub
这是干什么的?CuPy 是一个与 NumPy/SciPy 兼容的数组库,用 Python 做 GPU 加速计算:你写的是普通的 Python 数组代码,但它会在 NVIDIA 或 AMD 的 GPU 上运行。
它能直接替换 NumPy,还是要学一套新的 API?它的定位就是直接替换:API 与 NumPy 和 SciPy 基本一致,现有的 NumPy/SciPy 代码不用重写,就能跑在 NVIDIA CUDA 或 AMD ROCm 上。
要真正跑起来需要什么条件?需要一块 GPU 以及配套的环境:要么是 NVIDIA GPU 加 CUDA 12.x 或 13.x,要么是 AMD GPU 加 ROCm 7.0。预编译的安装包支持 x86_64 和 aarch64 架构上的 Linux 和 Windows。
它在 AMD GPU 上也能用吗,还是只支持 NVIDIA?AMD 也能用,不过这条路还比较新:ROCm 7.0 版本(cupy-rocm-7-0,仅限 x86_64)官方明确标注为实验性,而 CUDA 12.x/13.x 的安装包才是主流选择。
我能在里面调用自己写的 CUDA C/C++ 代码吗?可以。你可以通过 RawKernels 把 ndarray 传给现有的 CUDA C/C++ 程序,用 Streams 提升性能,甚至直接调用 CUDA Runtime API。
它也带信号处理功能吗?带。从 v13.0.0 开始,cuSignal 已并入 CuPy,所以 GPU 加速的信号处理功能是随库本身一起提供的。
用 conda 的人需要注意什么?用 conda install -c conda-forge cupy 安装;如果想要不带 CUDA 依赖的精简安装,可以装 cupy-core,并通过元包把版本固定住,比如 cuda-version=12.0。
What are similar projects?DeepGEMM, taskflow, pytorch, tilelang, numba, dask, DeepEP, scipy
Creator
cupy
Size
47.8 MB
Stars
12.4K
Age
9y
Commits · 90 Days