I am trying to train efficientdet to predict bounding boxes without classes. My code:
.model = create_model(
model_name,
bench_task='train',
num_classes=num_classes,
pretrained=True,
pretrained_backbone=True,
bench_labeler=True,
checkpoint_path = '',
)
model = torch.nn.SyncBatchNorm.convert_sync_batchnorm(model)
...
torch.cuda.set_device(rank)
torch.distributed.init_process_group(backend='nccl', init_method='file://'+ddp_init_file, world_size=world_size, rank=rank)
model = model.cuda(rank)
model = torch.nn.parallel.DistributedDataParallel(model, device_ids=[rank], output_device=rank, find_unused_parameters=True)
...
loss = outputs['loss']
class_loss = outputs['class_loss']
bbox_loss = outputs['box_loss']
loss = bbox_loss
loss.backward()
Error:
...
outputs = model(images, targets)
File "/home/xxxxxx/.local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 722, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/xxxxxx/.local/lib/python3.7/site-packages/torch/nn/parallel/distributed.py", line 526, in forward
self.reducer.prepare_for_backward(list(_find_tensors(output)))
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).
Hi!
I am trying to train efficientdet to predict bounding boxes without classes. My code:
Error: ... outputs = model(images, targets) File "/home/xxxxxx/.local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 722, in _call_impl result = self.forward(*input, **kwargs) File "/home/xxxxxx/.local/lib/python3.7/site-packages/torch/nn/parallel/distributed.py", line 526, in forward self.reducer.prepare_for_backward(list(_find_tensors(output))) 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
totorch.nn.parallel.DistributedDataParallel
; (2) making sure allforward
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'sforward
function. Please include the loss function and the structure of the return value offorward
of your module when reporting this issue (e.g. list, dict, iterable).How to train on bboxes only?