Fix missing model.stride in DP and DDP mode (#683)
parent
a0ac5adb7b
commit
3d8ed0a76b
8
train.py
8
train.py
|
@ -123,6 +123,10 @@ def train(hyp, opt, device, tb_writer=None):
|
|||
epochs += ckpt['epoch'] # finetune additional epochs
|
||||
|
||||
del ckpt, state_dict
|
||||
|
||||
# Image sizes
|
||||
gs = int(max(model.stride)) # grid size (max stride)
|
||||
imgsz, imgsz_test = [check_img_size(x, gs) for x in opt.img_size] # verify imgsz are gs-multiples
|
||||
|
||||
# DP mode
|
||||
if cuda and rank == -1 and torch.cuda.device_count() > 1:
|
||||
|
@ -140,10 +144,6 @@ def train(hyp, opt, device, tb_writer=None):
|
|||
if cuda and rank != -1:
|
||||
model = DDP(model, device_ids=[opt.local_rank], output_device=(opt.local_rank))
|
||||
|
||||
# Image sizes
|
||||
gs = int(max(model.stride)) # grid size (max stride)
|
||||
imgsz, imgsz_test = [check_img_size(x, gs) for x in opt.img_size] # verify imgsz are gs-multiples
|
||||
|
||||
# Trainloader
|
||||
dataloader, dataset = create_dataloader(train_path, imgsz, batch_size, gs, opt, hyp=hyp, augment=True,
|
||||
cache=opt.cache_images, rect=opt.rect, local_rank=rank,
|
||||
|
|
Loading…
Reference in New Issue