CentOS 7 安装 NVIDIA 显卡驱动

CentOS 7 安装 NVIDIA 显卡驱动主要有两种方式:

  1. 通过三方库EPEL安装
  2. 通过NVIDIA官方安装包安装

小C最先尝试的第一种通过EPEL仓库安装,虽然安装过程没有出现问题,但是NVIDIA驱动并没有生效,折腾了很久都没有成功。最后还是通过第二种:NVIDIA官方安装包安装成功!

CentOS 7 安装 NVIDIA 显卡驱动

屏蔽 nouveau 驱动

nouveau 是系统自带的一个显示驱动程序,需要先将其禁用,然后再进行下一步操作。
在 /lib/modprobe.d/dist-blacklist.conf 中,将 nvidiafb 注释掉:

#blacklist nvidiafb

再在该行下一行添加一下配置:

blacklist nouveau  
options nouveau modeset=0 

最后整个文件看起来就像下面这样:

[root@test ]# vi /lib/modprobe.d/dist-blacklist.conf 

#
# Listing a module here prevents the hotplug scripts from loading it.
# Usually that'd be so that some other driver will bind it instead,
# no matter which driver happens to get probed first.  Sometimes user
# mode tools can also control driver binding.
#
# Syntax: see modprobe.conf(5).
#

# watchdog drivers
blacklist i8xx_tco

# framebuffer drivers
blacklist aty128fb
blacklist atyfb
blacklist radeonfb
blacklist i810fb
blacklist cirrusfb
blacklist intelfb
blacklist kyrofb
blacklist i2c-matroxfb
blacklist hgafb
#blacklist nvidiafb
blacklist nouveau
options nouveau modeset=0 
blacklist rivafb
blacklist savagefb
blacklist sstfb
blacklist neofb
blacklist tridentfb
blacklist tdfxfb
blacklist virgefb
blacklist vga16fb
blacklist viafb

# ISDN - see bugs 154799, 159068
blacklist hisax
blacklist hisax_fcpcipnp

重建initramfs 镜像

如果 /boot 分区大小不够,可以备份到其他目录

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

更改为终端模式

如果之前在图形界面操作,需要改为终端模式,runlevel 改为 3

systemctl set-default multi-user.target

安装 kernel-devel

需要 kernel-devel 的支持。

yum install kernel-devel -y

如果你通过 elrepo 升级过 kernel,那么通过如下命令安装:

yum install kernel-ml-devel.x86_64 -y

杀掉 X 相关的进程

ps -ax | grep X

输出示例如下:

[root@nvss239 jstnvr]# ps -ax | grep X
 1201 ?        Ss     0:00 /usr/bin/abrt-watch-log -F Backtrace /var/log/Xorg.0.log -- /usr/bin/abrt-dump-xorg -xD
 1557 tty1     Ssl+   8:39 /usr/bin/X :0 -background none -noreset -audit 4 -verbose -auth /run/gdm/auth-for-gdm-EVsyyE/database -seat seat0 -nolisten tcp vt1
 9863 pts/0    Sl     0:00 /usr/bin/Xvnc :1 -auth /root/.Xauthority -desktop nvss239:1 (root) -fp catalogue:/etc/X11/fontpath.d -geometry 1024x768 -pn -rfbauth /root/.vnc/passwd -rfbport 5901 -rfbwait 30000
10043 ?        Ss     0:00 /usr/bin/ssh-agent /etc/X11/xinit/Xclients
14742 pts/0    S+     0:00 grep --color=auto X

那么通过如下命令杀掉所有相关进程:

kill 1201 1557 9863 10043

安装 NVIDIA 显卡驱动

  1. 首先去官网下载你显卡对应的驱动
    https://www.geforce.com/drivers
  2. 然后执行如下命令开始 NVIDIA 显卡驱动的安装:
bash ./NVIDIA-Linux-x86_64-430.40.run -k $(uname -r)

必须带上 -k 参数,不然会安装失败。

启用桌面模式

之前我们更改了操作模式为终端模式,现在改回桌面模式。

systemctl set-default graphical.target

重启系统

reboot

检查驱动安装情况

执行 NVIDIA 官方工具检测驱动安装情况:

nvidia-smi

示例输出如下:

[root@test ]# nvidia-smi 
Tue Aug 20 21:19:31 2019       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.42                 Driver Version: 390.42                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GT 1030     Off  | 00000000:01:00.0 Off |                  N/A |
| 34%   42C    P8    N/A /  30W |   1118MiB /  2001MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
至此,我们就完成了 CentOS 7 系统下 NVIDIA 显卡驱动的安装!
0 0 投票数
喜欢就给个好评吧!
赞(1) 打赏
未经允许不得转载:爱易默博客 » CentOS 7 安装 NVIDIA 显卡驱动
订阅评论
提醒
guest
0 评论
内联反馈
查看所有评论
免责声明:本站大部分下载资源收集于网络,只做学习和交流使用,版权归原作者所有,请在下载后24小时之内自觉删除,若作商业用途,请购买正版,由于未及时购买和付费发生的侵权行为,与本站无关。本站发布的内容若侵犯到您的权益,请联系站长删除,我们将及时处理! Disclaimer: Most of the download resources on this site are collected on the Internet, and are only used for learning and communication. The copyright belongs to the original author. Please consciously delete within 24 hours after downloading. If you use it for commercial purposes, please purchase the original version. If the content posted on this site violates your rights, please contact us to delete it, and we will deal with it in time!

联系我们 Contact us

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏

0
希望看到您的想法,请您发表评论x