Skip to content

Commit 5afc2c9

Browse files
authored
Merge pull request #477 from zivy/stabilizeParallelization
Set ITK to be single threaded in the characterize_data script.
2 parents 7ab41da + 315c76d commit 5afc2c9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Python/scripts/characterize_data.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,14 @@ def xyz_to_index(x, y, z, thumbnail_size, tile_size):
10491049
)
10501050
return 1
10511051

1052+
# This script uses concurrent.futures ProcessPoolExecutor for parallel processing at
1053+
# the process level. ITK filters implement concurrency at the thread level.
1054+
# The combination of these two parallelization approaches can potentially be
1055+
# detrimental, as each of N processes creates M threads which can overwhelm a
1056+
# system if it has less than NM cores. We therefor configure SimpleITK to work
1057+
# in a single threaded fashion and only use process level parallelization.
1058+
sitk.ProcessObject.SetGlobalDefaultNumberOfThreads(1)
1059+
10521060
thumbnail_settings = {}
10531061
if args.create_summary_image:
10541062
thumbnail_settings["thumbnail_sizes"] = args.thumbnail_sizes

0 commit comments

Comments
 (0)