如何手動安裝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
相關文章
相關標籤/搜索