本文主要是介绍pytorch艰难安装路,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
pytorch安装@pytorch
国庆买了新电脑,需要重新装pytorch,之前的电脑安装得很顺利,现在却是不论是pip install torch或者去官网
找命令pip3.7 install torch==1.2.0+cpu torchvision==0.4.0+cpu -f https://download.pytorch.org/whl/torch_stable.html 都装不了,给我的问题反馈是
一开始用的cmd装,后来用pycharm,发现不管用什么装本质都是一样的问题,网上找了很久很久也找不到方法解决。
昨晚奋战到凌晨查了半天,想用whl文件装,查了下我朋友给我装的python是32位的,但我电脑是64位的,不知道有没有影响,但是pytorch的whl文件没有32位的!!!我就很怀疑是不是这个问题,查了下tensorflow也没有32bit的(毕竟先出来的tf,大家的交流比较多),于是连夜卸载,安装了3.7.4的64位的python.
C:\Users\littlebigus>python
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
继续装pytorch
做了以下工作:
1. pycharm解释器换成了昨天安装的3.7.4的解释器
2. 妄想在pycharm里重新装,结果还是昨天的问题
ModuleNotFoundError: No module named ‘tools.nnwrap’
3.简单粗暴去cmd再试一次,但这次用的pip换了
C:\Users\littlebigus>pip3.7 install torch
然后!!!还是不可,同样的问题’tools.nnwrap’问题(我真的不知道为什么我应该如何解决)
4.再试一次官网的码,来来来copy(话说这几天ctrl+c/v快被我锤烂了)
C:\Users\littlebigus>pip3.7 install torch==1.2.0+cpu torchvision==0.4.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
然后!!!!!!!!!!!!!!!!!!!!!!!!!
Looking in links: https://download.pytorch.org/whl/torch_stable.html
Collecting torch==1.2.0+cpuDownloading https://download.pytorch.org/whl/cpu/torch-1.2.0%2Bcpu-cp37-cp37m-win_amd64.whl (89.4MB)|████████████████████████████████| 89.4MB 211kB/s
Collecting torchvision==0.4.0+cpuDownloading https://download.pytorch.org/whl/cpu/torchvision-0.4.0%2Bcpu-cp37-cp37m-win_amd64.whl (684kB)|████████████████████████████████| 686kB 139kB/s
Requirement already satisfied: numpy in d:\python3.7.4\lib\site-packages (from torch==1.2.0+cpu) (1.17.2)
Collecting pillow>=4.1.1 (from torchvision==0.4.0+cpu)Downloading https://files.pythonhosted.org/packages/14/db/f4c72818297d4d92083c1b3d3404efdb6b2734bea11c0950cfc48b832021/Pillow-6.2.0-cp37-cp37m-win_amd64.whl (2.0MB)|█████ | 307kB 2.9kB/s eta 0:09:46ERROR: Exception:
Traceback (most recent call last):
虽然不出意料又不行了,但是这个error我经常遇到!!!不就是网不好嘛,来来来,再来一遍
C:\Users\littlebigus>pip3.7 install torch==1.2.0+cpu torchvision==0.4.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
Looking in links: https://download.pytorch.org/whl/torch_stable.html
Collecting torch==1.2.0+cpuUsing cached https://download.pytorch.org/whl/cpu/torch-1.2.0%2Bcpu-cp37-cp37m-win_amd64.whl
Collecting torchvision==0.4.0+cpuUsing cached https://download.pytorch.org/whl/cpu/torchvision-0.4.0%2Bcpu-cp37-cp37m-win_amd64.whl
Requirement already satisfied: numpy in d:\python3.7.4\lib\site-packages (from torch==1.2.0+cpu) (1.17.2)
Collecting six (from torchvision==0.4.0+cpu)Downloading https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Collecting pillow>=4.1.1 (from torchvision==0.4.0+cpu)Downloading https://files.pythonhosted.org/packages/14/db/f4c72818297d4d92083c1b3d3404efdb6b2734bea11c0950cfc48b832021/Pillow-6.2.0-cp37-cp37m-win_amd64.whl (2.0MB)|████████████████████████████████| 2.0MB 504kB/s
Installing collected packages: torch, six, pillow, torchvision
Successfully installed pillow-6.2.0 six-1.12.0 torch-1.2.0+cpu torchvision-0.4.0+cpu
我都要感动的哭了
测试一下
C:\Users\littlebigus>python
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> print(torch.cuda.is_available())
False
>>> exit()
不过没有用cuda有点可惜,昨天左摸索右摸索把cuda下下来了,但是10.1版本,装pytorch只有10.0,我实在不想再卸载重新装了,不知道有没有什么事,毕竟小白还不知道cuda干嘛用的…
总结
不知到哪一步奏效的,但以后要用pip3.7装包,pycharm装很方便,等着就行了
还在网上看到一种方法,用whl文件装,把后缀名改成压缩包形式,然后解压缩放在lib\site-packages里面就行了,我试了一下这样在pycharm的包里面能看到安装的包名,但貌似不能用???(不懂,我看的都一知半解的,渴望大神)
生活不易
好好学习
这篇关于pytorch艰难安装路的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!