fastnlp / fastNLP

fastNLP: A Modularized and Extensible NLP Framework. Currently still in incubation.
https://gitee.com/fastnlp/fastNLP
Apache License 2.0
3.05k stars 451 forks source link

elmo_embedding的mask bug #397

Open Pryest opened 2 years ago

Pryest commented 2 years ago

Describe the bug 当device不为cpu时,使用elmo_embedding时发生错误: File "fastNLP/fastNLP/embeddings/elmo_embedding.py", line 329, in forward token_embedding = token_embedding.masked_fill(mask, 0) RuntimeError: expected self and mask to be on the same device, but got mask on cpu and self on cuda:0

To Reproduce 在使用Trainer,设置device不为cpu进行训练时,model含有elmo_embedding。

Expected behavior 正常运行

相关环境 fastNLP=0.6.0或fastNLP=0.7.0

yhcc commented 2 years ago

非常感谢,这个是由于https://github.com/pytorch/pytorch/issues/43227 这个导致的。稍后我们会把修复推送到dev分支。

Cathrii commented 7 months ago

我遇到了相似的问题,请问解决了吗?没有在dev分支中找到相关修复代码

yhcc commented 7 months ago

现在fastNLP已经升级到1.0了,现在已经没有elmoembedding了,你能找到你使用的代码行吗?我可以看看能不能hard code以下修复