getting error while training LayoutLMV2 model on multi gpu setup
See original GitHub issueRuntimeError: 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 passing the keyword argument find_unused_parameters=True
to torch.nn.parallel.DistributedDataParallel
, and by
making sure all forward
function outputs participate in calculating loss.
If you already have done the above, 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).
Parameters which did not receive grad for rank 0: layoutlmv2.pooler.dense.bias, layoutlmv2.pooler.dense.weight, layoutlmv2.visual.backbone.fpn_output5.bias, layoutlmv2.visual.backbone.fpn_output5.weight, layoutlmv2.visual.backbone.fpn_output4.bias, layoutlmv2.visual.backbone.fpn_output4.weight, layoutlmv2.visual.backbone.fpn_output3.bias, layoutlmv2.visual.backbone.fpn_output3.weight
Parameter indices which did not receive grad for rank 0: 16 17 20 21 24 25 510 511
Traceback (most recent call last):
File “LayoutLMv2 Best Model - 0.7873 - Finetuning on LS Internal All Data.py”, line 788, in <module>
outputs = model(**train_batch)
File “/root/py38/lib/python3.8/site-packages/torch/nn/modules/module.py”, line 1102, in _call_impl
return forward_call(*input, **kwargs)
File “/root/py38/lib/python3.8/site-packages/torch/nn/parallel/distributed.py”, line 873, in forward
if torch.is_grad_enabled() and self.reducer._rebuild_buckets():
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 passing the keyword argument find_unused_parameters=True
to torch.nn.parallel.DistributedDataParallel
, and by
making sure all forward
function outputs participate in calculating loss.
If you already have done the above, 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).
Parameters which did not receive grad for rank 1: layoutlmv2.pooler.dense.bias, layoutlmv2.pooler.dense.weight, layoutlmv2.visual.backbone.fpn_output5.bias, layoutlmv2.visual.backbone.fpn_output5.weight, layoutlmv2.visual.backbone.fpn_output4.bias, layoutlmv2.visual.backbone.fpn_output4.weight, layoutlmv2.visual.backbone.fpn_output3.bias, layoutlmv2.visual.backbone.fpn_output3.weight
Parameter indices which did not receive grad for rank 1: 16 17 20 21 24 25 510 511
I am following the guide here: https://huggingface.co/docs/transformers/accelerate
Can anyone help??
Issue Analytics
- State:
- Created a year ago
- Comments:5
Top GitHub Comments
Thanks, @muellerzr for the prompt response. It was constructive.
@sujit420 as the error states it wants you to pass in
find_unused_params=True
. These are from the DDP kwargs and you can pass them in when building yourAccelerator
object: https://huggingface.co/docs/accelerate/package_reference/kwargs#accelerate.DistributedDataParallelKwargsCan you try the following when declaring your Accelerator?