centos7安装NVIDIA gpu驱动


1.官网下载对应型号的驱动:

https://www.nvidia.com/Download/index.aspx

我的gpu型号是telsa m40,系统是centos7.7

2.下载CUDA Toolkit

https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=CentOS&target_version=7&target_type=runfilelocal

我下载的最新版

wget http://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda_10.2.89_440.33.01_linux.run

3.安装依赖包

yum -y install kernel-devel kernel-doc kernel-headers gcc gcc-c++

4.关闭原有驱动

使用su命令切换到root用户下: su root

打开/etc/modprobe.d/dist-blacklist.conf

将nvidiafb注释掉。

#blacklist nvidiafb
然后添加以下语句:

blacklist nouveau

options nouveau modeset=0

重建initramfs image步骤

mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak

dracut /boot/initramfs-$(uname -r).img $(uname -r)

重启系统
5.切换到文本模式
ini 3
执行安装驱动
./NVIDIA-Linux-x86_64-440.33.01.run --kernel-source-path=/usr/src/kernels/3.10.0-1062.4.3.el7.x86_64/

安装cuda

./cuda_10.2.89_440.33.01_linux.run

测试显卡驱动

[root@gpu ~]# nvidia-smi
Mon Dec 2 13:34:50 2019
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.33.01 Driver Version: 440.33.01 CUDA Version: 10.2 |
|-------------------------------+----------------------+----------------------+
| 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 M40 Off | 00000000:04:00.0 Off | 0 |
| N/A 33C P0 65W / 250W | 0MiB / 11448MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
| 1 Tesla M40 Off | 00000000:82:00.0 Off | 0 |
| N/A 32C P0 64W / 250W | 0MiB / 11448MiB | 2% Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+


Whatever is worth doing is worth doing well.