CentOS 7安装Nvidia驱动
使用runfile的方式安装NVIDIA驱动

本文记录了CentOS 7下以 runfile
形式安装Nvidia驱动的过程。
准备工作
明确操作系统信息。
cat /proc/version
Linux version 3.10.0-1160.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Mon Oct 19 16:18:59 UTC 2020
明确显卡硬件信息。
/sbin/lshw -c display
*-display
description: VGA compatible controller
product: GM200 [GeForce GTX 980 Ti]
vendor: NVIDIA Corporation
physical id: 0
bus info: pci@0000:04:00.0
version: a1
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress vga_controller bus_master cap_list rom
configuration: driver=nouveau latency=0
resources: iomemory:3bf0-3bef iomemory:3bf0-3bef irq:64 memory:91000000-91ffffff memory:3bfe0000000-3bfefffffff memory:3bff0000000-3bff1ffffff ioport:2000(size=128) memory:92080000-920fffff
下载驱动
访问下方Nvidia官方驱动下载网站,按照实际的硬件规格获取最新驱动版本。
Download the latest official NVIDIA drivers
Download the latest official NVIDIA drivers

最终会获得驱动版本与下载按钮。

点击下载即可获得驱动文件的地址。示例中的地址如下:
https://us.download.nvidia.com/XFree86/Linux-x86_64/510.54/NVIDIA-Linux-x86_64-510.54.run
获得下载地址后,使用curl将文件下载到本地。
curl -SL https://us.download.nvidia.com/XFree86/Linux-x86_64/510.54/NVIDIA-Linux-x86_64-510.54.run -O
安装驱动
💡
以下操作均以root用户身份执行。
禁用旧驱动
在终端中执行:
sh NVIDIA-Linux-x86_64-510.54.run
此时会提示 Nouveau
驱动正在使用中。

点击确定后,会弹出建议解决方法。选择Yes,回车。

此时会弹出提示操作完成,回车确认。

至此仅仅完成了旧驱动的禁用操作,还未安装新驱动,因此会显示驱动安装失败。没关系,重新启动机器。
启动安装
继续回到中断,再次执行安装指令。
sh NVIDIA-Linux-x86_64-510.54.run
此次可能会报其它错误,例如:
找不到编译器

类似的错误可以通过 yum
管理器安装缺失的组件即可。
yum install gcc
Kernel source files缺失

安装缺失的包。
yum install -y kernel-devel-$(uname -r) kernel-headers-$(uname -r)
找不到X library path


对于服务器端来说可以不理会X服务。
启用32位支持

此项视情况,我最后选择的是“No”。
安装到最后最显示安装成功提示。

验证安装结果
使用 nvidia-smi
命令验证:
nvidia-smi
Wed Feb 23 11:47:34 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 510.54 Driver Version: 510.54 CUDA Version: 11.6 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... Off | 00000000:04:00.0 Off | N/A |
| 18% 28C P0 62W / 250W | 0MiB / 6144MiB | 2% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+
至此安装过程结束。
如果你在安装过程中遇到问题,可以参考官方的安装指南。注意匹配版本。
NVIDIA Accelerated Linux Graphics Driver README andInstallation Guide
Comments ()