pytorch is difficult to install

pytorch install@ pytorch

I bought a new computer on National Day and I need to reinstall pytorch. The previous computer was installed very smoothly, but now it is either pip install torch or go to the official website
to find the command pip3.7 install torch== 1.2.0+cpu torchvision == 0.4.0 +cpu -f https://download.pytorch.org/whl/torch_stable.html can't install it, the feedback to me is that
I used cmd installation at the beginning, and later I used pycharm, and found that no matter what installation is used, the essence is the same I have searched the Internet for a long time, but I can’t find a way to solve the problem.

I fought for a long time in the early morning last night and wanted to install it with a whl file. I checked that the python installed by my friend is 32-bit, but my computer is 64-bit. I don’t know if it will affect it, but the whl file of pytorch is not. 32-bit! ! ! I wonder if this is the problem. I checked tensorflow and there is no 32-bit version (after all, tf came out first, and everyone has a lot of communication), so I uninstalled overnight and installed 3.7.4 64-bit 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.

Continue to install pytorch

The following work was done:
1. The pycharm interpreter was replaced with the 3.7.4 interpreter installed yesterday.
2. The delusion was reinstalled in pycharm, and the result was yesterday’s problem.

ModuleNotFoundError: No module named ‘tools.nnwrap’

3. Simply go to cmd and try again, but this time I changed pip

C:\Users\littlebigus>pip3.7 install torch

then! ! ! Still no, the same problem'tools.nnwrap' problem (I really don't know why I should solve it)

4. Try the code of the official website again, come and copy (it is said that ctrl+c/v is about to be broken by me these days)

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

then! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !

Looking in links: https://download.pytorch.org/whl/torch_stable.html
Collecting torch==1.2.0+cpu
  Downloading 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+cpu
  Downloading 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):

Although it is not unexpected and not good, but I often encounter this error! ! ! It’s just that the internet is not good, come, come, come again

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+cpu
  Using cached https://download.pytorch.org/whl/cpu/torch-1.2.0%2Bcpu-cp37-cp37m-win_amd64.whl
Collecting torchvision==0.4.0+cpu
  Using 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

I'm so moved and cry

have a test

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()

But it’s a pity that I didn’t use cuda. ​​Yesterday I fumbled left and right to download cuda, but the 10.1 version, only 10.0 installed pytorch, I really don’t want to uninstall and reinstall it anymore, I don’t know if there is anything, after all, Xiaobai still doesn’t know about cuda. Why use it...

to sum up

I don’t know which step worked, but I will use pip3.7 to install the package in the future. Pycharm is very convenient to install. Just wait.

I still saw a method on the Internet, install it with a whl file, change the suffix name to a compressed package, and then unzip it and place it in lib\site-packages. I tried it so that it can be seen in the pycharm package. The name of the installed package, but it doesn’t seem to work? ? ? (I don’t understand, I don’t know what I read, I long for God)

Life is not easy,
study hard

Guess you like

Origin blog.csdn.net/sanctuary03/article/details/102229524