nvidia modules are missing after each kernel upgrade in 18.04
Your dkms
is broken. I suggest to fix it this way:
sudo rm -r /var/lib/dkms/nvidia
sudo apt install --reinstall dkms
sudo apt purge 'nvidia.*'
sudo apt install nvidia-driver-415
That will cleanup the dkms directory, create dkms.conf
and install the driver properly.
I think you might find that the solution here is nothing to do directly with the Nvidia driver,nor the kernel version nor DKMS.
The problem here is the GCC & G++ version your system has as its default.
On my system GCC was set to an old version 7.4 and I upgraded the compiler version to 8.0 & G++ also to version 8.
I then set GCC 8 as the default compiler and this finally fixed the problem. The latest mainstream kernel installed fine and the Nvidia modules (the x4 .ko files) also compiled without any glitches. System running nicely once again.