920232796 / bert_seq2seq

pytorch实现 Bert 做seq2seq任务,使用unilm方案,现在也可以做自动摘要,文本分类,情感分析,NER,词性标注等任务,支持t5模型,支持GPT2进行文章续写。

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

关于多卡训练

guijuzhejiang opened this issue · comments

现在的代码只支持单卡训练,为了改成多GPU并行训练,加了DistributedDataParallel。报错
RuntimeError: grad can be implicitly created only for scalar outputs
好像是loss.backward()的错误
请问有尝试修改代码做多GPU训练吗?

我把原来的total_loss += loss.item()改成total_loss += loss.mean(),是可以跑起来了。

好嘞,多卡我还没了解,多谢您的尝试!

我把原来的total_loss += loss.item()改成total_loss += loss.mean(),是可以跑起来了。

您好!因为显存限制,我也想尝试使用多卡来运行代码,但我自己的尝试失败了,所以想请问您这边的代码实现可以分享一下吗?非常感谢!