Fixing a Broken NVIDIA / GNOME Setup on Ubuntu
Published:
Recently my Ubuntu installation ended up in a broken state after a reboot:
external displays stopped working, nvidia-smi failed inside the desktop
environment (DE), and the system would hang while stopping gdm during
shutdown. Interestingly, the NVIDIA driver still worked in recovery mode, which
suggested the kernel modules themselves were not completely broken. I decided
to reset both the NVIDIA stack and the DE entirely since I
have had issues in the past with GPU weirdness.
One thing that helped diagnose root issues was disabling the graphical splash screen during boot. By default Ubuntu hides most boot messages behind the splash screen, which makes it hard to see where the system is hanging.
To see the real boot output, while in the Ubuntu DE I edited the GRUB configuration:
1
sudo nano /etc/default/grub
In the line:
1
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
I removed quiet splash so it became:
1
GRUB_CMDLINE_LINUX_DEFAULT=""
Then I updated the GRUB:
1
sudo update-grub
Now Ubuntu displayed the full boot log instead of the splash screen. This made
it obvious that the system was hanging while rebooting from the DE due to
gdm, which pointed toward a joint problem with the DE and GPU stack rather
than the kernel itself.
At this point, I hard reset, then powered back on. I then pressed ESC in
order to reveal the GRUB boot menu. I then entered recovery mode and fixed the
issue as follows:
First, I updated the system to ensure all packages and kernel components were consistent:
1
apt update && apt upgrade
Next, I completely removed all NVIDIA and CUDA packages:
1
apt --purge remove "*nvidia*" "*cuda*"
To make sure no stale desktop configuration remained, I also removed the GNOME desktop and the display manager:
1
apt --purge remove ubuntu-desktop gdm3
Then I cleaned up any remaining dependencies:
1
apt autoremove
After that, I reinstalled the desktop environment:
1
apt install ubuntu-desktop gdm3
Finally, I let Ubuntu reinstall the recommended GPU drivers automatically:
1
ubuntu-drivers install
After rebooting, the system came up normally again. NVIDIA worked inside the
desktop environment, external displays were detected, and the gdm shutdown
hang was gone. While perhaps not the most elegant solution, completely
resetting both the GPU drivers and the desktop environment turned out to be the
fastest path to a clean state.