glenn-jocher
commited on
Commit
•
1ff4370
1
Parent(s):
6769021
Validate with 2x `--workers` single-GPU/CPU fix (#6659)
Browse files- utils/datasets.py +1 -1
utils/datasets.py
CHANGED
@@ -110,7 +110,7 @@ def create_dataloader(path, imgsz, batch_size, stride, single_cls=False, hyp=Non
|
|
110 |
|
111 |
batch_size = min(batch_size, len(dataset))
|
112 |
nd = torch.cuda.device_count() # number of CUDA devices
|
113 |
-
nw = min([
|
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,
|
|
|
110 |
|
111 |
batch_size = min(batch_size, len(dataset))
|
112 |
nd = torch.cuda.device_count() # number of CUDA devices
|
113 |
+
nw = min([os.cpu_count() // max(nd / 2, 1), 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,
|