查看显卡型号是否支持双显卡
lspci | grep VGA
00:02.0 VGA compatible controller: Intel Corporation HD Graphics 520 (rev 07)
lspci | grep 3D
01:00.0 3D controller: NVIDIA Corporation GM108M [GeForce 940MX] (rev a2)
安装nvidia-detect检查显卡型号
yum install nvidia-detect
Installed:
nvidia-detect.x86_64 0:384.90-1.el7.elrepo
nvidia-detect -v
Probing for supported NVIDIA devices...
[10de:134d] NVIDIA Corporation
GM108M [GeForce 940MX]
This device requires the current
384.98 NVIDIA driver kmod-nvidia
[8086:1916] Intel Corporation
HD Graphics 520
An Intel display controller was also detected
更新最新内核和内核开发文件
yum update kernel kernel-devel
Installed:
kernel.x86_64 0:3.10.0-514.21.1.el7 kernel-devel.x86_64 0:3.10.0-514.21.1.el7
rpm -qa
kernel*
kernel-tools-3.10.0-693.5.2.el7.x86_64
kernel-3.10.0-693.5.2.el7.x86_64
kernel-devel-3.10.0-693.5.2.el7.x86_64
kernel-headers-3.10.0-693.5.2.el7.x86_64
kernel-tools-libs-3.10.0-693.5.2.el7.x86_64
删除多余的内核开发文件
yum remove --nodeps
*****
启用默认版本内核
首先查看默认启动内核版本
uname -a
Linux THTF
3.10.0-693.2.2.el7.x86_64 #1 SMP Tue Sep 12 22:26:13 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
cat /boot/grub2/grub.cfg | grep
3.10.0-693.5.2.el7.x86_64
menuentry 'CentOS Linux (3.10.0-693.5.2.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-693.el7.x86_64-advanced-e7d7b9e7-f593-4c29-b5db-4ccd7a7dc0d6' {
linux16 /vmlinuz-
3.10.0-693.5.2.el7.x86_64 root=/dev/mapper/vg_centos-lv_root ro rd.lvm.lv=vg_centos/lv_root rd.lvm.lv=vg_centos/lv_swap rhgb quietLANG=en_US.UTF-8
initrd16 /initramfs-
3.10.0-693.5.2.el7.x86_64.img
设置默认内核(如果有多个内核)
grub2-set-default "CentOS Linux (3.10.0-693.5.2.el7.x86_64) 7 (Core)
"
验证是否成功
grub2-editenv list
禁用nouveau驱动
lsmod | grep nouveau
nouveau 1527946 0
mxm_wmi 13021 1 nouveau
ttm 93908 1 nouveau
i2c_algo_bit 13413 2 i915,nouveau
drm_kms_helper 146456 2 i915,nouveau
drm 372540 8 ttm,i915,drm_kms_helper,nouveau
wmi 19070 2 mxm_wmi,nouveau
video 24400 2 i915,nouveau
i2c_core 40756 8 drm,i915,i2c_i801,i2c_hid,drm_kms_helper,i2c_algo_bit,nouveau,videodev
vi /lib/modprobe.d/dist-blacklist.conf
#blacklist nvidiafb
blacklist nouveau options nouveau modeset=0
更改grub2配置禁用nouveau
vi /etc/default/grub
GRUB_CMDLINE_LINUX="rd.lvm.lv=vg_centos/lv_root rd.lvm.lv=vg_centos/lv_swap rhgb quiet rdblacklist=nouveau"
重新生成grub.cfg
grub2-mkconfig -o /boot/grub2/grub.cfg
设置为文本模式启动
systemctl set-default multi-user.target
reboot
查看nouveau是否被禁用
lsmod | grep nouveau
输出空白,说明禁用成功
安装kmod-nvidia驱动
yum -y install kmod-nvidia
kmod-nvidia.x86_64 0:
384.98
-1.el7_4.elrepo
nvidia-x11-drv.x86_64 0:
384.98
-1.el7.elrepo
yum-plugin-nvidia.noarch 0:1.0.2-1.el7.elrepo
*如果安装不成功,有可能是没有配置/etc/X11/xorg.conf
nvidia-xconfig
重建内核initramfs image
备份initramfs image
mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak
重建initramfs image
dracut /boot/initramfs-$(uname -r).img $(uname -r)
cat /etc/group | grep bumblebee
bumblebee:x:1001:
usermod -a root -G bumblebee
usermod -a david -G bumblebee
cat /etc/group | grep bumblebee
bumblebee:x:1001:root,david
配置bumblebee.conf
vi /etc/bumblebee/bumblebee.conf
[bumblebeed]
Driver
=
nvidia
[optirun]
Bridge=
auto
[driver-nvidia]
KernelDriver=
nvidia
PMMethod=
bbswitch
LibraryPath=
/usr/lib64/nvidia:/usr/lib64/vdpau:/usr/lib/nvidia:/usr/lib/vdpau
XorgModulePath=
/usr/lib64/xorg/modules/extensions/nvidia,/usr/lib64/xorg/modules/drivers,/usr/lib64/xorg/modules
编辑nvidia-settings.desktop
vi /usr/share/applications/nvidia-settings.desktop
Exec=optirun nvidia-settings -c :8.0
设置图形模式启动
systemctl set-default
graphical.target
reboot
选择kmod-nvidia驱动关联的内核版本启动
测试是否安装成功
optirun
glxgears
optirun
glxspheres64
启动加载nvidia驱动
vi /boot/grub2/grub.cfg
在启动选项里,kernel那一条的后面追加
vga=792
参照表格:
http://elrepo.org/tiki/kmod-nvidia