python3 pytorch de instalación rápida

     Necesita instalar pytorch, pero falló después de varios intentos. Al mismo tiempo, debido al tamaño relativamente grande de pytorch, la velocidad de descarga también es relativamente lenta. Aquí hay un resumen de los pasos de instalación rápida de pytorch para referencia futura y referencia de pares.

Una instalación de espejo Tsinghua

Bajo la ruta de su unidad C (C: \ Users \ 1112 \ AppData \ Roaming), principalmente en AppData \ Roaming, el usuario (1112) puede ser diferente para cada computadora (la mía es win10). Luego cree una nueva carpeta pip, como se muestra a continuación:

 

 

Luego cree un nuevo documento de texto pip.ini en la carpeta pip, con el contenido dentro:

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

Luego guárdelo como un archivo pip.ini (el formato es todos los formatos, no los tipos de texto, es fácil cometer errores aquí)

Después del éxito, se convertirá en el archivo de configuración. Al instalar el paquete con pip en el futuro, se usa el espejo Tsinghua por defecto, que es muy rápido

 

Dos instalar pytouch

Prácticas exitosas:

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

 La instalación se realiza correctamente en menos de 30 segundos (los beneficios de utilizar la duplicación)

 

Situación de falla inmediata:

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.

 

Supongo que te gusta

Origin blog.csdn.net/qq_39463175/article/details/106897784
Recomendado
Clasificación