0、确认显卡和下载驱动

lspci | grep -i nvidia

image-20231126212913295

在pic的页面里查询型号对应的真实型号:https://admin.pci-ids.ucw.cz//mods/PC/10de/

image-20231126213141752

根据真实的显卡进行驱动的下载

下载地址:https://www.nvidia.cn/Download/index.aspx?lang=cn

1、屏蔽系统自带的nouveau

Linux系统一般默认安装的是开源的nouvea显卡驱动,它与nvidia显卡驱动产生冲突

# 查看命令:

lsmod | grep nouveau

# 修改dist-blacklist.conf文件:

vi /lib/modprobe.d/dist-blacklist.conf

# 将nvidiafb注释掉: #blacklist nvidiafb

# 快捷命令
sed -i 'szblacklist nvidiafbz#blacklist nvidiafbzg' /lib/modprobe.d/dist-blacklist.conf

接着添加以下语句:

blacklist nouveau
options nouveau modeset=0

# 快捷命令
cat >> /lib/modprobe.d/dist-blacklist.conf <<EOF
blacklist nouveau
options nouveau modeset=0
EOF

#重建initramfs image步骤

# 备份内核文件
mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak
dracut /boot/initramfs-$(uname -r).img $(uname -r)

# 修改运行级别为文本模式

systemctl set-default multi-user.target

# 重启服务器
reboot

2、下载安装

# 保证内核版本和源码版本一样,否则,安装报错误

若内核和源码需要从FC官方网站上下载与内核版本对应的源码包devel与headers两个包进行安装。

可以在以下网站下载并安装:

http://rpmfind.net/linux/rpm2html/search.php?query=kernel-devel

http://rpmfind.net/linux/rpm2html/search.php?query=kernel-headers

#龙蜥os 7.9下载:
http://mirrors.openanolis.cn/anolis/7.9/Plus/x86_64/os/Packages/
rpm -ivh kernel-devel-4.19.91-25.2.an7.x86_64.rpm --nodeps --force

rpm -ivh kernel-headers-4.19.91-25.2.an7.x86_64.rpm --force

chmod +x NVIDIA-Linux-x86_64-535.129.03.run #刚才下载的显卡驱动

sh NVIDIA-Linux-x86_64-535.129.03.run -no-x-check

2.1进入安装界面 有以下几种情况

The distribution-provided pre-install script failed! Are you sure you want to continue?

选择 yes 继续。

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 继续。

Nvidia's 32-bit compatibility libraries?

选择 No 继续。

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

2.2安装成功后查看配置信息

nvidia-smi

image-20231129230318674