Ubuntu配置Pytorch

1. 制作系统盘

我是教程

2. 安装系统

我是教程
安装时分辨率
GRUB错误直接exit
进入后调整分辨率

3. 安装N卡驱动

先apt换源
sudo apt-get update /upgrade
首先卸载以前的驱动

sudo apt-get remove –purge nvidia*
sudo apt-get --purge remove xserver-xorg-video-nouveau
sudo apt-get autoremove
sudo apt-get install linux-image-extra-virtual
reboot
sudo gedit /etc/modprobe.d/blacklist.conf
blacklist nouveau
blacklist lbm-nouveau
options nouveau modeset=0
alias nouveau off
alias lbm-nouveau off
blacklist vga16fb
blacklist nouveau
blacklist rivafb
blacklist nvidiafb
blacklist rivatv
echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf
sudo update-initramfs -u
reboot

Ctrl-Alt+F1进入命令行

sudo service lightdm stop
sudo chmod a+x NVIDIA-Linux-x86_64-375.20.run
sudo ./NVIDIA-Linux-x86_64-375.20.run –no-x-check –no-nouveau-check –no-opengl-files 一直yes Xconfig yes
sudo service lightdm start

4安装Cuda

去官网找cuda下载
sudo sh cuda.run
不要安装推荐的驱动
安装完毕后

sudo gedit ~/.bashrc 

export PATH=/usr/local/cuda-10.1/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

sudo gedit /etc/profile
exportPATH=/usr/local/cuda/bin:$PATH

sudo gedit /etc/ld.so.conf.d/cuda.conf
/usr/local/cuda/lib64
sudo ldconfig

4.1 ubuntu访问win磁盘报错

Ubuntu配置Pytorch_第1张图片
image

解决措施
mount:unknown filesystem type 'exfat' ----> sudo apt-get install exfat-fuse

5 CUDNN安装

cudnn解压

 1. sudo cp cuda/include/cudnn.h /usr/local/cuda/include/  
 2. sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/  
 3. sudo chmod a+r  /usr/local/cuda/include/cudnn.h  
 4. sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

/sbin/ldconfig.real: /usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8 不是符号连接
解决办法

cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
这个是检测cudnn是否安装的命令,但是cudnn8中cudnn.h文件中并没有CUDNN_MAJOR关键字,所以没有输出version信息

竖屏 xrandr -o left

6 Pycharm

Pycharm安装

7 安装Anaconda

Anaconda安装教程
conda info 查看源信息
换源

记录

安装pip install torch==1.7.0+cu101 torchvision==0.8.1+cu101 torchaudio==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
conda 一直在solving environment...... conda upgrade --all
有时pip的源中没有你要的包 pip install opencv-python==4.1.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
-i指定地址
pip换源
pip镜像源
系统备份

NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver.
Make sure that the latest NVIDIA driver is installed and running.

你可能感兴趣的:(Ubuntu配置Pytorch)