python3 quick install pytorch

     Need to install pytorch, but failed after several attempts. At the same time, due to the relatively large size of pytorch, the download speed is also relatively slow. Here is a summary of the quick installation steps of pytorch for future reference and peer reference.

One install Tsinghua mirror

Under the path of your C drive (C:\Users\1112\AppData\Roaming), mainly in AppData\Roaming, the user (1112) may be different for each computer (mine is win10). Then create a new folder pip, as shown below:

 

 

Then create a new text document pip.ini in the pip folder, with the content inside:

[global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn

Then save it as a file pip.ini (the format is all formats, not text types, it's easy to make mistakes here)

After success, it will become the configuration file. When installing the package with pip in the future, the Tsinghua mirror is used by default, which is very fast

 

Two install pytouch

Successful practices:

pip install torch==1.2.0+cpu torchvision==0.4.0+cpu -f https://download.pytorch.org/whl/torch_stable.html

 The installation is successful in less than 30 seconds (the benefits of using mirroring)

 

Failure prompt situation:

C:\Users\1002>pip install pytorch
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting pytorch
  WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x000001903FC29E48>: Failed to establish a new connection: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。')': /simple/pytorch/
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ee/67/f403d4ae6e9cd74b546ee88cccdb29b8415a9c1b3d80aebeb20c9ea91d96/pytorch-1.0.2.tar.gz
Building wheels for collected packages: pytorch
  Building wheel for pytorch (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'E:\software\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\1002\\AppData\\Local\\Temp\\pip-install-khgxxu4u\\pytorch\\setup.py'"'"'; __file__='"'"'C:\\Users\\1002\\AppData\\Local\\Temp\\pip-install-khgxxu4u\\pytorch\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\1002\AppData\Local\Temp\pip-wheel-pxo1yahy' --python-tag cp37
       cwd: C:\Users\1002\AppData\Local\Temp\pip-install-khgxxu4u\pytorch\
  Complete output (5 lines):
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\1002\AppData\Local\Temp\pip-install-khgxxu4u\pytorch\setup.py", line 15, in <module>
      raise Exception(message)
  Exception: You tried to install "pytorch". The package named for PyTorch is "torch"
  ----------------------------------------
  ERROR: Failed building wheel for pytorch
  Running setup.py clean for pytorch
Failed to build pytorch
Installing collected packages: pytorch
  Running setup.py install for pytorch ... error
    ERROR: Command errored out with exit status 1:
     command: 'E:\software\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\1002\\AppData\\Local\\Temp\\pip-install-khgxxu4u\\pytorch\\setup.py'"'"'; __file__='"'"'C:\\Users\\1002\\AppData\\Local\\Temp\\pip-install-khgxxu4u\\pytorch\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\1002\AppData\Local\Temp\pip-record-ml07_20g\install-record.txt' --single-version-externally-managed --compile
         cwd: C:\Users\1002\AppData\Local\Temp\pip-install-khgxxu4u\pytorch\
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\1002\AppData\Local\Temp\pip-install-khgxxu4u\pytorch\setup.py", line 11, in <module>
        raise Exception(message)
    Exception: You tried to install "pytorch". The package named for PyTorch is "torch"
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'E:\software\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\1002\\AppData\\Local\\Temp\\pip-install-khgxxu4u\\pytorch\\setup.py'"'"'; __file__='"'"'C:\\Users\\1002\\AppData\\Local\\Temp\\pip-install-khgxxu4u\\pytorch\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\1002\AppData\Local\Temp\pip-record-ml07_20g\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.

 

Guess you like

Origin blog.csdn.net/qq_39463175/article/details/106897784