glenn-jocher
commited on
Commit
•
c43f135
1
Parent(s):
4de8b24
Update `nw` to `max(nd, 1)` (#6714)
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([os.cpu_count() // max(nd
|
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, 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,
|