在CentOS 7上安装NVIDIA T4驱动。

确认显卡设备

首先确认服务器上已有NVIDIA显卡。通过lshw -short命令查看,如果lshw命令找不到,可以通过yum install lshw进行安装。

下载驱动安装包

然后是下载安装程序。驱动的下载地址为:https://www.nvidia.com/Download/index.aspx?lang=en-us。选择需要的驱动版本

下载完成后是一个sh脚本,文件名为:NVIDIA-Linux-x86_64-460.106.00.run。将文件上传至服务器。在正式安装前,服务器上需要做一下准备工作。

安装前准备工作

安装GCC和Linux的头文件。如果yum install没有找到对应的包,可以网上下载rpm包进行安装。

1
2
3
yum install kernel-devel-$(uname -r) kernel-headers-$(uname -r)

rpm -ivh xxxx.rpm

禁用原来的显卡驱动。

1
2
3
4
5
6
7
8
9
echo -e "blacklist nouveau\noptions nouveau modeset=0" > /etc/modprobe.d/disable-nouveau.conf

#在centos里是执行这个命令
dracut --regenerate-all -f

#在ubuntu中是执行这个命令
update-initramfs -u

reboot

安装驱动

最后就可以执行驱动安装命令了:sh NVIDIA-Linux-x86_64-460.106.00.run -no-x-check -no-nouveau-check -no-opengl-files

安装完成后,可以测试一下nvidia-smi命令是否正常。

FAQ

Unable to load the kernel module 'nvidia.ko'. This happens most frequently when this kernel module was built against the wrong or improperly configured kernel sources, with a version of gcc that differs from the one used to build the target kernel, or if another driver, such as nouveau, is present and prevents the NVIDIA kernel module from obtaining ownership of the NVI

这个报错原因是没有禁用老的显卡驱动。可以参考安装前准备工作操作。