microsoft / Cream

This is a collection of our NAS and Vision Transformer work.
MIT License
1.61k stars 220 forks source link

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. #197

Closed vamckrish32 closed 5 months ago

vamckrish32 commented 8 months ago

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). Parameter indices which did not receive grad for rank 0: 138 139 142 143 144 145 In addition, you can set the environment variable TORCH_DISTRIBUTED_DEBUG to either INFO or DETAIL to print out information about which particular parameters did not receive gradient on this rank as part of this error

wkcn commented 8 months ago

Hi @vamckrish32 , thanks for your attention to our work!

Could you please tell me which project raised the error, and how to reproduce it?

vamckrish32 commented 7 months ago

hi I am getting this error from Tiny Clip pre training code By running this command "sh script/auto_weight_inherit_100to75.sh"

wkcn commented 7 months ago

Thank @vamckrish32 ! I will check it.

wkcn commented 7 months ago

Sorry that I could not reproduce the error.

I need more details.

  1. At which iteration did the error occur?
  2. How many GPUs did you use, and what is the value of the --prune-step?
  3. What is your PyTorch version? The version of PyTorch I used is 1.11.0. You could try updating it to 1.11 or later.

Thank you!

wkcn commented 7 months ago

Close it. Feel free to reopen it if the issue still exists. : )

Gumpest commented 5 months ago

@wkcn Sorry, I encountered the same problem.

wkcn commented 5 months ago

@Gumpest Thanks for your attention to our work!

Which version of PyTorch did you use? You could try updating PyTorch to 1.11 or the higher version.

Gumpest commented 5 months ago

@wkcn Thanks for your reply. The version of PyTorch is 2.1.2.

image
Gumpest commented 5 months ago
  1. At which iteration did the error occur? The initial step.
  2. How many GPUs did you use, and what is the value of the --prune-step? 3 A100 80GB and utilize auto_weight_inherit_100to75.sh.
Gumpest commented 5 months ago
image
Gumpest commented 5 months ago

By the way, if I change L476 to the torch.nn.parallel.DistributedDataParallel, device_ids=[device], find_unused_parameters=True, **ddp_args), it will Expected to mark a variable ready only once.

wkcn commented 5 months ago

@Gumpest Thank you for pointing it out! I will check it on PyTorch 2.1.2. Before the bug fixed, you could try to use PyTorch 1.11.

Gumpest commented 5 months ago

@wkcn Thanks a lot! Wait for your solution. 🙏

Gumpest commented 5 months ago

@wkcn PyTorch 1.11 is well done!

wkcn commented 5 months ago

Hi @Gumpest and @vamckrish32 , I have fixed the bug on PyTorch 2.0+ in the latest code of TinyCLIP.