conda config --show channels
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 --set show_channel_urls yes
# 或者手动 vim .condarc
chmod +x Anaconda3-5.3.1-Linux-x86_64.sh
./Anaconda3-5.3.1-Linux-x86_64.sh
# 安装路径默认为用户目录(可以自己指定),最后需要确认将路径加入用户的.bashrc中。
# 先给conda换源否则会很慢
# conda会自动安装cudatoolkit和cudnn,这点相比pip方式更人性化
conda install pytorch torchvision cudatoolkit=10.0 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
# -c 指定channel
# deb本质上也是一种压缩包,所以直接解压就行
# cudnn7.4(for cuda10.0)下载 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/libcudnn7_7.4.1.5-1+cuda10.0_amd64.deb
mkdir libcudnn7
cd libcudnn7
ar xv libcudnn7_7.4.1.5-1+cuda10.0_amd64.deb #得到 control.tar.xz data.tar.xz debian-
tar xf data.tar.xz
cp -a usr/lib/x86_64-linux-gnu/* "${pkgdir}"/usr/lib/
# cudnn7.4 dev(for cuda10.0) 下载 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/libcudnn7-dev_7.4.1.5-1+cuda10.0_amd64.deb
mkdir libcudnn7-dev
cd libcudnn7-dev
ar xv "${srcdir}"/libcudnn7-dev_${pkgver}-1+cuda${_cudaver}.0_amd64.deb
tar xf data.tar.xz
cp -a usr/include/x86_64-linux-gnu/* "${pkgdir}"/usr/include/
cp -a usr/lib/x86_64-linux-gnu/* "${pkgdir}"/usr/lib/
# cuda9.0下载地址 https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run
chmod +x cuda_9.0.176_384.81_linux-run
./cuda_9.0.176_384.81_linux-run
# cudnn7.0 for cuda9.0 下载地址 https://developer.download.nvidia.com/compute/redist/cudnn/v7.0.5/cudnn-9.0-linux-x64-v7.tgz
tar -zvxf cudnn-9.0-linux-x64-v7.tgz
cp include/cudnn.h /xxx/cuda-9.0/include/
cp lib64/libcudnn* /xxx/cuda-9.0/lib64/
chmod a+r include/cudnn.h lib64/libcudnn*
# cuda10.0下载地址 https://developer.nvidia.com/compute/cuda/10.0/Prod/local_installers/cuda_10.0.130_410.48_linux
# cudnn7.4 for cuda10.0下载地址(见上)
注意下载地址是从archlinux pkgs官网找到的历史版本
最后修改一下启动设置:
vim ~/.bashrc
# 将下述内容添加到.bashrc文件末尾
export CUDA_HOME="/xxx/cuda-9.0"
export PATH="$PATH:$CUDA_HOME/bin"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$CUDA_HOME/lib64"
参考1 , 参考2