Nvidia driver installs but does not load on ubuntu 18.04

Solution 1:

Finally it installed! :D

The main cause was the driver installed by cuda toolkit. It never uninstalled properly. So to fix it I performed these operations:

  1. Uninstall all nvidia related packages and remove all blacklist.
  2. sudo update-initramfs -u
  3. Reboot
  4. Went to console mode (Ctrl + Alt + F3), installed Nvidia driver from Nvidia's website (.run file)
  5. sudo update-initramfs -u
  6. Reboot
  7. Went to recovery mode, nvidia-uninstall
  8. # update-initramfs -u
  9. Reboot
  10. Installed nvidia-driver-396 package from graphics-drivers ppa

Everything working fine now

Update: It broke after an update that rebuilt kernel and all dkms modules. Problem is with compiling nvidia-drm module. If anyone has a permanent solution, please post it and I will update accepted answer

Solution 2:

Thanks @sziraqui - I finally have Nvidia drivers installed on Ubuntu 18.04 with your advice along with a few others. Here's what I had to do.

  1. Uninstall / purge all Nvidia drivers

    sudo apt-get remove --purge nvidia* && sudo apt autoremove

  2. Download Nvidia driver from Nvidia's website (.run file)

  3. Disable / Blacklist Noveau driver https://linuxconfig.org/how-to-disable-nouveau-nvidia-driver-on-ubuntu-18-04-bionic-beaver-linux

  4. Reboot in text mode Entering Grub Boot Parameters - This can be done by going to the grub menu at boot (press Esc or Shit at boot) here press e. Enabling Text Mode Booting - Here add a 3 after quiet splash and press F10 to reboot using the new parameters.

  5. Identified gcc used for my kernal and set environment variable CC when running Nvidia installer downloaded in step 2.

    sudo CC=gcc-7 ./[Nvidia installer .run file]

The installer is set to tell you the preinstall fails - ignore and keep going. I allowed NVidia to configure X11 and installed the 32-bit libraries. Rebooted and my dual monitors are working as well as back to 1920x1080 resolution.

Seems like the primary culprit is the gcc compiler used with Ubuntu vs. Nvidia drivers was different so the auto-installers would never work. I hope this helps someone else get their Nvidia drivers installed on Ubuntu!

Solution 3:

In my case installing the modules 'linux-modules-nvidia390-XXXXXX' (where XXXXXX is the Kernel version) on Synaptic fixed it.