Skip to content

Commit 8a1ef97

Browse files
committed
docs: πŸ“ document dilate_gpu (GPU dilation on the cluster)
Explains dilate_gpu: true, its cupy + GPU-allocation requirements, and that it's independent of whatever method itself runs on.
1 parent 9a63544 commit 8a1ef97

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

β€Ždocs/guide/custom_segmentation.mdβ€Ž

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ tiles are merged, so `overlap` must still cover the dilation amount. On the
7474
cluster, set `dilate: N` in the config instead β€” see [Configure the
7575
run](snakemake.md#3-configure-the-run).
7676

77+
By default the dilation itself runs on CPU (scipy), independent of whatever
78+
backend `fn` used β€” pass `use_gpu=True` to dilate via cupy instead:
79+
80+
```python
81+
fn = dilate_labels(fn, iterations=2, use_gpu=True) # needs cupy installed
82+
```
83+
84+
On the cluster, this is the `dilate_gpu: true` config key.
85+
7786
## Real example: StarDist 3-D, with model caching
7887

7988
Heavy models must be loaded **once**, not per tile. On SLURM each tile is its

β€Ždocs/guide/snakemake.mdβ€Ž

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ empty_threshold: null # null β†’ Otsu
6565
method: "cellpose" # "cellpose" (GPU), "threshold" (no GPU), "custom"
6666
label_name: "cellpose" # name under image.zarr/labels/
6767
dilate: 0 # optional: pixels to grow labels by, any method
68+
dilate_gpu: false # dilate via cupy instead of scipy (needs a GPU)
6869
cellpose:
6970
model: "cyto3"
7071
diameter: 30
@@ -80,8 +81,15 @@ sequential_labels: true # renumber labels to a contiguous 1..N
8081
8182
!!! tip "Growing labels after segmentation"
8283
`dilate: N` grows every label by `N` pixels once segmentation finishes,
83-
regardless of `method`. `0` (default) disables it. See [Growing labels
84-
afterwards](custom_segmentation.md#growing-labels-afterwards-dilation)
84+
regardless of `method`. `0` (default) disables it. Runs on CPU (scipy)
85+
by default; set `dilate_gpu: true` to dilate via cupy instead β€” that
86+
needs `cupy` installed in the segment job's environment (matching your
87+
CUDA version, e.g. `pip install cupy-cuda12x`) and a GPU allocated for
88+
that job (`set-resources: segment:` in `profile/slurm/config.yaml`,
89+
same as for a GPU `method`). It's independent of whatever `method`
90+
itself runs on β€” you can dilate on GPU even with `method: "threshold"`
91+
(CPU), or on CPU even with `method: "cellpose"` (GPU). See [Growing
92+
labels afterwards](custom_segmentation.md#growing-labels-afterwards-dilation)
8593
for how it works and the equivalent direct-API call.
8694

8795
!!! tip "Tile size vs runtime"

0 commit comments

Comments
Β (0)