Validate with 2x `--workers` (#6658)
This commit is contained in:
parent
ee6c70ae43
commit
6769021901
2
train.py
2
train.py
|
|
@ -232,7 +232,7 @@ def train(hyp, # path/to/hyp.yaml or hyp dictionary
|
||||||
if RANK in [-1, 0]:
|
if RANK in [-1, 0]:
|
||||||
val_loader = create_dataloader(val_path, imgsz, batch_size // WORLD_SIZE * 2, gs, single_cls,
|
val_loader = create_dataloader(val_path, imgsz, batch_size // WORLD_SIZE * 2, gs, single_cls,
|
||||||
hyp=hyp, cache=None if noval else opt.cache, rect=True, rank=-1,
|
hyp=hyp, cache=None if noval else opt.cache, rect=True, rank=-1,
|
||||||
workers=workers, pad=0.5,
|
workers=workers * 2, pad=0.5,
|
||||||
prefix=colorstr('val: '))[0]
|
prefix=colorstr('val: '))[0]
|
||||||
|
|
||||||
if not resume:
|
if not resume:
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ def create_dataloader(path, imgsz, batch_size, stride, single_cls=False, hyp=Non
|
||||||
|
|
||||||
batch_size = min(batch_size, len(dataset))
|
batch_size = min(batch_size, len(dataset))
|
||||||
nd = torch.cuda.device_count() # number of CUDA devices
|
nd = torch.cuda.device_count() # number of CUDA devices
|
||||||
nw = min([os.cpu_count() // max(nd, 1), batch_size if batch_size > 1 else 0, workers]) # number of workers
|
nw = min([2 * os.cpu_count() // max(nd, 1), batch_size if batch_size > 1 else 0, workers]) # number of workers
|
||||||
sampler = None if rank == -1 else distributed.DistributedSampler(dataset, shuffle=shuffle)
|
sampler = None if rank == -1 else distributed.DistributedSampler(dataset, shuffle=shuffle)
|
||||||
loader = DataLoader if image_weights else InfiniteDataLoader # only DataLoader allows for attribute updates
|
loader = DataLoader if image_weights else InfiniteDataLoader # only DataLoader allows for attribute updates
|
||||||
return loader(dataset,
|
return loader(dataset,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue