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). '
This commit is contained in:
parent
a0ef217842
commit
26e3a28bee
2
train.py
2
train.py
|
@ -178,7 +178,7 @@ def train():
|
||||||
init_method='tcp://127.0.0.1:9999', # distributed training init method
|
init_method='tcp://127.0.0.1:9999', # distributed training init method
|
||||||
world_size=1, # number of nodes for distributed training
|
world_size=1, # number of nodes for distributed training
|
||||||
rank=0) # distributed training node rank
|
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
|
model.yolo_layers = model.module.yolo_layers # move yolo layer indices to top level
|
||||||
|
|
||||||
# Dataset
|
# Dataset
|
||||||
|
|
Loading…
Reference in New Issue