ubuntu利用conda建立虛擬環境,安裝 cuda,cudnn,pytorch,遠端訪問 jupyter notebook
阿新 • • 發佈:2018-12-09
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國內映象:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/ conda config --set show_channel_urls yes
安裝cuda:
conda install cudatoolkit=8.0 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64/
安裝cudnn:
conda install cudnn=7.0.5 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64/
安裝pytorch、torchvision指定版本:
conda install pytorch=0.3.0 torchvision=0.2.0 -c soumith
安裝jupyter notebook:
conda install notebook
ssh遠端連線:
https://blog.csdn.net/lxfhahaha/article/details/73650096
https://blog.csdn.net/kaixinjiuxing666/article/details/80118714
ssh -L6789:localhost:8889 name(遠端伺服器的使用者名稱)@ip(遠端伺服器的IP)
在已經成功連線的伺服器環境中,開啟 notebook:
jupyter notebook
在本地瀏覽器中開啟 notebook:
http://localhost:6789
在本地瀏覽器中輸入notebook金鑰:
剛才在遠端伺服器開啟notebook後,系統自動跳出的toke= 後面的那一串
注:
- pytorch 中文官網:
http://pytorch.apachecn.org/
- 安裝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/