2391

Ubuntu 22.04手动安装卸载NVIDIA驱动

下载驱动文件

官网地址:官方驱动 | NVIDIA
根据自己的显卡型号,选择驱动文件进行下载
(注意:选择系统的下拉框中如果没有ubuntu系统,可以点击全部系统,就能选择了)

更新系统软件

root账户下操作

apt update

apt install g++ gcc make

禁用默认驱动

安装Nvidia驱动前,需要禁用自带显卡驱动nouveau

vi /etc/modprobe.d/blacklist.conf

在文件末尾添加并保存:

blacklist nouveau
options nouveau modeset=0

更新initinitramfs,执行以下命令

update-initramfs -u

安装完成后重启,查看是否生效

lsmod | grep nouveau

如果没有输出任何内容,说明默认驱动nouveau已经禁用了

进入tty模式

正式安装驱动前,需要关闭图形界面

停止桌面服务

系统默认图形界面是gdm3,如果自行安装了lightdm,则需要停止各个服务

systemctl stop gdm3

systemctl stop lightdm
systemctl set-default multi-user.target

进入tty模式

telinit 3

安装依赖

apt install pkg-config libglvnd-dev libglvnd0

安装驱动

linux系统下载的是.run的脚本,ubuntu下载的是.deb的软件包

chmod 755 NVIDIA-Linux-x86_64-525.53.run
sudo sh ./NVIDIA-Linux-x86_64-525.53.run

注意:此处如果添加-no-opengl-files,会导致安装后驱动无法生效。-no-x-check

如果下载的是软件包,则使用以下命令安装

dpkg -i nvidia-driver-local-repo-ubuntu2204-535.161.08_1.0-1_amd64.deb

安装过程中可能遇到的选项

选项翻译选择
Install NVIDIA'S 32-BIT compatibility libraries?英伟达32位兼容库NO
Would you like to register the kernel module sources with DKMS? This will allow DKMS to automatically build a new module, if your kernel changes later.是否安装DKMS,这会引起内核变化YES
The initramfs will likely need to be rebuilt是否重建内核引导(Initramfs)Rebuild
Would you like to run the nvidia-xconfig utility to automatically update your X configuration file so that the NVIDIA X driver dill be used dhen you restart X?Any pre-existing X configuration file will be backed up.是否要通过英伟达的xconfig自动更新配置XNO

返回图形界面

关闭tty

telinit 5

启动图形界面服务

systemctl start lightdm
systemctl set-default graphical.target

判断是否安装成功

  • 终端输入nvidia-smi,查看是否有输出内容
  • 在系统设置-关于选项中,查看是否识别到显卡驱动

[可选]安装UE运行依赖

安装Vulkan

apt install libvulkan1

查看libvulkan1信息

dpkg -s libvulkan1

输出

Package: libvulkan1
Status: install ok installed
Priority: optional
Section: libs
Installed-Size: 494
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: amd64
Multi-Arch: same
Source: vulkan-loader
Version: 1.3.204.1-2
Replaces: libvulkan-dev (<< 1.1.70+dfsg1-2), vulkan-loader
Depends: libc6 (>= 2.34)
Recommends: mesa-vulkan-drivers | vulkan-icd
Breaks: libvulkan-dev (<< 1.1.70+dfsg1-2), vulkan-loader
Description: Vulkan loader library
 The Loader implements the main VK library. It handles layer management and
 driver management. The loader fully supports multi-gpu operation. As part of
 this, it dispatches API calls to the correct driver, and to the correct
 layers, based on the GPU object selected by the application.
 .
 This package includes the loader library.
Original-Maintainer: Debian X Strike Force <debian-x@lists.debian.org>
Homepage: https://github.com/KhronosGroup/Vulkan-Loader

查看配置文件

cat /etc/vulkan/icd.d/nvidia_icd.json

输出

{
    "file_format_version" : "1.0.0",
    "ICD": {
        "library_path": "libGLX_nvidia.so.0",
        "api_version" : "1.3.204"
    }
}

依赖项

apt install -y libasound2 libfreetype6 libglib2.0-dev libxrandr2 libnss3 libatk1.0-0 libatk-bridge2.0-0 libxcomposite1 libxcursor1 libxdamage1 libxi6 libpangocairo-1.0-0 libxss1 libxkbcommon-x11-0

卸载驱动

如果安装完成后,无法正确识别到显卡驱动,则先卸载驱动后,再次尝试安装

查看显卡信息

lspci | grep -i vga
lspci | grep -i nvidia

查找已安装的显卡相关包

dpkg -l | grep nvidia

删除显卡相关包

dpkg -P $(dpkg -l | grep nvidia-driver | awk '{print $2}')

apt --purge remove "*nvidia*" "*cublas*" "cuda*"
apt autoremove

最后,查看系统DKMS模块,中是否存在nvidia信息

dkms status

删除相关信息

dkms remove <名称>/<版本> --all

例如:

dkms remove nvidia/535.183.01 --all
文章作者:DOTATONG
发布日期:2024-04-07

评论

暂无

添加新评论