如何手动安装pytorch whl文件

pytorch 官方网站python

官方网站提供多种安装方式,例如pip和conda等,能够参考官方安装文档,文档很详细,建议仔细查看和使用。但安装过程当中可能存在网络不稳定致使没法正常安装等状况,须要使用离线方式下载whl文件安装。浏览器

pip安装软件能够使用国内安装源加速安装,能够参考安装教程网络

首先不推荐pip安装方式。Windows 10 PowerShell安装很容易失败。具体日志以下:post

#安装错误日志
Windows PowerShell
版权全部 (C) Microsoft Corporation。保留全部权利。

PS C:\Windows\system32> pip install pytorch
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting pytorch
  Downloading https://mirrors.aliyun.com/pypi/packages/a9/41/4487bc23e3ac4d674943176f5aa309427b011e00607eb98899e9d951f67b/pytorch-0.1.2.tar.gz
Building wheels for collected packages: pytorch
  Building wheel for pytorch (setup.py) ... error
  Complete output from command "c:\program files\python36\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\legion\\AppData\\Local\\Temp\\pip-install-yo1kyfd7\\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\legion\AppData\Local\Temp\pip-wheel-ryvzo89f --python-tag cp36:
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\legion\AppData\Local\Temp\pip-install-yo1kyfd7\pytorch\setup.py", line 17, in <module>
      raise Exception(message)
  Exception: You should install pytorch from http://pytorch.org

  ----------------------------------------
  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
    Complete output from command "c:\program files\python36\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\legion\\AppData\\Local\\Temp\\pip-install-yo1kyfd7\\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\legion\AppData\Local\Temp\pip-record-zmowtm8p\install-record.txt --single-version-externally-managed --compile:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\legion\AppData\Local\Temp\pip-install-yo1kyfd7\pytorch\setup.py", line 13, in <module>
        raise Exception(message)
    Exception: You should install pytorch from http://pytorch.org

    ----------------------------------------
Command ""c:\program files\python36\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\legion\\AppData\\Local\\Temp\\pip-install-yo1kyfd7\\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\legion\AppData\Local\Temp\pip-record-zmowtm8p\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\legion\AppData\Local\Temp\pip-install-yo1kyfd7\pytorch\
PS C:\Windows\system32>

正式开始安装 pytorch 前首先安装 torchvision 。网站

#torchvision 下载地址
https://pypi.org/project/torchvision/#files
#可能存在变更
pip install torchvision
#详细下载地址
pip install https://files.pythonhosted.org/packages/fb/01/03fd7e503c16b3dc262483e5555ad40974ab5da8b9879e164b56c1f4ef6f/torchvision-0.2.2.post3-py2.py3-none-any.whl
#conda 安装
conda install -c anaconda cudatoolkit

https://pytorch.org/get-started/previous-versions/ 能够下载不一样版本pytorch。.whl文件能够使用浏览器或者迅雷下载。ui

本文以安装 python 3.7 CPU 版本为例。下载连接以下.net

https://download.pytorch.org/whl/cpu/torch-0.4.1-cp37-cp37m-win_amd64.whl3d

下载完毕,开始安装。日志

pip install torch-0.4.1-cp37-cp37m-win_amd64.whl

安装可能须要依赖numpy等,能够提早下载。地址以下code

https://pypi.org/project/numpy/#files

本文推荐使用conda安装,能够解决部分状况下缺乏部分C依赖库致使安装失败问题。

conda install numpy pyyaml mkl mkl-include setuptools cmake cffi typing
conda install pytorch
相关文章
相关标签/搜索