Skip to content

Commit 21cbeda

Browse files
Shizoquaericspod
andauthored
Clarify CUDA/CuPy install requirements in docs (#8106) (#8983)
Fixes #8106 ### Description The installation docs did not make it clear that some MONAI transforms require CuPy for GPU-accelerated array operations. Users who ran GPU inference hit `OptionalImportError: import cupy (No module named 'cupy')` with no obvious guidance — `pip install cupy` fails because the real package is CUDA-version specific (`cupy-cuda12x`), and it was not documented that the `cucim` extra provides CuPy. This PR updates `docs/source/installation.md` to: - Promote the GPU/CUDA setup steps into their own `## GPU-enabled installation (CUDA and CuPy)` section (with a Table of Contents entry) instead of an unlabeled paragraph. - Explain that some transforms use CuPy (e.g. via `convert_to_cupy`), what error appears when it is missing, and that CuPy is installed through the `cucim` extra (`pip install 'monai[cucim]'`). - Note that installing CuPy directly requires the CUDA-specific package name (`cupy-cuda12x` / `cupy-cuda11x`), linking to the CuPy installation guide. - Add a cross-reference from the recommended-dependencies list. Docs-only change; no code or public API is modified. ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [x] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: Lanre Shittu <136805224+Shizoqua@users.noreply.github.com> Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
1 parent aca533a commit 21cbeda

1 file changed

Lines changed: 30 additions & 5 deletions

File tree

docs/source/installation.md

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- [Installation Guide](#installation-guide)
66
- [Table of Contents](#table-of-contents)
7+
- [GPU-enabled installation (CUDA and CuPy)](#gpu-enabled-installation-cuda-and-cupy)
78
- [From PyPI](#from-pypi)
89
- [Milestone release](#milestone-release)
910
- [Weekly preview release](#weekly-preview-release)
@@ -30,12 +31,36 @@ Ignite](https://pytorch.org/ignite/), please follow the instructions:
3031

3132
- [Installing the recommended dependencies](#installing-the-recommended-dependencies)
3233

33-
The installation commands below usually end up installing CPU variant of PyTorch. To install GPU-enabled PyTorch:
34+
---
35+
36+
## GPU-enabled installation (CUDA and CuPy)
37+
38+
The installation commands below usually end up installing the CPU variant of PyTorch. To install GPU-enabled PyTorch:
3439

3540
1. Install the latest NVIDIA driver.
36-
1. Check [PyTorch Official Guide](https://pytorch.org/get-started/locally/) for the recommended CUDA versions. For Pip package, the user needs to download the CUDA manually, install it on the system, and ensure CUDA_PATH is set properly.
41+
1. Check the [PyTorch Official Guide](https://pytorch.org/get-started/locally/) for the recommended CUDA versions. For Pip packages, PyTorch wheels already bundle the CUDA runtime, so you only need to pick the CUDA version matching your driver from the selector and install with the provided command. You do not need to manually download CUDA or set `CUDA_PATH`.
3742
1. Continue to follow the guide and install PyTorch.
38-
1. Install MONAI using one the ways described below.
43+
1. Install MONAI using one of the ways described below.
44+
45+
Installing GPU-enabled PyTorch is enough to run models and transforms on the GPU. Some transforms,
46+
however, additionally use [CuPy](https://cupy.dev/) for GPU-accelerated array operations (for example
47+
when a transform converts a CUDA tensor via `convert_to_cupy`). If CuPy is not installed, these code
48+
paths raise `OptionalImportError: import cupy (No module named 'cupy')`.
49+
50+
MONAI provides a dedicated `cupy` extra that installs a compatible CuPy build:
51+
52+
```bash
53+
pip install 'monai[cupy]'
54+
```
55+
56+
The `cucim` extra installs [cuCIM](https://github.com/rapidsai/cucim) (`cucim-cu12` or `cucim-cu13`
57+
depending on your Python version), which is a separate GPU image-processing library and does not
58+
install CuPy.
59+
60+
If you prefer to install CuPy directly, note that the PyPI package name is CUDA-version specific
61+
(e.g. `cupy-cuda12x` for CUDA 12.x, `cupy-cuda13x` for CUDA 13.x) rather than plain `cupy`. See the
62+
[CuPy installation guide](https://docs.cupy.dev/en/stable/install.html) for the correct package for
63+
your CUDA toolkit.
3964

4065
---
4166

@@ -184,7 +209,7 @@ You can install it by running:
184209
```bash
185210
cd MONAI/
186211
pip install -e .
187-
# or pip install -e .[all,testing] to include most of the dependencies
212+
# or pip install -e '.[all,testing]' to include most of the dependencies
188213
```
189214

190215
or, to build with MONAI C++/CUDA extensions and install:
@@ -212,7 +237,7 @@ $env:BUILD_MONAI="1"
212237
pip install -e .
213238
```
214239

215-
If the compiled extensions were built by pip against a different version of PyTorch than the one in your environment, you may need to run the above with the `--no-build-isoloation` flag to force the use of that version, or use the `--build-constraint` method.
240+
If the compiled extensions were built by pip against a different version of PyTorch than the one in your environment, you may need to run the above with the `--no-build-isolation` flag to force the use of that version, or use the `--build-constraint` method.
216241

217242
To uninstall the package please run:
218243

0 commit comments

Comments
 (0)