ubuntu搭建GPU pytorch版本

安装显卡驱动

我的个人blog: https://ximikang.icu

禁止集成的nouveau驱动

vim /etc/modprobe.d/blacklist.conf

#添加几行
blacklist vga16fb
blacklist nouveau
blacklist rivafb
blacklist rivatv
blacklist nvidiafb

#执行
update-initramfs -u
reboot

#重启后执行
lsmod | grep nouveau

#没有显示说明已经禁用

开始安装

#安装必要
apt-get update
apt-get install gcc g++ make -y

#按照提示进行安装
bash NVIDIA-Linux-x86_64-440.31.run

#安装后执行,可以查看gpu状态
nvidia-smi 

#查看gpu的驱动版本
cat /proc/driver/nvidia/version

Anaconda

  • 下载Anaconda, 如果在国内的话建议使用国内的mirror下载, https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/ 清华镜像源的镜像,找到对应的版本进行下载.

    wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.3.1-Linux-x86_64.sh
    bash Anaconda3-5.3.1-Linux-x86_64.sh
    
  • 按照提示进行安装

  • 生效环境变量

    source ~/.bashrc
    
  • 换清华镜像源

      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
    
  • 创建一个name为pytorh python版本为3.7的虚拟环境。

      conda create -n pytorch python=3.7
      #切入环境
      source activate pytorch
    

pytroch

配置好conda环境后就,pytorch就可以顺利安装了。

此处不能按照官方进行安装conda install pytorch torchvision cudatoolkit=10.1 -c pytorch

#需要去掉-c torch后,可以从清华镜像快速下载。
conda install pytorch torchvision cudatoolkit=10.1

猜你喜欢

转载自blog.csdn.net/qq_36361250/article/details/104650337