Pytorch安裝教程


一、准備

  Window10系統+Ubuntu16.10系統、Anaconda3.5(python3.6)

二、流程

  (1)由於牆的問題,用conda安裝Pytorch過程中會連接失敗,這是因為Anaconda.org的服務器在國外。在這里可以用清華TUNA鏡像源,包含Anaconda倉庫的鏡像,將其加入conda的配置,配置如下:

# 添加Anaconda的TUNA鏡像
$  conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
# TUNA的help中鏡像地址加有引號,需要去掉

# 設置搜索時顯示通道地址
$  conda config --set show_channel_urls yes

  執行完上述命令后,會生成~/.condarc文件,記錄着對conda的配置,直接手動創建、編輯該文件是相同的效果。

  (2)此時,為避免后面出現An HTTP error occurred when trying to retrieve this URL. 的錯誤,更改.condarc文件,操作如下:

cd 
sudo gedit .condarc

刪除 - default 所在的行

.condarc的內容應該是:

channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
show_channel_urls: true

  (3)Pytorch安裝


  在這里的安裝,我采用conda安裝:

 

  跟據自身電腦的配置,按照 https://ptorch.com/news/30.html

  安裝方法:conda,服務器:linux,Cuda版本:cudanone,Python版本:python3.6

conda install pytorch torchvision -c soumith

  (4)測試

 

  進入python模式下,看能否導入torch成功:

$  python
>  import torch

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM