Skip to content

Commit

Permalink
enh: run set_num_interop_threads(1) for torchmpo segmenter
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Jun 14, 2024
1 parent 002003e commit e517464
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/dcnum/segm/segm_torch/segm_torch_mpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ def segment_algorithm(image, *,
# Set number of pytorch threads to 1, because dcnum is doing
# all the multiprocessing.
# https://pytorch.org/docs/stable/generated/torch.set_num_threads.html#torch.set_num_threads
torch.set_num_threads(1)
torch.set_num_interop_threads(1)
if torch.get_num_threads() != 1:
torch.set_num_threads(1)
if torch.get_num_interop_threads() != 1:
torch.set_num_interop_threads(1)
device = torch.device("cpu")

# Load model and metadata
Expand Down

0 comments on commit e517464

Please sign in to comment.