NVIDIA驱动安装

1、安装依赖

yum -y install gcc
yum -y install epel-release
yum -y install --enablerepo=epel dkms
yum install kernel-devel
yum install kernel-headers
uname -r

2、备份

vim /etc/modprobe.d/blacklist.conf
添加如下内容

#nvidia driver
blacklist nouveau
options nouveau modeset=0
mv     /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak 
dracut /boot/initramfs-$(uname -r).img $(uname -r)

测试阿里云的机器不需要重启
自己的机子的话需要重启

3、检查设备型号,下载驱动安装

检查系统版本

uname -a

检测显卡型号

lspci | grep NVIDIA

http://pci-ids.ucw.cz/mods/PC/10de?action=help?help=pci

4 安装驱动

上英伟达官网https://nvidia.cn搜索对应的显卡驱动,下载

cd /to/your/directory/ ;  //跳转到驱动所在的目录

./NVIDIA-Linux-x86_64-450.80.02.run --kernel-source-path=/usr/src/kernels/3.10.0-957.21.3.el7.x86_64  -k $(uname -r)

5 cuda下载安装

下载对应的版本----以下安装脚本针对centos7 x64
https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=CentOS&target_version=7&target_type=runfilelocal

wget https://developer.download.nvidia.com/compute/cuda/11.1.1/local_installers/cuda_11.1.1_455.32.00_linux.run
sh cuda.run

或者

sudo yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo
sudo yum clean all
sudo yum -y install nvidia-driver-latest-dkms cuda
sudo yum -y install cuda-drivers

6、添加PATH环境变量

export PATH=/usr/local/cuda-11.0/bin:${PATH}
export LD_LIBRARY_PATH=/usr/local/cuda-11.0/lib64:${LD_LIBRARY_PATH}

cudnn安装

切换到压缩包所在位置,解压
$ tar -xzvf cudnn-8.0-linux-x64-v5.1.tgz

复制相关文件到cuda特定目录下(我的cuda安装目录为/usr/local/cuda/)

$ sudo cp cuda/include/cudnn.h /usr/local/cuda/include
$ sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64

修改文件权限
$ sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

7、检测是否安装成功

nvidia-smi

8、docker 及nvidia-docker安装

yum -y install yum-utils
nvidia-docker 用来在docker中使用nvidia的cuda运算

https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#installing-on-centos-7-8

你可能感兴趣的:(NVIDIA驱动安装)