Nvidia driver installs but does not load on ubuntu 18.04

62,818

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.

Share:
62,818

Related videos on Youtube

sziraqui
Author by

sziraqui

whoami : a_TechFreak ls skills : ["android apps","android ROMs","bash", "python","java","c","nodejs","html","unity3D","blender","photoshop",after effects","illustrator","corelDraw", ....] uname -i : linux+windows_x86_x64

Updated on September 18, 2022

Comments

  • sziraqui
    sziraqui over 1 year

    Nvidia driver 384 ran well on Ubuntu 17.04 and 17.10. I switched to Ubuntu 18.04 (clean fresh install) and installed nvidia-driver-396 following this great answer

    Then I installed cuda toolkit 9.2 using .run file. It failed to install with and without choosing to install nvidia driver along with it. Rebooted and tried again, then cuda was installed succesfully. But nvidia isn't running.

    $ nvidia-settings
    ERROR: NVIDIA driver is not loaded
    
    
    ERROR: Unable to load info from any available system
    
    
    $ nvidia-smi
    NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.
    
    $ lspci -v | grep VGA
    00:02.0 VGA compatible controller: Intel Corporation HD Graphics 5500 (rev 09) (prog-if 00 [VGA controller])
    

    What I have tried so far:

    1. Uninstalled nvidia (nvidia-uninstall) Successful but with warning: "Some symlinks could not be removed. The I removed cuda with rm -rf /usr/local/cuda* and installed nvidia-driver-396 but still the same error

    2. Removed nvidia-396, installed 396 from nvidia's website (.run file). It started with a warning "Distribution provided pre-script failed". I proceeded and installation was successful. It also added nouveau to blacklist automatically. Still same result as 1.

    3. Uninstalled previous one, removed blacklist entry, installed nvidia-390 Still same result

    4. Uninstalled previous one, installed it from "Additional drivers" from GUI. No change.

    5. Went to console mode. Stopped gdm. Then installed 396. No change. Installed 390 likewise. No change.

    6. Tried using xorg-edgers ppa (Yes its is said they are same as graphics-drivers ppa but I am desperate now) Unmet dependency problems. So reverted to removed everything.

    7. Uninstalled everything, went to recovery mode then installed nvidia-driver-390. No luck.

    8. I felt nvidia driver from official website made some irrevesible changes. So tried installing it again so that I can uninstall it properly from recovery mode as suggested in the great answer using --unistall option. But now it fails to install. Error message says nouveau is running despite being blacklisted. I removed the blacklist entry later

    I have Intel i5 with Intel HD graphics along with Nvidia GeForce 940M. Yes nvidia-prime was installed. Dual booted with Windows 10, Secure Boot is disabled

    During all these steps, once I was able to start the nvidia x server app, though the nvidia-smi gave the same error. Once there was a resolution issue when cuda ran nvidia-xconfig. I removed the xorg.conf to fix it. Right now my pc has nouveau running, no other drivers installed, no blacklisting nvidia, no xorg.conf.

    Can someone help. I don't see any reason why it should not work. nvidia driver 390.12 is reported to work well with kernel 4.15 but still it is not working on mine.

    • Jonathan
      Jonathan about 5 years
      Make sure you only have on distro in your /etc/apt/sources.d.list/ files, I had multiple different distros (bionic/cosmic/xenial etc) and it was causing it to fail
    • sziraqui
      sziraqui almost 5 years
      @Jonathan I have only one distro in that file
  • Alban Dericbourg
    Alban Dericbourg over 5 years
    So I can understand: what was the purpose of manually installing the binary driver and removing it before installing the one from the graphics PPA?
  • sziraqui
    sziraqui over 5 years
    The .run file made some unknown changes to system. The uninstall script of the .run file failed to do a complete uninstall (all changes were not reverted). Uninstall script was a part of the binary so to use it again in recovery mode I had to install the binary again
  • sziraqui
    sziraqui about 5 years
    Did you ever change your default c compiler?
  • sziraqui
    sziraqui about 5 years
    Now I understood why my drivers break after an update. I changed default GCC to gcc-5 because of current project. Everytime dkms rebuilds kernel, the nvidia-drm module fails to build because it requires same compiler that was used to build your OS kernel (gcc-7 for Ubuntu 18.04). This leads to a broken install of drivers. This is not reported as an error by either dkms nor dpkg.
  • sziraqui
    sziraqui almost 5 years
    Setting gcc back to gcc-7 didn't solve my problem.
  • Sachin Borkar
    Sachin Borkar over 4 years
    Has anybody been successful in solving this issue. I've tried all sorts of fixes for this, but to no avail. I really do not want to use Windows on this machine. If anybody has met success in resolving the issue, please help me!
  • Timothy C. Quinn
    Timothy C. Quinn over 4 years
    I installed the driver from Nvidia site and it fixed my issue. My display drivers stopped working after my battery ran out last night and when I restarted, it was no longer working. All attempts to fix using standard ubuntu nvidia drivers did not work, even including purge and reinstall. I will stick with Nvidia drivers until next Ubuntu LTS comes out in a few months.