借鉴博客:地址
一、安装NVIDIA 显卡驱动
1、屏蔽 nouveau 驱动
编写(如果没有会新建),下面两个文件
# vi /etc/modprobe.d/nvidia-installer-disable-nouveau.conf
# vi /lib/modprobe.d/nvidia-installer-disable-nouveau.conf
在两个文件下写入如下内容
blacklist nouveau
options nouveau modeset=0
2、重做 initramfs 镜像
①给当前镜像做备份
cp /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak
②建立新的镜像
dracut /boot/initramfs-$(uname -r).img $(uname -r)
③重启
reboot
3、预安装组件(联网)
yum install gcc kernel-devel kernel-headers
4、根据当前系统内核下载 NVIDIA 官方驱动
地址:https://www.nvidia.cn/Download/index.aspx?lang=cn#
5、安装 NVIDIA驱动
执行如下的安装步骤,必需指定 kernel source path,否则会报错;kernel 的版本和系统内核有关,可能会有差别
①定位到驱动下载到的目录
②执行
./NVIDIA-Linux-x86_64-450.66.run --kernel-source-path=/usr/src/kernels/3.10.0-1127.19.1.el7.x86_64 -k $(uname -r)
说明:
-
NVIDIA-Linux-x86_64-450.66.run是下载的驱动;
-
3.10.0-1127.19.1.el7.x86_64是通过ll /usr/src/kernels/命令查看的系统内核源码
6、安装解压
Verifying archive integrity... OK
Uncompressing NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81.......................................
..................................................................
..................................................................
常规选择即可
安装 32 位兼容库 -yes
PS:大多数默认选择就可以,有一些是与NVIDIA做后期交互的一些选择,也是默认即可
7、验证
执行:
lspci |grep NVIDIA
nvidia-smi
如下效果表示安装成功
二、安装CUDA驱动
1、下载CUDA
地址:https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=CentOS&target_version=7&target_type=rpmnetwork
根据提供地址,下载到本地
2、安装
安装执行:
./cuda_11.0.3_450.51.06_linux.run
此时可能会出现权限不足的情况,需要进行授权,这里我直接给了最高权限
chmod 777 cuda_11.0.3_450.51.06_linux.run
之后会出现协议,选择接受:
安装:
这里面不需要再装显卡驱动了(这里截图有错)
出现了警告信息,对安装无影响
截图日志:
[root@host83 masr]# sudo sh cuda_11.0.3_450.51.06_linux.run
===========
= Summary =
===========
Driver: Not Selected
Toolkit: Installed in /usr/local/cuda-11.0/
Samples: Installed in /root/, but missing recommended libraries
Please make sure that
- PATH includes /usr/local/cuda-11.0/bin
- LD_LIBRARY_PATH includes /usr/local/cuda-11.0/lib64, or, add /usr/local/cuda-11.0/lib64 to /etc/ld.so.conf and run ldconfig as root
To uninstall the CUDA Toolkit, run cuda-uninstaller in /usr/local/cuda-11.0/bin
***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least .00 is required for CUDA 11.0 functionality to work.
To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file:
sudo <CudaInstaller>.run --silent --driver
Logfile is /var/log/cuda-installer.log
也可以进入日志进行查看(位置如下):
/var/log/cuda-installer.log
3、 配置环境变量
vi /etc/profile
进入文件,添加配置
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
使环境变量立即生效
source /etc/profile ;
安装完成!
若有帮助记得点赞哦~