From 9bf7b7729708310ffb636bf2ba002feba0d0019b Mon Sep 17 00:00:00 2001 From: sbamopoulos <62857539+sbamopoulos@users.noreply.github.com> Date: Sat, 27 Jun 2026 14:51:54 +0200 Subject: [PATCH] Use mmap when loading new_labeling.npy during distributed relabeling. np.load without mmap_mode copies the full relabeling vector into each Dask worker for every tile. mmap_mode='r' reads only the pages needed per block, avoiding multi-GB RAM spikes on large whole-slide runs. Co-authored-by: Cursor --- cellpose/contrib/distributed_segmentation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cellpose/contrib/distributed_segmentation.py b/cellpose/contrib/distributed_segmentation.py index a504670a..80ff7aa6 100644 --- a/cellpose/contrib/distributed_segmentation.py +++ b/cellpose/contrib/distributed_segmentation.py @@ -774,7 +774,7 @@ class in this module. If you are running on the Janelia LSF cluster, see segmentation_da = dask.array.from_zarr(temp_zarr) relabeled = dask.array.map_blocks( - lambda block: np.load(new_labeling_path)[block], + lambda block: np.load(new_labeling_path, mmap_mode='r')[block], segmentation_da, dtype=np.uint32, chunks=segmentation_da.chunks,