Ubuntu18.04安装NVIDIA驱动
- 一 查看显卡相关信息并下载显卡驱动
- 二 安装显卡驱动
- 三 参考资料
-
2022年4月20日凌晨于上海
一 查看显卡相关信息并下载显卡驱动
- 重启电脑,进入BIOS界面,找到secure boot,将其设置为disable
- 安装相关依赖项
# 安装依赖项
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
- 查看显卡型号
# 查看型号
lspci | grep -i vga
# 查看结果
00:02.0 VGA compatible controller: Intel Corporation Device 9a60 (rev 01)
01:00.0 VGA compatible controller: NVIDIA Corporation Device 2560 (rev a1)
# 结果显示电脑有两个显卡,一个是intel的集成显卡(9a60),另一个是NVIDIA的独立显卡(2560)
查看显卡代码相对应的显卡型号,地址:型号查询
# 查询显卡型号结果为
Name: GA106M [GeForce RTX 3060 Mobile / Max-Q]
- 下载显卡驱动
查看显卡型号相对应的显卡驱动,地址:NVIDIA驱动,信息填写完整后,点击SEARCH会显示相对应的显卡驱动,点击DOWNLOAD下载驱动,自动保存在Downloads文件夹,记住显卡驱动名
二 安装显卡驱动
- 禁用nouveau
ubuntu18.04默认安装了第三方开源的驱动程序nouveau,安装nvidia显卡驱动首先需要禁用nouveau,不然会碰到冲突的问题,导致无法安装nvidia显卡驱动
# 编辑blacklist.conf文件
sudo gedit /etc/modprobe.d/blacklist.conf
在打开的blacklist.conf文件最后部分插入以下两行内容并保存
blacklist nouveau
options nouveau modeset=0
更新系统
sudo update-initramfs -u
重启系统(一定要重启)
sudo reboot
验证nouveau是否已禁用
lsmod | grep nouveau
# 没有信息显示,说明nouveau已被禁用
- 安装驱动文件
卸载已经安装的显卡驱动:
# 若安装方式为installed by apt-get:
sudo apt-get remove --purge nvidia*
# 若安装方式为installed by runfile:
sudo ./NVIDIA-Linux-x86_64-xxx.run --uninstall
给驱动run文件赋予执行权限并安装
cd Downloads
sudo chmod a+x NVIDIA-Linux-x86_64-xxx.run
# 只有禁用opengl这样安装才不会出现循环登陆的问题;
sudo ./NVIDIA-Linux-x86_64-xxx.run -no-opengl-files
安装过程中会出现一些步骤需要进行选择
# 步骤1
An alternate method of installing the NVIDIA driver was detected.(This is usually a package
provided by distributor.) A driver installed via that method mayintegrate better with your
system than a driver installed by nvidia-installer
Please review the message provided by the maintainer of this alternate installation method
and decide how to proceed:
选择 continue installtion
# 步骤2
WARNING:Unable to find a suitable destibation to install 32-bit compatibility libraries.Your
system may not be set up for 32-bit compatibility.32-bit compatibility files will not be installed;
if you wish to install them,re-run the installation and set a valid directory with the
--compat32-libdir option
选择 OK
# 步骤3
Would you like to run the nvidia-xconfig utility to automatically update your X configuration
file so that the NVIDIA X driver will be used when you restart X? Any pre-existing X configuration
file will be backed up.
选择 NO
# 步骤4
Installation of the NVIDIA Accelerated Graphics Driver for Linux-x86_64(version:510.60.02) is now
complete.Please update your xorg-conf file as appropriate;see the file
/usr/share/doc/NVIDIA_GLX-1.0/README.txt for details
选择 OK
- 检查是否安装成功
# 挂载Nvidia驱动
modprobe nvidia
# 检查驱动是否安装成功
nvidia-smi
# 重启电脑
sudo reboot
三 参考资料
- 资料一
- 资料二
- 资料三
- 资料四