1.查看是否含有英伟达显卡
#下面说明有四块英伟达的显卡
[admin@A01-R15-I47-118-0825868 http-cnn-rnn]$ lspci | grep -i NVIDIA
02:00.0 3D controller: NVIDIA Corporation Device 1b38 (rev a1)
03:00.0 3D controller: NVIDIA Corporation Device 1b38 (rev a1)
83:00.0 3D controller: NVIDIA Corporation Device 1b38 (rev a1)
84:00.0 3D controller: NVIDIA Corporation Device 1b38 (rev a1)
2.从ELRepo源安装显卡驱动(以下操作均以root权限运行)
ELRepo源提供了nvidia-detect命令,会自动帮你寻找合适的驱动,然后根据显示的结果,用yum就能完成安装,重启之后不会有任何问题,省时省力
2.1添加ELRepo源
2.1.1首先导入公共密钥
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
2.1.2安装ELRepo
http://elrepo.org/tiki/tiki-index.php
#centos7
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
#centos6
rpm -Uvh http://www.elrepo.org/elrepo-release-6-6.el6.elrepo.noarch.rpm
#centos5
rpm -Uvh http://www.elrepo.org/elrepo-release-5-5.el5.elrepo.noarch.rpm
2.2查找合适的驱动
2.2.1 安装nvidia-detect
yum install nvidia-detect
2.2.2 运行nvidia-detect
[admin@A01-R15-I47-118-0825868 http-cnn-rnn]$ nvidia-detect
kmod-nvidia
WARNING: Xorg log file /var/log/Xorg.0.log does not exist
WARNING: Unable to determine Xorg ABI compatibility
WARNING: The driver for this device does not support the current Xorg version
#说明需要的驱动是最新的驱动 不用指定版本 默认下载最新的
[admin@A01-R15-I47-118-0825868 software]$ nvidia-detect -v
Probing for supported NVIDIA devices...
[10de:1b38] NVIDIA Corporation Device 1b38
This device requires the current 418.43 NVIDIA driver kmod-nvidia
[10de:1b38] NVIDIA Corporation Device 1b38
This device requires the current 418.43 NVIDIA driver kmod-nvidia
[1a03:2000] ASPEED Technology, Inc. ASPEED Graphics Family
[10de:1b38] NVIDIA Corporation Device 1b38
This device requires the current 418.43 NVIDIA driver kmod-nvidia
[10de:1b38] NVIDIA Corporation Device 1b38
This device requires the current 418.43 NVIDIA driver kmod-nvidia
WARNING: Xorg log file /var/log/Xorg.0.log does not exist
WARNING: Unable to determine Xorg ABI compatibility
WARNING: The driver for this device does not support the current Xorg version
根据 nvidia-detect 的输出信息,可以知道显卡的型号,以及要使用的驱动版本 418.43。
2.3安装显卡驱动
2.3.1 查找驱动程序
[admin@A01-R15-I47-118-0825868 http-cnn-rnn]$ yum search kmod-nvidia
Loaded plugins: fastestmirror, langpacks, nvidia
Determining fastest mirrors
* elrepo: mirrors.tuna.tsinghua.edu.cn
========================================== N/S matched: kmod-nvidia ===========================================
kmod-nvidia.x86_64 : nvidia kernel module(s)
kmod-nvidia-340xx.x86_64 : nvidia-340xx kernel module(s)
kmod-nvidia-390xx.x86_64 : nvidia-390xx kernel module(s)
Name and summary matches only, use "search all" for everything.
2.3.2 安装驱动程序
sudo yum install kmod-nvidia.x86_64
2.4 Disabling Nouveau
lsmod | grep nouveau
#若没有输出 则说明禁用成功,否则执行下面的命令
Create a file at /etc/modprobe.d/blacklist-nouveau.conf with the following contents:
blacklist nouveau
options nouveau modeset=0
Regenerate the kernel initramfs:
$ sudo dracut --force
2.5 重启
[admin@A01-R15-I47-118-0825868 software]$ nvidia-smi
NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver.
Make sure that the latest NVIDIA driver is installed and running.
说明需要重新启动
reboot
2.6测试
[admin@A01-R15-I47-118-0825868 users]$ nvidia-smi
Thu Mar 7 16:42:19 2019
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 418.43 Driver Version: 418.43 CUDA Version: 10.1 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 Tesla P40 Off | 00000000:02:00.0 Off | 0 |
| N/A 27C P0 50W / 250W | 0MiB / 22919MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
| 1 Tesla P40 Off | 00000000:03:00.0 Off | 0 |
| N/A 24C P0 50W / 250W | 0MiB / 22919MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
| 2 Tesla P40 Off | 00000000:83:00.0 Off | 0 |
| N/A 26C P0 50W / 250W | 0MiB / 22919MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
| 3 Tesla P40 Off | 00000000:84:00.0 Off | 0 |
| N/A 25C P0 49W / 250W | 0MiB / 22919MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+