From 26e3a28bee104c10501d92c64c94f21902add72c Mon Sep 17 00:00:00 2001 From: Francisco Reveriano <48685139+FranciscoReveriano@users.noreply.github.com> Date: Mon, 25 Nov 2019 03:21:36 -0500 Subject: [PATCH] Update train.py for distributive programming (#655) When attempting to running this function in a multi-GPU environment I kept on getting a runtime issue. I was able to solve this problem by passing this keyword. I first found the solution here: https://github.com/pytorch/pytorch/issues/22436 and in the pytorch tutorial 'RuntimeError: Expected to have finished reduction in the prior iteration before starting a new one. This error indicates that your module has parameters that were not used in producing loss. You can enable unused parameter detection by (1) passing the keyword argument find_unused_parameters=True to torch.nn.parallel.DistributedDataParallel; (2) making sure all forward function outputs participate in calculating loss. If you already have done the above two steps, then the distributed data parallel module wasn't able to locate the output tensors in the return value of your module's forward function. Please include the loss function and the structure of the return value of forward of your module when reporting this issue (e.g. list, dict, iterable). ' --- train.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/train.py b/train.py index 09eb70c3..9699cd2f 100644 --- a/train.py +++ b/train.py @@ -178,7 +178,7 @@ def train(): init_method='tcp://127.0.0.1:9999', # distributed training init method world_size=1, # number of nodes for distributed training rank=0) # distributed training node rank - model = torch.nn.parallel.DistributedDataParallel(model) + model = torch.nn.parallel.DistributedDataParallel(model, find_unused_parameters=True) model.yolo_layers = model.module.yolo_layers # move yolo layer indices to top level # Dataset