From 2bc7744dd6c6110d8aee6135f674f03b2d0b8d5b Mon Sep 17 00:00:00 2001 From: Thomas Fish Date: Wed, 6 Nov 2024 11:46:49 +0000 Subject: [PATCH] Update pool creation --- src/sim_recon/recon.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sim_recon/recon.py b/src/sim_recon/recon.py index a2633d2..aa7d7f3 100644 --- a/src/sim_recon/recon.py +++ b/src/sim_recon/recon.py @@ -381,8 +381,11 @@ def run_single_reconstruction( ) -> None: if multiprocessing_pool is None: + # `maxtasksperchild=1` is necessary to ensure the child process is cleaned + # up between tasks, as the cudasirecon process doesn't fully release memory + # afterwards pool = multiprocessing.Pool( - processes=1 + int(parallel_process), # 2 processes max + processes=2 if parallel_process else 1, # 2 processes max maxtasksperchild=1, ) else: @@ -393,9 +396,6 @@ def run_single_reconstruction( logging_redirect = get_logging_redirect() progress_wrapper = get_progress_wrapper() - # `maxtasksperchild=1` is necessary to ensure the child process is cleaned - # up between tasks, as the cudasirecon process doesn't fully release memory - # afterwards with logging_redirect(), delete_directory_if_empty(processing_directory): output_paths: tuple[Path, ...] | None = None try: @@ -564,7 +564,7 @@ def run_reconstructions( # afterwards with ( multiprocessing.Pool( - processes=1 + int(parallel_process), # 2 processes max + processes=2 if parallel_process else 1, # 2 processes max maxtasksperchild=1, ) as pool, logging_redirect(),