CUDA install on Ubuntu 18.04 leads to black screen (kernel 5.3), nvidia modules not loading (kernel 4.15.0-88) custom build GeForce 1050

I have never been able to successfully install Nvidia drivers on Ubuntu 18.04 kernel 5.3; it gives me a black screen on boot with nonblinking cursor. I’ve found that downgrading to kernel 4.15.0-88 can at least let me boot properly, so i’ve been living with the problem.

I recently purged all Nvidia packages to clean install CUDA, which resulted in me getting kernels 4.15.0-96 and 5.3.0-46 again.

4.15.0-96 does not respond to any input (keyboard/touchpad) at the login screen.
5.3.0-46 still gives me a black screen on boot with nonblinking cursor.

On 4.15.0-88, it is clear that the Nvidia modules are not loaded.

sudo modprobe nvidia
modprobe: FATAL: Module nvidia not found in directory /lib/modules/4.15.0-88-generic

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.

cat /var/log/Xorg.0.log | grep nvidia
[     6.332] (II) LoadModule: "nvidia"
[     6.333] (WW) Warning, couldn't open module nvidia
[     6.333] (EE) Failed to load module "nvidia" (module does not exist, 0)

On 4.15.0-88:
nvidia-bug-report.log (823.7 KB)

A full history of issues here: 18.04 - Random icon/text disppearing on Nouveau, Nvidia black screen on lightdm, gdm3 boot loop - Ask Ubuntu

Any help is appreciated!

4.15.0-96 bug report:
4-15-96-nvidia-bug-report.log (777.1 KB)

5.3.0-46 bug report:
5-13-nvidia-bug-report.log (1006.8 KB)

It’s an Optimus notebook, so you can’t use the .run installer.
Please follow this:

  • remove the .run installer driver using the --uninstall option
  • delete /etc/X11/xorg.conf
  • remove the kernel parameter ‘nomodeset’ if existing
  • install the driver from repo (sudo apt install nvidia-driver-440)
  • make sure nvidia-prime is installed (sudo apt install nvidia-prime)
  • switch to nvidia (sudo prime-select nvidia)
  • remove stray blacklist files (sudo rm /lib/modprobe.d/blacklist-nvidia.conf /etc/modprobe.d/blacklist-nvidia.conf)
  • update the initrd (sudo update-initramfs -u)
  • reboot to 5.3 kernel

Aterwards, install cuda:

  • download the cuda 10.2 .deb
  • add the repo to your system (first 6 steps from install instructions on download page)
  • don’t install cuda
  • instead, run sudo apt install cuda-toolkit-10-2

It worked! Thanks! It was somewhat surprising, since i definitely installed nvidia-driver-440 and nvidia-prime before; maybe i had other conflicting packages.

  • remove the .run installer driver using the --uninstall option
    No NVIDIA drivers are installed. Instead i did
    sudo apt purge nvidia*
    sudo apt autoremove

  • delete /etc/X11/xorg.conf
    Moved to xorg.conf.nvidia

  • remove the kernel parameter ‘nomodeset’ if existing
    No such kernel parameter

  • install the driver from repo (sudo apt install nvidia-driver-440)
    Done

  • make sure nvidia-prime is installed (sudo apt install nvidia-prime)
    nvidia-prime is already the newest version (0.8.8.2).
    nvidia-prime set to manually installed.

  • switch to nvidia (sudo prime-select nvidia)
    Info: the nvidia profile is already set

  • remove stray blacklist files (sudo rm /lib/modprobe.d/blacklist-nvidia.conf /etc/modprobe.d/blacklist-nvidia.conf)
    No blacklist files

  • update the initrd (sudo update-initramfs -u)
    Done

  • download the cuda 10.2 .deb

  • add the repo to your system (first 6 steps from install instructions on download page)

  • don’t install cuda

  • instead, run sudo apt install cuda-toolkit-10-2
    Done

You should rather remove xorg.conf.nvidia, some xserver versions load anything that contains “xorg.conf”.