Add `--sync-bn` known issue (#4032)
* Add `--sync-bn` known issue * Update train.py
This commit is contained in:
parent
b7e985e397
commit
951922c735
7
train.py
7
train.py
|
|
@ -217,6 +217,7 @@ def train(hyp, # path/to/hyp.yaml or hyp dictionary
|
||||||
|
|
||||||
# SyncBatchNorm
|
# SyncBatchNorm
|
||||||
if opt.sync_bn and cuda and RANK != -1:
|
if opt.sync_bn and cuda and RANK != -1:
|
||||||
|
raise Exception('can not train with --sync-bn, known issue https://github.com/ultralytics/yolov5/issues/3998')
|
||||||
model = torch.nn.SyncBatchNorm.convert_sync_batchnorm(model).to(device)
|
model = torch.nn.SyncBatchNorm.convert_sync_batchnorm(model).to(device)
|
||||||
logger.info('Using SyncBatchNorm()')
|
logger.info('Using SyncBatchNorm()')
|
||||||
|
|
||||||
|
|
@ -232,9 +233,9 @@ def train(hyp, # path/to/hyp.yaml or hyp dictionary
|
||||||
# Process 0
|
# Process 0
|
||||||
if RANK in [-1, 0]:
|
if RANK in [-1, 0]:
|
||||||
valloader = create_dataloader(val_path, imgsz_val, batch_size // WORLD_SIZE * 2, gs, single_cls,
|
valloader = create_dataloader(val_path, imgsz_val, batch_size // WORLD_SIZE * 2, gs, single_cls,
|
||||||
hyp=hyp, cache=opt.cache_images and not noval, rect=True, rank=-1,
|
hyp=hyp, cache=opt.cache_images and not noval, rect=True, rank=-1,
|
||||||
workers=workers,
|
workers=workers,
|
||||||
pad=0.5, prefix=colorstr('val: '))[0]
|
pad=0.5, prefix=colorstr('val: '))[0]
|
||||||
|
|
||||||
if not resume:
|
if not resume:
|
||||||
labels = np.concatenate(dataset.labels, 0)
|
labels = np.concatenate(dataset.labels, 0)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue