Ubuntu18.04安装教程
# 阿里云源
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
##測試版源
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
# 源碼
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
##測試版源
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
# 清华大学源
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
##測試版源
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# 源碼
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
##測試版源
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bcakup
sudo gedit /etc/apt/sources.list
sudo apt-get update
sudo apt-get upgrade
1、准备工具
make:
sudo apt install make
gcc:
sudo apt install gcc
2、禁用第三方(nouveau)驱动
安装依赖:
sudo apt-get install dkms build-essential linux-headers-generic
打开conf文件:
sudo vim /etc/modprobe.d/blacklist.conf
在末尾添加:
blacklist nouveau
blacklist lbm-nouveau
options nouveau modeset=0
alias nouveau off
alias lbm-nouveau off
blacklist nouveau
blacklist lbm-nouveau
options nouveau modeset=0
alias nouveau off
alias lbm-nouveau off
禁用第三方驱动:
echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf
更新并重启:
sudo update-initramfs -u
sudo reboot
3、下载并安装NVIDIA驱动
下载驱动:
wget https://cn.download.nvidia.com/XFree86/Linux-x86_64/470.82.00/NVIDIA-Linux-x86_64-470.82.00.run
权限设置:
sudo chmod 775 NVIDIA-Linux-x86_64-470.82.00.run
移除留存的驱动:
sudo apt-get remove nvidia* && sudo apt autoremove
安装驱动:
sudo bash NVIDIA-Linux-x86_64-470.82.00.run
4、安装CUDA、pytorch、pytorchvision
3080要求CUDA版本为11.3及以上:
(你需要先安装好Anconda或者Miniconda)
conda install pytorch torchvision cudatoolkit=11.3 -c pytorch
5、验证
验证pytorch能否使用cuda,通过torch.cuda.is_available()是不可靠的,通过torch.tensor(1).cuda()方式是可靠的,如果没有报错证明CUDA可用。
6、可能的Bug
6.1、ValueError: signal number 32 out of range
Exception in Thread: ValueError: signal number 32 out of range
6.2 经常性nvidia-smi命令失效
参考:https://blog.csdn.net/u013685264/article/details/121903540
7、卸载该Nvidia驱动
实际上和安装命令差不多,只不过多了–uninstall
sudo bash NVIDIA-Linux-x86_64-470.82.00.run --uninstall