ubuntu利用conda創建虛擬環境,並安裝cuda,cudnn,pytorch


cd到安裝包所在目錄,安裝:bash Anaconda3-5.1.0-Linux-x86_64.sh

創建虛擬環境:conda create -n your_env_name python=3.6
 

激活虛擬環境:source activate your_env_name

添加conda國內鏡像:

  1. conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  2. conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  3. conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
  4. conda config --set show_channel_urls yes

安裝cuda:conda install cudatoolkit=9.0 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64/
 

安裝cudnn:conda install cudnn=7.4.1 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64/

安裝pytorch指定版本:conda install pytorch=0.3.0 torchvision=0.2.0 -c soumith

根據電腦環境,按照pytorch官網對應代碼安裝

torch官網:https://pytorch.org/get-started/locally/

 

 

注:

安裝conda完成后,輸入conda list,若出現未找到命令,則需修改環境變量:export PATH=~/anaconda3/bin:$PATH(此法每次開機后都要修改,也可修改配置文件永久生效)

每個不同鏡像網站里面包含各種不同的下載包,可根據自己的需求打開查找對應的安裝包,

如cudatoolkit 8.0.3 在https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64/內,

則安裝命令如:conda install cudatoolkit=8.0 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64/ 即可。


免責聲明!

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



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