自动安装:
在soft and updates里直接选择就行
手动安装:
下载驱动
然后安装依赖
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install --no-install-recommends libboost-all-dev
sudo apt-get install libopenblas-dev liblapack-dev libatlas-base-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
禁用系统默认显卡驱动
sudo gedit /etc/modprobe.d/blacklist.conf
打开文件,在文件末尾写入:
blacklist nouveau
options nouveau modeset=0
保存后手动更新;
sudo update-initramfs -u
电脑重启,输入下列指令进行确认,若无输出,则禁用成功:
lsmod | grep nouveau
配置环境变量
gedit命令打开配置文件:
sudo gedit ~/.bashrc
末尾写入:
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
保存更新:
source ~/.bashrc
卸载原有驱动(如果有的话)
有两种方法
sudo apt-get --purge remove “nvidia*”
sudo apt autoremove
退出图形界面
sudo systemctl isolate multi-user.target
sudo modprobe -r nvidia-drm
安装驱动
进入到对应目录
先对对应文件进行授权,然后执行安装程序。
sudo chmod +x NVIDIA-……………….run*
sudo sh NVIDIA-……………….run* --no-opengl-files --no-x-check --no-nouveau-check
第二项指令的三个参数分别为:
–no-opengl-files 不安装OpenGL文件。这个参数最重要
–no-x-check 安装驱动时不检查X服务
–no-nouveau-check 安装驱动时不检查nouveau
1.The distribution-provided pre-install script failed! Are you sure you want to continue?
“Yes”
2.Would you like to register the kernel module souces with DKMS? This will allow DKMS to automatically build a new module, if you install a different kernel later?
“No”
3.Nvidia’s 32-bit compatibility libraries?
“No”
4.Would you like to run the nvidia-xconfigutility to automatically update your x configuration so that the NVIDIA x driver will be used when you restart x? Any pre-existing x confile will be backed up.
“Yes”
设置图像界面并重启
sudo systemctl set-default graphical.target
sudo reboot 0
终端输入指令,进行验证
sudo nvidia-smi
参考
Ubuntu20.04显卡驱动安装
Ubuntu 18.04.5 LTS 安装 NVIDIA 显卡驱动时报错:An NVIDIA kernel module ‘nvidia-drm‘ appears to already be load