From 1e6c4544603cc53bf3b5297b3cfb931a81f4839e Mon Sep 17 00:00:00 2001 From: Burhan <62214284+Burhan-Q@users.noreply.github.com> Date: Tue, 8 Oct 2024 14:58:48 -0400 Subject: [PATCH] Respect ENV value for `OMP_NUM_THREADS` if set (#16751) Co-authored-by: UltralyticsAssistant Co-authored-by: Glenn Jocher --- ultralytics/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ultralytics/__init__.py b/ultralytics/__init__.py index 7ecb2c05af..c37bed0752 100644 --- a/ultralytics/__init__.py +++ b/ultralytics/__init__.py @@ -4,8 +4,9 @@ __version__ = "8.3.7" import os -# Set ENV Variables (place before imports) -os.environ["OMP_NUM_THREADS"] = "1" # reduce CPU utilization during training +# Set ENV variables (place before imports) +if not os.environ.get("OMP_NUM_THREADS"): + os.environ["OMP_NUM_THREADS"] = "1" # default for reduced CPU utilization during training from ultralytics.data.explorer.explorer import Explorer from ultralytics.models import NAS, RTDETR, SAM, YOLO, FastSAM, YOLOWorld