sitecao
commited on
`DEVICE_COUNT` instead of `WORLD_SIZE` to calculate `nw` (#6324)
Browse files- utils/datasets.py +2 -2
utils/datasets.py
CHANGED
@@ -35,7 +35,7 @@ from utils.torch_utils import torch_distributed_zero_first
|
|
35 |
HELP_URL = 'https://github.com/ultralytics/yolov5/wiki/Train-Custom-Data'
|
36 |
IMG_FORMATS = ['bmp', 'jpg', 'jpeg', 'png', 'tif', 'tiff', 'dng', 'webp', 'mpo'] # acceptable image suffixes
|
37 |
VID_FORMATS = ['mov', 'avi', 'mp4', 'mpg', 'mpeg', 'm4v', 'wmv', 'mkv'] # acceptable video suffixes
|
38 |
-
|
39 |
|
40 |
# Get orientation exif tag
|
41 |
for orientation in ExifTags.TAGS.keys():
|
@@ -110,7 +110,7 @@ def create_dataloader(path, imgsz, batch_size, stride, single_cls=False, hyp=Non
|
|
110 |
prefix=prefix)
|
111 |
|
112 |
batch_size = min(batch_size, len(dataset))
|
113 |
-
nw = min([os.cpu_count() //
|
114 |
sampler = None if rank == -1 else distributed.DistributedSampler(dataset, shuffle=shuffle)
|
115 |
loader = DataLoader if image_weights else InfiniteDataLoader # only DataLoader allows for attribute updates
|
116 |
return loader(dataset,
|
|
|
35 |
HELP_URL = 'https://github.com/ultralytics/yolov5/wiki/Train-Custom-Data'
|
36 |
IMG_FORMATS = ['bmp', 'jpg', 'jpeg', 'png', 'tif', 'tiff', 'dng', 'webp', 'mpo'] # acceptable image suffixes
|
37 |
VID_FORMATS = ['mov', 'avi', 'mp4', 'mpg', 'mpeg', 'm4v', 'wmv', 'mkv'] # acceptable video suffixes
|
38 |
+
DEVICE_COUNT = max(torch.cuda.device_count(), 1)
|
39 |
|
40 |
# Get orientation exif tag
|
41 |
for orientation in ExifTags.TAGS.keys():
|
|
|
110 |
prefix=prefix)
|
111 |
|
112 |
batch_size = min(batch_size, len(dataset))
|
113 |
+
nw = min([os.cpu_count() // DEVICE_COUNT, batch_size if batch_size > 1 else 0, workers]) # number of workers
|
114 |
sampler = None if rank == -1 else distributed.DistributedSampler(dataset, shuffle=shuffle)
|
115 |
loader = DataLoader if image_weights else InfiniteDataLoader # only DataLoader allows for attribute updates
|
116 |
return loader(dataset,
|