pytorch版本错误RuntimeError: one of the variables needed for gradient computation has been modified by a

报错提示:RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor [128, 1]], which is output 0 of TBackward, is at version 2; expected version 1 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).

必须记录一下 一天了 一直卡在这个报错上

网上查到的解决方案:

解决方案1:把所有的inplace=True改成inplace=False
解决方案2:将out+=residual这样所有的+=操作,改成out=out+residual

但是都不行

最后看到了一个帖子帖子本人

尝试了一下 就解决了

解决方法:

降低pytorch版本
我的pytorch版本是1.6.0 降为1.4.0就好用了

作为一个小白 anaconda降版本特别慢 于是用了清华镜像源
如何降版本 查看版本信息 找到了两个很好的博客 放在下方 作为参考。
如何降低版本 及清华镜像源地址 讲解的很清楚

用conda查看当前pytorch版本

  • 5
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值