服务器版本:Ubuntu16.04
环境搭建版本:CUDA9.0,Pytorch1.0 branch 最新版
安装anaconda
先去anaconda官网获取下载连接
https://www.anaconda.com/distribution/
这里,我的是下面这个链接,进行下载
wget https://repo.anaconda.com/archive/Anaconda3-2019.10-Linux-x86_64.sh
下载完成后,用bash进行安装
bash Anaconda3-2019.10-Linux-x86_64.sh
创建新的虚拟环境
安装完成后,用conda创建需求的环境,比如说我想创建python版本为3.6的环境
conda create -n env_name python=3.6 #创建名字为env_name的虚拟空间,并设置python版本
conda activate env_name #激活这个虚拟空间
创建环境
conda create -n pytorch1.0-py3.6 python=3.6
进行激活
conda activate pytorch1.0-py3.6
安装cuda
这里选择用清华源进行下载
首先在conda添加清华源(顺便添加pytorch的镜像)
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和cudnn
conda install cudatoolkit=版本号 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64/
conda install cudnn=版本号 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64/
版本号改成需要的版本即可,比如cudatoolkit=9.0
安装pytorch
可以在pytoch官网找自己需要的版本:https://pytorch.org/get-started/locally/ ,记得cuda版本要改成自己安装的版本
这里我用的是
conda install pytorch torchvision cudatoolkit=9.0 -c pytorch
或者直接用清华源的镜像进行下载
conda install pytorch=*.*.* torchvision=*.*.* -c soumith
*.*.*
填上自己需要的版本号