安装基础依赖环境

Yum install gcc kernel-delve -y

注意事项,保证内核版本和源码版本一样,否则,安装报错误6:

  • 查看内核版本:ls /boot | grep vmlinu

  • 查看源码包版本rpm -aq | grep kernel-devel

从上面的输出中可以看出内核版本号和内核源码版本。为了解决这个错误,需要从FC官方网站上下载与内核版本对应的源码包进行安装。
可以在以下网站下载并安装:
http://rpmfind.net/linux/rpm2html/search.php?query=kernel-devel

源码安装

1 在英伟达官网下载相应驱动

搜索出相应的驱动后,不要直接点,而是右健,Save Link as…
否则,会出现下载半天没动静的情况。
存放的路径上最好不要有中文。
我存放的路径是 ~/Downloads/NVIDIA-Linux-x86_64-346.47.run

2 屏蔽默认带有的nouveau

使用su命令切换到root用户下: su root
打开/lib/modprobe.d/dist-blacklist.conf

将nvidiafb注释掉。
#blacklist nvidiafb

然后添加以下语句:

blacklist nouveau options nouveau modeset=0

3 重建initramfs image步骤

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

4 修改运行级别为文本模式

systemctl set-default multi-user.target

5 重新启动, 使用root用户登陆

reboot

6 查看nouveau是否已经禁用

ls mod | grep nouveau

如果没有显示相关的内容,说明已禁用。

7 进入下载的驱动所在目录

chmod +x NVIDIA-Linux-x86_64-346.47.run ./NVIDIA-Linux-x86_64-346.47.run
安装过程中,选择accept
如果提示要修改xorg.conf,选择yes

8 修改运行级别回图形模式

systemctl set-default graphical.target

9 重新启动,OK

在Applications—Other可以看见NVIDIA X Server Settings菜单。

问题:

错误1:

ERROR: The Nouveau kernel driver is currently in use by your system. This driver is incompatible with the NVIDIA driver, and must be disabled before proceeding. Please consult the NVIDIA driver README and your Linux distribution’s documentation for details on how to correctly disable the Nouveau kernel driver.

解释:如果没有执行屏蔽nouveau操作,报以上错误。

错误2:

unable to find the development too ‘cc’ in you path; please make sure that you have the package ‘gcc

解决办法:
yum install gcc

错误3:

错误4:

ERROR: Unable to find the kernel source tree for the currently running kernel. Please make sure you have installed the kernel source files for your kernel and that they are properly configured; on Red Hat Linux systems, for example, be sure you have the ‘kernel-source’ or ‘kernel-devel’ RPM installed. If you know the correct kernel source files are installed, you may specify the kernel source path with the ‘—kernel-source-path’ command line option.

解决办法:
yum install kernel-delve

错误5:

ERROR: Unable to find the kernel source tree for the currently running kernel. Please make sure you have installed the kernel source files for your kernel and that they are properly configured; on Red Hat Linux systems, for example, be sure you have the ‘kernel-source’ or ‘kernel-devel’ RPM installed. If you know the correct kernel source files are installed, you may specify the kernel source path with the ‘—kernel-source-path’ command line option.

解决方法:
./NVIDIA-Linux-x86_64-390.67.run —kernel-source-path=/usr/src/kernels/3.10.0-862.3.2.el7.x86_64/

错误6:

ERROR: Unable to load the kernel module ‘nvidia.ko’. This happens most frequently when this kernel module was built against the wrong or improperly configured kernel sources, with a version of gcc that differs from the one used to build the target kernel, or if another driver, such as nouveau, is present and prevents the NVIDIA kernel module from obtaining ownership of the NVIDIA GPU(s), or no NVIDIA GPU installed in this system is supported by this NVIDIA Linux graphics driver release. Please see the log entries ‘Kernel module load error’ and ‘Kernel messages’ at the end of the file ‘/var/log/nvidia-installer.log’ for more information.

解决办法:

  • 可以通过以下方式查看内核版本和源码包版本:

    • ls /boot | grep vmlinuz
  • 如果上面的命令输出中有多个内核,则按grub.conf中指定的文件为准。

    • rpm -aq | grep kernel-devel kernel-devel-2.6.35.13-92.fc14.i686
  • 从上面的输出中可以看出内核版本号和内核源码版本。为了解决这个错误,需要从FC官方网站上下载与内核版本对应的源码包进行安装。

可以在以下网站下载并安装:
http://rpmfind.net/linux/rpm2html/search.php?query=kernel-devel
备注:执行更新内核操作好需要重新执行屏蔽nouveau,及重建initramfs image步骤。