cuda 9.1 install fail with ubuntu 16.04 kernel version 4.13.0-26

Installing the NVIDIA display driver…
The driver installation is unable to locate the kernel source. Please make sure that the kernel source packages are installed and set up correctly.
If you know that the kernel source packages are installed and set up correctly, you may pass the location of the kernel source with the ‘–kernel-source-path’ flag.

I witnessed the same behavior.

I even tried following option:

--kernel-source-path=/usr/src/linux-headers-4.13.0-26-generic/

but with no result.

Output of

$uname -r

4.13.0-26-generic

The same problem occurred when I tried installing CUDA 8.0.61 with driver version 375.26.

Any idea?

Probably a temporary solution for me was to downgrade the kernel which comes with a current fresh installation of Ubuntu 16.04 (you can check with uname -r):

sudo apt-get purge linux-image-4.13.0-26-generic
sudo apt-get purge linux-headers-4.13.0-26-generic

Update initramfs image:

sudo update-initramfs -u

Reboot and try again.

Yes, I just found that out as well. Actually the docs say that only 4.4 kernel is accepted currently for Ubuntu 16.04. Basically no LTS support at the moment.

Thank you very much for this, it helped me solve the issue.

Hello! I’ve been getting the same error with cuda 8.0, but I cannot find a way to fix it, could you tell me how it worked for you? :(

Hi natdp94,

It is very simple, if you follow stuhlo’s suggestions. First, you have to use the uname command to find out your kernel version:

uname -r

You will get an output similar to the one provided by stuhlo, such as “4.13.0-26-generic”. With that exact version, you do the following (e.g., assuming that you got that one):

sudo apt-get purge linux-image-4.13.0-26-generic
sudo apt-get purge linux-headers-4.13.0-26-generic

Do not forget to replace “4.13.0-26-generic” with the output from uname. Then, after those two commands have finished, do the following:

sudo update-initramfs -u

And that is it. I rebooted, tried again and it worked.

I hope it helps!

Hi, my pc stopped booting after applying these instructions. I have reinstalled Ubuntu after that and tried again to if I did a mistake or not but no luck.

Again it is not booting after the second fresh-trial. But I have to add that I have blacklisted nouveau kernel driver after a failed attempt of NVIDIA Installation for stopping it. Maybe I can not use these instructions alongside with a blacklisted nouveau?

Update :

Turns out I just purged too much. Corrected my mistake; now I have only 4.4.0-121.
But the problem persists. I still have the error as

“The driver installation is unable to locate the kernel source. Please make sure hat the kernel source packages are installed and set up correctly.
If you know that the kernel source packages are installed and set up correctly, you may pass the location of the kernel source with the ‘–kernel-source-path’ flag”

Ubuntu 16.04 & cuda_9.0.176_384.81_linux-run

Hi 3yanlis1bos,

I honestly do not know how to help with this, sorry! Perhaps someone from NVIDIA will show up and hint something for you and future users coming to the forum.

Also, if you manage to solve it, please, let us all know the solution!

For anyone who is still struggling, someone wrote great instructions for CUDA 8 on Ubuntu 16.04 that might help figuring out issues with CUDA 9 as well:

The one thing in particular that stands out is that some kernel modules are missing in certain virtualized images of Ubuntu so in certain cases you have to install additional modules with apt-get.

The following might be all you need:

apt-get install linux-image-extra-virtual
apt-get install linux-source
apt-get source linux-image-$(uname -r)
apt-get install linux-headers-$(uname -r)