Skip to content

feat(cellpose): update to v4.0.8 with GPU support#10306

Open
an-altosian wants to merge 10 commits intonf-core:masterfrom
an-altosian:feat/cellpose-v4-gpu
Open

feat(cellpose): update to v4.0.8 with GPU support#10306
an-altosian wants to merge 10 commits intonf-core:masterfrom
an-altosian:feat/cellpose-v4-gpu

Conversation

@an-altosian
Copy link
Contributor

@an-altosian an-altosian commented Mar 2, 2026

Summary

  • Upgrade cellpose from 3.1.0 to 4.0.8 (includes Cellpose-SAM integration)
  • Replace biocontainers/cellpose:3.1.0_cv1 with GPU-enabled dongzehe/cellpose-gpu:4.0.8
  • Add GPU support via process_gpu label and task.ext.use_gpu flag
  • Change model input from path to val (pretrained model name string)
  • Add cells output (*seg.npy) for downstream analysis
  • Outputs moved to ${prefix}/ directory for consistency
  • Add Dockerfile for reproducible container builds

Changes

File Change
main.nf Upgrade to v4.0.8, GPU container, val model input, task.ext.use_gpu, cells output
meta.yml Match new interface: model as val string, add cells output
Dockerfile New: GPU container based on pytorch/pytorch:2.5.1-cuda12.4-cudnn9-runtime
tests/main.nf.test Update inputs for new interface
tests/main.nf.test.snap Updated snapshots for v4.0.8 outputs

Container

dongzehe/cellpose-gpu:4.0.8 (hosted on quay.io, public)

  • Base: pytorch/pytorch:2.5.1-cuda12.4-cudnn9-runtime
  • Packages: cellpose==4.0.8, numpy, scipy, matplotlib, scikit-image, opencv-python-headless
  • Falls back to CPU automatically when no GPU is available

GPU control

withName: 'CELLPOSE' {
    ext.use_gpu = true  // passes --use_gpu to cellpose CLI
}

When task.ext.use_gpu is not set or false, cellpose runs on CPU only.

Usage

CELLPOSE(
    ch_images,      // tuple val(meta), path(image)
    "cyto3"         // model name: 'cyto3', 'nuclei', 'CPSAM', or ''
)

Licensing

  • Cellpose: BSD-3-Clause
  • SAM (segment_anything): Apache 2.0
  • Model weights NOT bundled (downloaded at runtime)

🤖 Generated with Claude Code

- Upgrade cellpose from 3.1.0 to 4.0.8 (includes SAM integration)
- Replace private container with public quay.io/dongzehe/cellpose-gpu:4.0.8
- Add GPU support (process_gpu label, --use_gpu flag via task.ext.use_gpu)
- Change model input from path to val (pretrained model name string)
- Add maskname input for custom output filenames
- Add cells output (seg.npy) for downstream analysis
- Add Dockerfile for reproducible GPU container builds
- Add environment.yml for conda channel reference
- Update meta.yml to match new interface

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@an-altosian
Copy link
Contributor Author

Hi there, I saw that the cellpose module was updated three weeks ago but is still on cellpose 3. Here is a draft of updating it to cellpose v4 with GPU support, which has its cellpose-SAM based model compatibility. It works great on my side.

an-altosian and others added 4 commits March 2, 2026 21:50
- Remove environment.yml (module refuses conda, not in upstream)
- Remove maskname input (xenium-specific)
- Fix meta.yml: use non-tuple syntax for val inputs
- Update nf-test: provide model input as string
- Move outputs to ${prefix}/ with standard cellpose names
- Remove GPU detection logging and NPY_PROMOTION_STATE

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
nf-core lint auto-prepends quay.io/ for simple org/container:tag format.
Explicit quay.io/ prefix triggers lint failure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Mask and versions.yml md5 hashes differ from cellpose 3.1.0.
Updated from CI docker test output.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add notes section to meta.yml: GPU usage, ext.args, model weights
- Expand model input description with built-in model names
- Add inline comments for env vars (HOME/MPLCONFIGDIR required by container)
- Update nf-test snapshots (nf-test 0.9.3 metadata)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@an-altosian an-altosian marked this pull request as ready for review March 2, 2026 23:20
an-altosian and others added 4 commits March 3, 2026 00:15
val model doesn't stage files into the work directory, breaking custom
model support in containerized/cloud environments. Revert to path(model)
matching upstream interface. Pretrained model names go via ext.args.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Change model input to tuple val(model_name), path(model_path):
- Custom model file: ["", file("/path/to/model")] — staged by Nextflow
- Pretrained name: ["cyto3", file("NO_FILE")] — downloaded at runtime
- Default: ["", file("NO_FILE")] — no --pretrained_model flag

model_path takes priority over model_name when both are provided.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use empty list [] instead of file("NO_FILE") for the optional model_path
input, following the nf-core standard for optional path inputs in tuples.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add fixOwnership to the docker profile and remove the redundant
docker_self_hosted profile.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@an-altosian an-altosian requested review from a team as code owners March 3, 2026 00:44
@an-altosian an-altosian marked this pull request as draft March 3, 2026 00:54
@DongzeHE DongzeHE removed the request for review from a team March 3, 2026 04:17
@DongzeHE DongzeHE marked this pull request as ready for review March 3, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants