songhaoyu / BoB

The released codes for ACL 2021 paper 'BoB: BERT Over BERT for Training Persona-based Dialogue Models from Limited Personalized Data'
https://aclanthology.org/2021.acl-long.14/
Apache License 2.0
136 stars 24 forks source link

采用DDP训练代码出错 #11

Closed cingtiye closed 2 years ago

cingtiye commented 2 years ago

您好,我想用DDP(model)训练代码,但是出现如下错误:

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).`

尽管我已经设置了 find_unused_parameters=True 和 提高了 torch的版本。

请问应该如何更改相关代码才能解决上述问题,感谢。

cingtiye commented 2 years ago

直接用 total_loss = loss + ALAPHA*loss_2 + BETA*ul_loss 不知道训练出来效果咋样