ubuntu 22.04 安装Nvidia显卡驱动 an error occurred while performing building kernel modules
通用流程参考知乎文章:
ubuntu22.04安装nvidia显卡驱动——超详细、最简单 - 一切都好的文章 - 知乎
1.安装驱动前一定要更新软件列表和安装必要软件、依赖(必须)
sudo apt-get update #更新软件列表
sudo apt-get install g++
sudo apt-get install gcc
sudo apt-get install make
2、禁用 nouveau
sudo gedit /etc/modprobe.d/blacklist.conf
在最后两行添加
blacklist nouveau
options nouveau modeset=0
3、安装
3.1进入命令行界面
sudo telinit 3
3.2关闭显示服务
sudo service gdm3 stop
3.3 给安装文件赋予权限,然后运行安装
sudo chmod 777 NVIDIA-Linux-x86_64-525.60.11.run #赋予可执行权限
sudo ./NVIDIA-Linux-x86_64-525.60.11run --no-opengl-files #安装
3.4安装完成后重新开启显示服务
sudo service gdm3 start
3.5进入系统 输入
nvidia-smi
显示
然而我还遇到执行NVIDIA*.run时build kernel error的问题
(an error occurred while performing building kernel modules see /var/log/nvidia-installer.log for details. unrecognized command-line option...)
原因是系统gcc版本和内核gcc版本不一致,
That’s an issue with the Ubuntu kernel. For whatever reasons, the ubuntu kernel team decided to use gcc-12 for kernel compilation while the 22.04 system compiler is gcc-11. Please install gcc-12 from ubuntu repo to be able to compile the nvidia modules again.
参考链接: