I am trying to train ‘convnext_tiny’ on my 16GPUs AWS instance
learn = vision_learner(dls, 'convnext_tiny', pretrained= True, metrics = accuracy, cbs = [SaveModelCallback, CSVLogger(fname='convnext_tiny_stage1.csv')])
print('learner loaded')
with learn.distrib_ctx(sync_bn=False):
learn.fit_one_cycle(20, 0.00251, cbs=EarlyStoppingCallback(monitor='accuracy'))
learn.save('convnext_tiny_stage1')
and I am receiving this error:
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 8: 44 45
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
The complete log:
epoch train_loss valid_loss accuracy time
Traceback (most recent call last):--------------------------------------------------------------------------------| 0.01% [1/14439 00:11<47:49:00]
File "convnext_tiny_stage1.py", line 44, in <module>
learn.fit_one_cycle(20, 0.00251, cbs=EarlyStoppingCallback(monitor='accuracy'))
File "/home/aayush/.local/share/virtualenvs/aayush-bykuu7TH/lib/python3.7/site-packages/fastai/callback/schedule.py", line 116, in fit_one_cycle
self.fit(n_epoch, cbs=ParamScheduler(scheds)+L(cbs), reset_opt=reset_opt, wd=wd)
File "/home/aayush/.local/share/virtualenvs/aayush-bykuu7TH/lib/python3.7/site-packages/fastai/learner.py", line 222, in fit
self._with_events(self._do_fit, 'fit', CancelFitException, self._end_cleanup)
File "/home/aayush/.local/share/virtualenvs/aayush-bykuu7TH/lib/python3.7/site-packages/fastai/learner.py", line 164, in _with_events
try: self(f'before_{event_type}'); f()
File "/home/aayush/.local/share/virtualenvs/aayush-bykuu7TH/lib/python3.7/site-packages/fastai/learner.py", line 213, in _do_fit
self._with_events(self._do_epoch, 'epoch', CancelEpochException)
File "/home/aayush/.local/share/virtualenvs/aayush-bykuu7TH/lib/python3.7/site-packages/fastai/learner.py", line 164, in _with_events
try: self(f'before_{event_type}'); f()
File "/home/aayush/.local/share/virtualenvs/aayush-bykuu7TH/lib/python3.7/site-packages/fastai/learner.py", line 207, in _do_epoch
self._do_epoch_train()
File "/home/aayush/.local/share/virtualenvs/aayush-bykuu7TH/lib/python3.7/site-packages/fastai/learner.py", line 199, in _do_epoch_train
self._with_events(self.all_batches, 'train', CancelTrainException)
File "/home/aayush/.local/share/virtualenvs/aayush-bykuu7TH/lib/python3.7/site-packages/fastai/learner.py", line 164, in _with_events
try: self(f'before_{event_type}'); f()
File "/home/aayush/.local/share/virtualenvs/aayush-bykuu7TH/lib/python3.7/site-packages/fastai/learner.py", line 170, in all_batches
for o in enumerate(self.dl): self.one_batch(*o)
File "/home/aayush/.local/share/virtualenvs/aayush-bykuu7TH/lib/python3.7/site-packages/fastai/learner.py", line 195, in one_batch
self._with_events(self._do_one_batch, 'batch', CancelBatchException)
File "/home/aayush/.local/share/virtualenvs/aayush-bykuu7TH/lib/python3.7/site-packages/fastai/learner.py", line 164, in _with_events
try: self(f'before_{event_type}'); f()
File "/home/aayush/.local/share/virtualenvs/aayush-bykuu7TH/lib/python3.7/site-packages/fastai/learner.py", line 173, in _do_one_batch
self.pred = self.model(*self.xb)
File "/home/aayush/.local/share/virtualenvs/aayush-bykuu7TH/lib64/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/home/aayush/.local/share/virtualenvs/aayush-bykuu7TH/lib64/python3.7/site-packages/torch/nn/parallel/distributed.py", line 873, in forward
Traceback (most recent call last):
File "convnext_tiny_stage1.py", line 44, in <module>
learn.fit_one_cycle(20, 0.00251, cbs=EarlyStoppingCallback(monitor='accuracy'))
File "/home/aayush/.local/share/virtualenvs/aayush-bykuu7TH/lib/python3.7/site-packages/fastai/callback/schedule.py", line 116, in fit_one_cycle
self.fit(n_epoch, cbs=ParamScheduler(scheds)+L(cbs), reset_opt=reset_opt, wd=wd)
File "/home/aayush/.local/share/virtualenvs/aayush-bykuu7TH/lib/python3.7/site-packages/fastai/learner.py", line 222, in fit
self._with_events(self._do_fit, 'fit', CancelFitException, self._end_cleanup)
File "/home/aayush/.local/share/virtualenvs/aayush-bykuu7TH/lib/python3.7/site-packages/fastai/learner.py", line 164, in _with_events
try: self(f'before_{event_type}'); f()
File "/home/aayush/.local/share/virtualenvs/aayush-bykuu7TH/lib/python3.7/site-packages/fastai/learner.py", line 213, in _do_fit
self._with_events(self._do_epoch, 'epoch', CancelEpochException)
File "/home/aayush/.local/share/virtualenvs/aayush-bykuu7TH/lib/python3.7/site-packages/fastai/learner.py", line 164, in _with_events
try: self(f'before_{event_type}'); f()
File "/home/aayush/.local/share/virtualenvs/aayush-bykuu7TH/lib/python3.7/site-packages/fastai/learner.py", line 207, in _do_epoch
self._do_epoch_train()
File "/home/aayush/.local/share/virtualenvs/aayush-bykuu7TH/lib/python3.7/site-packages/fastai/learner.py", line 199, in _do_epoch_train
self._with_events(self.all_batches, 'train', CancelTrainException)
File "/home/aayush/.local/share/virtualenvs/aayush-bykuu7TH/lib/python3.7/site-packages/fastai/learner.py", line 164, in _with_events
try: self(f'before_{event_type}'); f()
File "/home/aayush/.local/share/virtualenvs/aayush-bykuu7TH/lib/python3.7/site-packages/fastai/learner.py", line 170, in all_batches
for o in enumerate(self.dl): self.one_batch(*o)
File "/home/aayush/.local/share/virtualenvs/aayush-bykuu7TH/lib/python3.7/site-packages/fastai/learner.py", line 195, in one_batch
self._with_events(self._do_one_batch, 'batch', CancelBatchException)
File "/home/aayush/.local/share/virtualenvs/aayush-bykuu7TH/lib/python3.7/site-packages/fastai/learner.py", line 164, in _with_events
try: self(f'before_{event_type}'); f()
File "/home/aayush/.local/share/virtualenvs/aayush-bykuu7TH/lib/python3.7/site-packages/fastai/learner.py", line 173, in _do_one_batch
self.pred = self.model(*self.xb)
File "/home/aayush/.local/share/virtualenvs/aayush-bykuu7TH/lib64/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/home/aayush/.local/share/virtualenvs/aayush-bykuu7TH/lib64/python3.7/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).
Parameter indices which did not receive grad for rank 1: 44 45
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
My Environment settings:
timm==0.5.4
fastai==2.6.3
torch==1.10.2
torchvision==0.11.3