【Pytorch学习】陈云深度学习框架PyTorch入门与实践Windows环境pytorch1.4第三章error记录
文章目录
- Expected object of scalar type Double but got scalar type Long for argument #4 'src' in call to _th_scatter_
- RuntimeError: cos_vml_cpu not implemented for 'Long'
- RuntimeError: CUDA error: invalid device ordinal
- 小试牛刀中的线性回归例子关于GPU、CPU和long类型存在问题还未解决
- Only Tensors of floating point dtype can require gradients
昨天花了一下午的时间把pytorch升级到了1.4,并且安装了cuda10.1。
记录一下在该环境下运行陈云(pytorch0.1.1)出现的问题。
Expected object of scalar type Double but got scalar type Long for argument #4 ‘src’ in call to th_scatter
ERROR:Expected object of scalar type Double but got scalar type Long for argument #4 ‘src’ in call to th_scatter
scatter_只能接收long类型,将生成的数组改成long类型即可
RuntimeError: cos_vml_cpu not implemented for ‘Long’
scatter_是只能接收long,三角函数是不能接收long
改成float就可以了
同理
内部结构这一节也要转换一下数据类型
另外pytorch1.4版本的浮点数表示形式变成了科学计数法
RuntimeError: CUDA error: invalid device ordinal
原因是我的电脑虽然有两块GPU,但只有一块是NVIDIA的,所以应该把cuda改成0
这样就可以正常使用cuda了
这里我的电脑只有一块NVIDIA的GPU,所以不支持
小试牛刀中的线性回归例子关于GPU、CPU和long类型存在问题还未解决
Only Tensors of floating point dtype can require gradients
意思是只有浮点数才需要求导
改成