centos7.x安装显卡驱动【建议换阿里源】
1.依赖安装
yum -y install gcc kernel-devel kernel-headers
2.备份initramfs image
mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak
3.重建initramfs image
dracut /boot/initramfs-$(uname -r).img $(uname -r)
4.设置自启动
systemctl set-default multi-user.target
5.下载驱动【nvidia管网】
https://www.nvidia.cn/Download/index.aspx?lang=cn
6.执行安装
sh NVIDIA-Linux-x86_64-495.29.05.run -no-x-check -no-nouveau-check -no-opengl-files
7.查看结果
nvidia-smi
一键脚本
# Step 1: Install dependencies
if yum -y install gcc kernel-devel kernel-headers; then
# Step 2: Backup initramfs image
if mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak; then
# Step 3: Rebuild initramfs image
if dracut /boot/initramfs-$(uname -r).img $(uname -r); then
# Step 4: Set default runlevel to multi-user
if systemctl set-default multi-user.target; then
# Step 5: Download and install NVIDIA driver
if wget https://www.nvidia.cn/Download/index.aspx?lang=cn -O NVIDIA-Linux-x86_64-495.29.05.run; then
sh NVIDIA-Linux-x86_64-495.29.05.run -no-x-check -no-nouveau-check -no-opengl-files
else
echo "Failed to download NVIDIA driver."
fi
else
echo "Failed to set default runlevel."
fi
else
echo "Failed to rebuild initramfs image."
fi
else
echo "Failed to backup initramfs image."
fi
else
echo "Failed to install dependencies."
fi