others-how to solve Unable to find the kernel source tree for the currently runnina kernel problem when trying to install nvidia GPU driver?
1. Purpose
In this post, I will show you how to solve the following error when trying to install Nvidia GPU driver on CentOS:
ERROR :
Unable to find the kernel source tree for the currently runnina 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
*ernel-source'or "kernel-deyel' py installed, Tf you know the correct kernel source files are installed, you may specify the
kernel source path with the '--kernel-source-path' command line option.
OK
2. Solution
The reason of this problem is that the linux kernal of the system does not match the nvidia drivers.
How to solve this problem?
You can just disable the nouveau driver installed by the linux system.
Nouveau
is a third-party open source Nvidia driver. Generally, this driver will be installed by default during Linux installation. This driver will conflict with the official Nvidia driver. Nouveau should be disabled before installing the Nvidia driver and CUDA.
First ,you should check if the system is using nouveau:
lsmod | grep nouveau
If there is any display content, perform the following steps:
sudo vim /etc/modprobe.d/blacklist-nouveau.conf
write the following content in the above file:
blacklist nouveau
options nouveau modeset=0
Then, we should backup your image:
sudo mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak
sudo dracut /boot/initramfs-$(uname -r).img $(uname -r)
At last, you should reboot the system:
sudo reboot
After reboot, you can check if the nouveau is disabled:
lsmod | grep nouveau
If there is nothing displayed, you can continue to install nvidia driver.
If you get the following warning:
WARNING: nvidia-installer was forced to guess the X library path '/usr/lib64' and X module path '/usr/lib64/xorg/modules'; these paths
were not queryable from the system. If X fails to find the NVIDIA X driver module, please install the `pkg-config` utility and the X.Org SDK/development package for your distribution and reinstall the driver.
You can just ignore the above message, continue the installation.
Installation of the NVIDIA Accelerated Graphics Driver for Linux-x86_64 (version: 535.104.05) is now complete.
Now verify the installation:
3. Summary
In this post, I demonstrated how to install the nvidia driver if you encountered some problems. That’s it, thanks for your reading.