torch安装快捷方式
20.9.3
最开始是torch0.1版本
报错:
AttributeError: module ‘torch’ has no attribute ‘device’
解决:优快云博主「xqlily」博客内容如下:
ubuntu14.04 pycharm运行github上的例子https://github.com/yunjey/pytorch-tutorial/blob/master/tutorials/01-basics/feedforward_neural_network/main.y ,报错标题中的错误AttributeError: module ‘torch’ has no attribute ‘device’
想直接pip安装报错
could not find a version that satisfies the requirement torch
解决:
cpu版本torch安装
得下载下来安装,感谢傲寒道长的博文:
https://www.jianshu.com/p/f54a01419330
安装0.4版本后换了一种报错:
AttributeError: Can’t get attribute ‘_rebuild_parameter’ on <module ‘torch._utils’
解决:优快云博主「无言*」博客内容如下:
调用 torch.load()会出现下面的错误
Can’t get attribute ‘_rebuild_parameter’ on <module 'torch._utils
可以查看是由于torch版本的不匹配造成的,如果是版本问题先卸载torch
pip uninstall torch
然后在https://www.lfd.uci.edu/~gohlke/pythonlibs/?%20?上下载与自己环境相匹配的版本
我的环境是python36版本,win64,使用的torch‑1.0.0‑cp36‑cp36m‑win_amd64.whl,下载torch‑1.0.0‑cp36‑cp36m‑win_amd64.whl,随意放到一个路径,例如放到d盘,则
pip install d:/torch‑1.0.0‑cp36‑cp36m‑win_amd64.whl
pytorch版本问题解决,下一个问题加载中。。。
20.9.5
我就知道torch不会这么放过我。。
AttributeError: module ‘torch’ has no attribute ‘repeat_interleave’
解决:https://stackoverflow.com/questions/64152866/torch-installed-but-repeat-interleave-not-found
The torch.repeat_interleave operator was introduced in 1.1.0 release of pytorch, so please, consider updating to 1.1.0+ version of pytorch to use this method smoothly.
就是说 torch.repeat_interleave这个操作是1.1版本以后才有,于是我重装了1.2版本,这个问题解决。
也许有人说,为什么一开始不装最新版本,主要是新版本可能会造成其他包的不兼容,之前装过1.4版本就报了一个奇怪的问题,可惜当时忘了把错误保存一下,现在,我实在不想再重装了。。。。。
gpu版本torch安装
由于cpu版本实在太慢了,我决定升级成GPU版本
1、这个命令查看系统安装的cuda版本
nvcc -V
参考:
Linux查看当前Cuda(CUDA Toolkit )版本
2、对照上面的cpu版本安装教程