预、查询命令
1、Linux查看显卡信息:(ps:若找不到lspci命令,可以安装 yum install pciutils) lspci | grep -i vga 2、使用nvidia GPU可以: lspci | grep -i nvidia 3、查看显卡驱动 cat /proc/driver/nvidia/version
一、前提准备
1.安装依赖环境:
yum install kernel-devel gcc -y
2.检查内核版本和源码版本,保证一致
ls /boot | grep vmlinu rpm -aq | grep kernel-devel
3.屏蔽系统自带的nouveau
查看命令: lsmod | grep nouveau 修改dist-blacklist.conf文件: vim /lib/modprobe.d/dist-blacklist.conf 将nvidiafb注释掉: #blacklist nvidiafb 然后添加以下语句: blacklist nouveau options nouveau modeset=0
屏蔽前
屏蔽后
4.重建initramfs image步骤
mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak dracut /boot/initramfs-$(uname -r).img $(uname -r)
5.修改运行级别为文本模式
systemctl set-default multi-user.target
6.重新启动
reboot
二、本地安装
1.在NVIDIA官网下载驱动
查询显卡型号
lspci | grep -i nvidia
2.安装过程
chmod +x NVIDIA-Linux-x86_64-440.64.run ./NVIDIA-Linux-x86_64-440.64.run
3.如果报错 unable to find the kernel source tree for the currently running kernel………,使用下面命令安装,3.10.0-1062.18.1.el7.x86_64需要改成自己的目录
./NVIDIA-Linux-x86_64-440.64.run --kernel-source-path=/usr/src/kernels/3.10.0-1062.18.1.el7.x86_64 -k $(uname -r)
4.安装成功
nvidia-smi
三、安装cuda
上图所示,CUDA version最高支持10.2
https://developer.nvidia.com/cuda-toolkit-archive
wget https://developer.download.nvidia.com/compute/cuda/12.3.0/local_installers/cuda-repo-rhel7-12-3-local-12.3.0_545.23.06-1.x86_64.rpm
sudo rpm -i cuda-repo-rhel7-12-3-local-12.3.0_545.23.06-1.x86_64.rpm
sudo yum clean all
sudo yum -y install cuda-toolkit-12-3
或
sudo yum install cuda
查询是否安装成功,根据自己的CUDA版本号来配置环境变量
这里以cuda10.1为例,cuda安装后好,目录在/usr/local/cuda-10.1
vi /etc/profile # cuda在最后加上三句话env export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-10.1/lib64 export PATH=$PATH:/usr/local/cuda-10.1/bin export CUDA_HOME=$CUDA_HOME:/usr/local/cuda-10.1 # 或 export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64 export PATH=$PATH:/usr/local/cuda-10.1/bin export CUDA_HOME=/usr/local/cuda-10.1 # 使配置生效 source /etc/profile
查看CUDA版本:
nvcc -V