Repository navigation
feat: cuda12/cuda13 extras that install CuPy and cuCIM with the CUDA runtime - #60
Conversation
pip and uv still cannot pick a CuPy build for the installed driver, so GPU users had to find the right cupy-cudaXXx and cucim-cuXX wheels and a matching CUDA Toolkit themselves. The extras pull both packages for one CUDA major version, with CuPy's [ctk] extra supplying the CUDA runtime and NVRTC from PyPI, so only the driver is needed. They are declared conflicting for uv and kept out of `all`. The README replaces the stale "CUDA>=11.x" requirement; CuPy 14 ships wheels for CUDA 12 and 13 only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011hEQ1TZJUbmhYKcC14RYHT
The CPU-fallback warning gave no install hint, and the cuCIM ImportError pointed to "the GPU extras", which did not exist until now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011hEQ1TZJUbmhYKcC14RYHT
[tool.uv] conflicts is read by uv alone; pip installs both extras when asked. Also drops the closing CPU-fallback sentence, which repeated the [optional] marker in the dependency list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011hEQ1TZJUbmhYKcC14RYHT
Reviewer's GuideAdds CUDA 12 and CUDA 13 extras that install matching CuPy/cuCIM packages together with CUDA runtime libraries, uses uv conflict metadata to keep the alternatives separate, updates the lockfile, and documents the driver-only GPU setup with clearer missing-dependency guidance. Flow diagram for selecting CUDA extrasflowchart TD
Start[Choose highest CUDA major version supported by nvidia-smi] --> CUDA12{CUDA 12.x?}
CUDA12 -->|Yes| Install12["Install cubic[cuda12]"]
CUDA12 -->|No| CUDA13{CUDA 13.x?}
CUDA13 -->|Yes| Install13["Install cubic[cuda13]"]
CUDA13 -->|No| Alternative[Use conda for CUDA-aware dependency selection]
Install12 --> Driver[Only NVIDIA driver required]
Install13 --> Driver
Install12 --> GPU[CuPy and cuCIM GPU support]
Install13 --> GPU
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The installation documentation omits that the cuCIM-based extras are Linux-only.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Adds CUDA 12/13 installation extras with bundled runtime dependencies and clearer GPU setup guidance.
Changes:
- Adds mutually exclusive
cuda12andcuda13extras. - Updates lockfile dependencies and GPU-related messages.
- Documents CUDA installation options.
| File | Description |
|---|---|
pyproject.toml |
Defines CUDA extras and uv conflicts. |
uv.lock |
Locks CuPy, cuCIM, and CUDA runtime packages. |
README.md |
Documents GPU installation. |
cubic/cuda.py |
Improves CPU-fallback guidance. |
cubic/segmentation/segment_utils.py |
Updates missing-cuCIM errors. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="pyproject.toml" line_range="68" />
<code_context>
+# driver is needed. Not part of `all`, since the two are mutually exclusive.
+cuda12 = [
+ "cupy-cuda12x[ctk]",
+ "cucim-cu12",
+]
+cuda13 = [
</code_context>
<issue_to_address>
**Windows GPU installs fail**
When a Windows user installs either CUDA extra, the `cucim-cu12` and `cucim-cu13` distributions have no compatible Windows wheels, so pip or uv cannot resolve the extra and the documented GPU install fails.
Provide Windows-compatible cuCIM distributions or make the Windows limitation explicit and adjust the extras so installation does not fail.
Also at `pyproject.toml:72`, `README.md:32-37`.
</issue_to_address>
### Comment 2
<location path="pyproject.toml" line_range="84" />
<code_context>
+[tool.uv]
+conflicts = [
+ [{ extra = "cuda12" }, { extra = "cuda13" }],
+]
+
</code_context>
<issue_to_address>
**All-extras sync is rejected**
When a user runs `uv sync --all-extras`, uv selects both CUDA extras, and `[tool.uv].conflicts` rejects the sync, so the environment is not created.
Change the extras and uv configuration so `uv sync --all-extras` can resolve both CUDA variants.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 2 findings to address first, and the new extras install large third-party CuPy, cuCIM, and CUDA runtime dependency trees, so an incorrect resolution can leave incompatible packages or CUDA libraries in a user's environment after the PR is reverted. This is bounded and repairable by uninstalling the extras or recreating the environment; no application data or irreversible external action is changed.
Blocking findings: pyproject.toml:68, pyproject.toml:84
Without a floor, an environment pinned to numpy<2 resolved cupy-cuda12x 13.6.0, which has no [ctk] extra: pip and uv only warn and install no CUDA libraries, so the first kernel compile fails. With the floor the resolution fails up front instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011hEQ1TZJUbmhYKcC14RYHT
…ssages The CPU-fallback warning and both cuCIM ImportErrors spelled out the extras separately; the earlier "GPU extras" wording went stale that way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011hEQ1TZJUbmhYKcC14RYHT
CuPy raises ImportError when it is installed but cannot load its CUDA libraries, and cuCIM when a dependency is missing, so "not installed" was wrong in those cases and the install hint useless. The warning now quotes the original error; the test forces a failed cupy import. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011hEQ1TZJUbmhYKcC14RYHT
CUDA 13 dropped Maxwell, Pascal and Volta (compute capability < 7.5), so a V100 on a 580 driver reports CUDA 13 yet needs cuda12. cuCIM publishes Linux wheels only, and an existing cupy-cuda* package in the environment clashes with the one an extra installs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011hEQ1TZJUbmhYKcC14RYHT
`.[all]` was labelled "install everything" but leaves out the GPU extras, which cannot be combined. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011hEQ1TZJUbmhYKcC14RYHT

Summary
GPU users currently have to pick the right
cupy-cudaXXxandcucim-cuXXwheels and install a matching CUDA Toolkit by hand. This PR adds two extras so the choice is one word:[ctk]extra pulls the CUDA runtime, NVRTC, cuBLAS, cuFFT etc. from PyPI, so only the NVIDIA driver is needed.[tool.uv] conflicts, souv lockresolves them in separate forks. Because they cannot be installed together,uv sync --all-extrasnow errors ("Extrascuda12andcuda13are incompatible with the declared conflicts"); name extras explicitly instead. CI uses--extra dev/--extra examplesand is unaffected. Neither extra is part ofall.[ctk]. Without the floor, a numpy<2 environment resolved cupy-cuda12x 13.6.0, which only warns about the missing extra and installs no CUDA libraries.cuda12even on a CUDA 13 driver. The README says both.cucim-cu1x26.2.1, the last release with cp310 wheels; on 3.11+ it resolves 26.8.0.ImportErrors share one install hint naming the extras (the latter pointed to "the GPU extras", which did not exist). The warning now quotes the original import error, since CuPy also raisesImportErrorwhen it is installed but cannot load its CUDA libraries.Why not auto-detect
Checked 2026-10-06:
pip install cupyis still a source build:cupy14.2.0 on PyPI is an sdist only.--torch-backend=autodetects the driver but covers PyTorch packages only, and only inuv pip(astral-sh/uv#16522 is open).Lockfile
uv.lockonly gains packages. A name/version diff of the old and new lock shows no existing package version removed or changed. The CPU CI (uv sync --extra dev) does not install any of them.Testing
On a GPU node (RTX A6000, driver 580.126.20, no
nvccand noLD_LIBRARY_PATH/CUDA_PATH/CUDA_HOME), each extra was installed from the lock into a fresh Python 3.12 env withuv sync --frozen --extra <cudaXX> --extra dev. For each env, a RawKernel was compiled and run, and the GPU-relevant tests were run (tests/test_cuda.py,test_scipy_proxy.py,test_skimage_proxy.py,tests/segmentation,tests/metrics):None of the skips is "GPU not available". All are optional packages missing from these envs (torch, torchmetrics, itk, cellpose). The GPU run used 65d19c8. The later commits add the CuPy floor (same resolved versions: cupy 14.2.0) and change only messages, the README and a new warning test.
🤖 Generated with Claude Code
https://claude.ai/code/session_011hEQ1TZJUbmhYKcC14RYHT
Summary by Sourcery
Provide streamlined CUDA 12 and CUDA 13 installation options with bundled runtime dependencies and clearer GPU setup guidance.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests: