Ubuntu 18.04 LTS - Unable to reinstall any Drivers after last system update

After the last update to my Ubuntu 18.04 LTS system (which included a new Kernel build, and the regeneration of Initramfs), my NVIDIA Drivers resulted to be “broken”. This is a situation that, at least to me, occurred quite often in the past after updating. Usually my solution to this was to completely reinstall the Drivers, and everything went ok after that

This time, when trying to launch the usual ./NVIDIA-Linux-x86_64-418.56.run an error popped up:

The kernel was built with gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3), but the current compiler version is cc (Ubuntu 7.4.0-1ubuntu1~18.04) 7.4.0

Apparently, the new Kernel is built using gcc 7.3, but the default Compiler on my machine remain 7.4, therefore the issue. To get past this, I had to manually specify the Compiler version to use:

CC=gcc-7.3.0 ./NVIDIA-Linux-x86_64-418.56.run

But having done this, I later got another exception:

ERROR: Unable to determine the version of the kernel sources located in ‘/lib/modules/4.15.0-48-generic/build’. Please make sure you have installed the kernel source files for your kernel and that they are properly configured […] you may specify the kernel source path with the ‘–kernel-source-path’ command line option

At this point, given that I know where the Kernel Source is located and that I know that the Kernel Headers are installed, I wanted to try the following as well:

CC=gcc-7.3.0 ./NVIDIA-Linux-x86_64-418.56.run --kernel-source-path=/usr/src/linux-headers-4.15.0-48-generic

But doing this resulted in the same exact error as just above. So I wanted to try playing around slightly modifying the Path to include, in the attempt to include the “kernel.h” file. I ended up with this version of the last command:

CC=gcc-7.3.0 ./NVIDIA-Linux-x86_64-418.56.run --kernel-source-path=/usr/src/linux-headers-4.15.0-48-generic/include

which resulted in a different exception again, this time maybe more explicit:

ERROR: The kernel header file ‘/usr/src/linux-headers-4.15.0-48-generic/include/include/linux/kernel.h’ does not exist. The most likely reason for this is that the kernel source path ‘/usr/src/linux-headers-4.15.0-48-generic/include/include’ is incorrect. […]

The problem is that after this last try I wasn’t able to make any progress. My system is unusable, and I’m completely out of ideas. Any help/inspiration/support from anybody who got past this would be greatly appreciated.

Thanks in advance!

Thou shalt not use the .run installer. Or at least use the --dkms switch. Doesn’t help though, if cc is set to the incorrect version.


sudo update-alternatives --list cc
sudo update-alternatives --display cc

to display the current and possible setting for cc, then use --set to choose the correct compiler

  • Don’t use the .run installers, use --uninstall to uninstall them
  • add the ubuntu graphics ppa https://launchpad.net/~graphics-drivers/+archive/ubuntu/ppa
  • install the driver from that (sudo apt install nvidia-driver-430)
    This should pull in the necessary build requirements unless you completely broke it.

Thanks for your reply. I will try your suggestions and update with the results. The procedure you recommend was in fact what I tried to do since the very beginning I put up this system (about 1 year ago, more or less), but it never worked for me… That’s the reason why I started to use the .runinstaller

Anyway, things may have changed a bit in the meanwhile, and trying to go back to the ubuntu graphics ppa might be working now. Thanks again, I’ll be back when I have relevant news

Dear Generix, your procedure worked. All the dependencies have been downloaded, everything was compiled correctly, a new initramfs was created. Reboot. That was it

I can guarantee that this did not work for me in the past. And definitely I never had weird configurations and stuff… Just don’t know why it didn’t work and then had to switch to ./runInstaller. Probably with all the updates along the way, the problems causing that wrong behaviour “got fixed” and now I can happily switch back to the recommended install procedure


On rare occasions (hwe stack upgrades, kernel api breakage), the repo drivers don’t work. You might have been unlucky, hitting that point. If that happens, there’s the staging graphics ppa for a resort.

Dear generix:

How are you.

I also met with the same problem. It was persisted and very hard to solve. Even tough it is depressive, I see a little hope in your solution. However, the solution you mentioned is vague. Would you please give a detailed installation guideline.

Please see the issue descriptions as follows.

  1. gcc 7.4 issues

The newly installed Ubuntu has no gcc information. I used the following method to install gcc. After installation, I found out both of them are gcc 7. 4. Therefore, the terminal has the reminding info: The kernel was built with gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3), but the current compiler version is cc (Ubuntu 7.4.0-1ubuntu1~18.04) 7.4.0

1). sudo apt install gcc

with regard to the newly installed Ubuntu, there is no gcc information.

$ gcc --version

Command '‘gcc’ not found, but can be installed with:
sudo apt install gcc

I can not find the gcc information in /usr/bin/gcc.

So I input the command

$ sudo apt install gcc

After installing with the command. I got the gcc 7.4. Therefore, it has the version conflict.

2). sudo apt install build-essential

I also can install this command to build gcc and its dependencies. It was still a gcc 7.4 It is also have the version conflict.

  1. Reinstalled Ubuntu 18.04 LTS and installed gcc 7.3

I spent a lot of time to search the solutions in Google and found out some methods at stackoverflow, askubuntu and jonantonf’s website. But it still did not work. I list the typical commands for your information.

1). Get a repo

$ sudo add-apt-repository ppa:jonathonf/gcc-7.3

2). Update

$ sudo apt-get update

3). search the version

I can find the gcc info while I run the following command.

$ apt-cache search gcc-7

4). Install gcc

$ sudo apt install gcc-7

After installing the gcc 7, I input the command gcc --version, the terminal has the message as follows.

Command '‘gcc’ not found, but can be installed with:
sudo apt install gcc

Even though It is same as the above. But I can find the gcc information in /usr/bin/gcc.

After a weeklong trial, I found out the dialogue in the weblink: https://devtalk.nvidia.com/default/topic/1052170/linux/ubuntu-18-04-lts-unable-to-reinstall-any-drivers-after-last-system-update/

However, the solution in the weblink is not clear and no in details. It can not guide me to successfully install any versions of Nvidia Graphics Driver including


Please give me a help.

Thanks in advance,


try running

sudo apt install build-essential

Dear generix:

Another issue is that I have tried to install gcc-7.3 with the following commands. But I still get gcc 7.4.0.

sudo add-apt-repository ppa:jonathonf/gcc-7.3 sudo apt-get update
sudo apt-get install gcc-7 g++-7 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 --slave /usr/bin/g++ g++ /usr/bin/g+±7

After completion of the installation, I input the command of gcc --version and get the version of gcc 7.4.0.

Please see the message as follows

gcc ubuntu (Ubuntu 7.4.0-1ubuntu1~18.04) 7.4.0

That means that Jonathanf’s method still leads to the installation of gcc 7.4.0 rather than 7.3.0. However, gcc 7.4.0 does not support Nvidia Graphics Driver including


I think that the new installation might be useful for your analysis.

Best regards,


Before I post the queries, I tried the command as you mentioned.

$ sudo apt install build-essential

But I got gcc 7.4.0 rather than 7.3.0. That is why I searched for Nvidia Forum.

I have some GeForce RTX 2060 graphics cards, I could/can successfully install cuda_10.1.105_418.39_linux.run. The cuda 10.1 includes an embedded Nvidia Graphics Driver 418.39. But the cuda environment (and cudnn 7.5.0) does not support Google TensorFlow and Anaconda/Minconda.

I tried many times and could not make the cuda compatible with both Tensorflow 1.13.1 and Anaconda/Miniconda. So I tried to install independent Graphics Driver 418.39(that onlysupport gcc 7.3.0), cuda_10.0.130 without selecting Graphics Card and cudnn 7.3.1. The combination is recommended by either Google TensorFlow or Aanconda/Miniconda.

Please give me an advice.



What’s the output of

sudo apt-cache policy gcc-7-base

After input the command, the terminal shows the output as follows.

Installed: 7.4.0-1ubuntu1~18.04
Candidate: 7.4.0-1ubuntu1~18.04
Version table:
*** 7.4.0-1ubuntu1~18.04 500
500 http://hk.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
100 /var/lib/dpkg/status
7.3.0-30ubuntu1~18.04.york0 500
500 http://ppa.launchpad.net/jonathonf/gcc-7.3/ubuntu bionic/main amd64 Packages
7.3.0-16ubuntu3 500
500 http://hk.archive.ubuntu.com/ubuntu bionic/main amd64 Packages

Maybe the ppa drivers have the cc check disabled, please try:

  • Don’t use the .run installers, use --uninstall to uninstall them
  • purge anything nvidia/cuda
  • add the ubuntu graphics ppa https://launchpad.net/~graphics-drivers/+archive/ubuntu/ppa
  • install the driver from that (sudo apt install nvidia-driver-430)
  • download the cuda 10.0 .deb from archives
  • add the repo to your system (first three steps from install instructions on download page)
  • don’t install cuda
  • instead, run sudo apt install cuda-toolkit-10-0

How to reinstall cuda-toolkit-10-0

While turn on the computer, the screen shows the message as follows.

Started bpfilter

I am aware that it might be a problem in installing either driver or cuda 10.0. So I removes both Nvidia driver 430.14 and cuda-10.0.

sudo apt remove nvidia-* sudo add-apt-repository --remove ppa:graphics-drivers/ppa
$ sudo apt update

check cuda 10.0

$ cd /usr/local/cuda-10.0/samples/1_Utilities/deviceQuery

bash: cd: /usr/local/cuda-10.0/samples/1_Utilities/deviceQuery: No such file or directory

At present, I successfully reinstall Nvidia 430 in ppa but fails to reinstall cuda 10.0. Please see the message as follows.

$ sudo apt install cuda-toolkit-10-0

Reading package lists… Done
Building dependency tree
Reading state information… Done
cuda-toolkit-10-0 is already the newest version (10.0.130-1).
0 upgraded, 0 newly installed, 0 to remove and 200 not upgraded.

check cuda 10.0

$ cd /usr/local/cuda-10.0/samples/1_Utilities/deviceQuery

bash: cd: /usr/local/cuda-10.0/samples/1_Utilities/deviceQuery: No such file or directory

Best regards,


I adopt another command to remove the old cuda 10.0 and successfully reinstall cuda 10.0.
sudo -i ........ sudo apt-get purge --autoremove cuda*

Then I can install cuda 10.0
sudo dpkg -i cuda-repo-ubuntu1804-10-0-local-10.0.130-410.48_1.0-1_amd64.deb sudo apt-key add /var/cuda-repo-10-0-local-10.0.130-410.48/7fa2af80.pub
sudo apt-get update sudo apt install cuda-toolkit-10-0