Skip to content

Commit 5c82022

Browse files
committed
trying to fix mem alloc of torch
1 parent 9fe219d commit 5c82022

File tree

5 files changed

+9
-3
lines changed

5 files changed

+9
-3
lines changed

docs/res/welcome.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Then go into Plugins > napari-cellseg3d, and choose which tool to use.
6868
- **Train**: This module allows you to train segmentation algorithms from labeled volumes.
6969
- **Utilities**: This module allows you to use several utilities, e.g. to crop your volumes and labels, compute prediction scores or convert labels
7070

71+
See above for links to detailed guides regarding the usage of the modules.
7172

7273
Credits & acknowledgments
7374
---------------------------------------------

src/napari_cellseg3d/model_workers.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ def inference(self):
184184

185185
images_dict = self.create_inference_dict(self.images_filepaths)
186186

187+
if self.device =="cuda": # TODO : fix mem alloc
188+
torch.backends.cudnn.benchmark = False
189+
187190
# TODO : better solution than loading first image always ?
188191
data_check = LoadImaged(keys=["image"])(images_dict[0])
189192
# print(data)
@@ -284,6 +287,8 @@ def inference(self):
284287
)
285288

286289
out = outputs.detach().cpu()
290+
# del outputs # TODO fix memory ?
291+
# outputs = None
287292

288293
if self.transforms["zoom"][0]:
289294
zoom = self.transforms["zoom"][1]

src/napari_cellseg3d/plugin_model_inference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def __init__(self, viewer: "napari.viewer.Viewer"):
107107
)
108108

109109
self.aniso_box_widgets = ui.make_n_spinboxes(
110-
n=3, min=1.0, default=1.5, step=0.5, double=True
110+
n=3, min=1.0, max=1000, default=1.5, step=0.5, double=True
111111
)
112112
self.aniso_box_lbl = [
113113
QLabel("Resolution in " + axis + " (microns) :") for axis in "xyz"

src/napari_cellseg3d/plugin_model_training.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ def start(self):
706706
707707
TODO:
708708
709-
* Fix memory leak
709+
* Fix memory allocation from torch
710710
711711
712712
Returns: Returns empty immediately if the file paths are not set correctly.

src/napari_cellseg3d/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def get_padding_dim(image_shape, anisotropy_factor=None):
146146
pad = -1
147147
size = image_shape[i]
148148
if anisotropy_factor is not None:
149-
# TODO : GOING TO CAUSE ISSUES WITH CERTAIN ANISOTROPY FACTORS
149+
# problems with zero divs avoided via params for spinboxes
150150
size = int(size / anisotropy_factor[i])
151151
while pad < size:
152152
pad = 2**n

0 commit comments

Comments
 (0)