glenn-jocher commited on
Commit
8df64a9
·
unverified ·
1 Parent(s): 562191f

`NUM_THREADS` leave at least 1 CPU free (#5706)

Browse files

Updated strategy leaves at least 1 cpu free to avoid system overloads. Partially addresses https://github.com/ultralytics/yolov5/issues/5685

Files changed (1) hide show
  1. utils/datasets.py +1 -1
utils/datasets.py CHANGED
@@ -35,7 +35,7 @@ HELP_URL = 'https://github.com/ultralytics/yolov5/wiki/Train-Custom-Data'
35
  IMG_FORMATS = ['bmp', 'jpg', 'jpeg', 'png', 'tif', 'tiff', 'dng', 'webp', 'mpo'] # acceptable image suffixes
36
  VID_FORMATS = ['mov', 'avi', 'mp4', 'mpg', 'mpeg', 'm4v', 'wmv', 'mkv'] # acceptable video suffixes
37
  WORLD_SIZE = int(os.getenv('WORLD_SIZE', 1)) # DPP
38
- NUM_THREADS = min(8, os.cpu_count()) # number of multiprocessing threads
39
 
40
  # Get orientation exif tag
41
  for orientation in ExifTags.TAGS.keys():
 
35
  IMG_FORMATS = ['bmp', 'jpg', 'jpeg', 'png', 'tif', 'tiff', 'dng', 'webp', 'mpo'] # acceptable image suffixes
36
  VID_FORMATS = ['mov', 'avi', 'mp4', 'mpg', 'mpeg', 'm4v', 'wmv', 'mkv'] # acceptable video suffixes
37
  WORLD_SIZE = int(os.getenv('WORLD_SIZE', 1)) # DPP
38
+ NUM_THREADS = min(8, max(1, os.cpu_count() - 1)) # number of multiprocessing threads
39
 
40
  # Get orientation exif tag
41
  for orientation in ExifTags.TAGS.keys():