RuntimeError: ‘lengths’ argument should be a 1D CPU int64 tensor, but got 1D cuda:0 Long tensor
PyTorch 使用报错
- 报错内容
- 原因分析
- 解决方案
报错内容
RuntimeError: ‘lengths’ argument should be a 1D CPU int64 tensor, but got 1D cuda:0 Long tensor
原因分析
因为我使用的是高版本的 torch 1.7.1,这个报错是由于torch 1.5 以上BiLSTM升级导致的。
解决方案
- 转到CPU运行代码就不报错了!
- 将报错的位置参数
lengths
转化为cpu
类型:
lengths.to("cpu")
即可解决!
参考:link
RuntimeError: ‘lengths’ argument should be a 1D CPU int64 tensor, but got 1D cuda:0 Long tensor相关推荐
- RuntimeError: ‘lengths‘ argument should be a 1D CPU int64 tensor, but got 1D cuda:0 Long tensor
- 关于‘lengths‘ argument should be a 1D CPU int64 tensor, but got 1D cuda:0 Long tensor报错的解决方发
复现论文的时候遇到的BUG,后来发现是torch版本升级的原因,发个博客记录一下. 解决方法是需要修改RNN.py文件中的代码. 源代码在244行上下: data, batch_sizes = \_V ...
- Tensor for ‘out‘ is on CPU, Tensor for argument #1 ‘self‘ is on CPU
1.问题 模型训练完后进行测试,报错 RuntimeError: Tensor for 'out' is on CPU, Tensor for argument #1 'self' is on CPU ...
- 异常解决(一)-- RuntimeError: expected device cpu but got device cuda:0
最近在编写深度学习的相关代码,基于PyTorch,运行程序的时候,报错,报错内容如下所示: RuntimeError: expected device cpu but got device cuda: ...
- RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 1.
最近在修改模型不支持的算子后,由于对模型的效果产生了影响,所以需要进行微调训练,但是训练的时候报错了,如下: File "/home/xxxxxxx/EdgeNets/nn_layers/e ...
- PyTorch 错误 RuntimeError: invalid argument 5: k not in range for dimension at /pytorch/aten/src/THC/g
PyTorch 错误 RuntimeError: invalid argument 5: k not in range for dimension at /pytorch/aten/src/THC/g ...
- RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0—问题分析
声明: 这里仅仅提供一个思路,暂时没有绝对正确通用的解决方案 作者:{ 墨理 } 感谢通过私信.评论交流,协力探讨解决问题的同学 UP .Penser 文章目录 探讨的 pytorch 报错信息如下 ...
- Pytorch踩坑: RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0.
报错信息: RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0. Got 186 a ...
- Cannot input a tensor of dimension other than 0 as a scalar argument
Cannot input a tensor of dimension other than 0 as a scalar argument 错误代码: channels_per_group = num_ ...
- RuntimeError: dimension specified as 0 but tensor has no dimensions
RuntimeError: dimension specified as 0 but tensor has no dimensions
最新文章
- python简单代码 春节集五福-新年福利来一波之Python轻松集齐五福(demo)
- Incomedia WebSite X5 17中文版
- linux服务器黑屏_xshell连接Linux系统(小红帽7.3)服务器,导致服务器黑屏
- 【转载】Nginx简介及使用Nginx实现负载均衡的原理
- nginx学习笔记002---Nginx代理配置_案例1_实现了对前端代码的方向代理_并且配置了后端api接口的访问地址
- vc中把数据库记录表导入Excel
- 对俄罗斯应用“一刀切”,乌克兰知名开发商推出 Mac 专用反间谍软件
- hastable与dictionary
- flex invalidation 机制
- 卸载MySQL安装包
- linux通过usb链接网络,Nokia N9 通过USB连接使用PC(Linux)主机的网络
- 【端口扫描工具】mascan核心使用
- 百度关键词地区排名查询php源码,百度关键词地区排名查询
- java贪吃蛇碰撞判定分析_java贪吃蛇碰撞检测
- linux基础之系统安装
- 生产服务器硬盘寻道时间,服务器01-硬盘篇(HDD)
- 8.HTML标签-表格标签table
- 基于Linux下的VIC使用(1)VIC部分(Fortran版本)
- 2021年茶艺师(中级)考试题库及茶艺师(中级)考试试卷
- Google面试官亲授Java面试课程
热门文章
- 项目管理论文十大领域各一篇
- 新视野大学英语3视听说教程智慧版听力原文 Further practice in listening
- 手机浏览器devtools_浏览器DevTools的秘诀:启动,网络和性能
- 厦门理工学院OJ题解(1223:Rite与跳舞毯)
- K-Means聚类算法原理及实现
- netty: LEAK: ByteBuf.release() was not called before it‘s garbage-collected
- 关于MySql使用索引的分析
- UnExpected Error, Quitting
- macos 系统固件 路径_itunes下载固件在哪里 itunes下载固件位置【介绍】
- Debian旧版本下载