./backlog: Charlie's blog

meanderings through tidbits of mathsy computery stuff

Getting NVIDIA drivers working on Ubuntu 17.10

I recently upgraded my system from Ubuntu 17.04 (a nice, stable distribution) to 17.10 (a fragile nightmare with very little hardware support). This broke... well, a lot of things. However, the main problem was that my NVIDIA graphics drivers were causing the system to fail to boot. I spent a frustratingly-long time trying to fix this problem on my work machine (NVIDIA 1050Ti graphics card), but I think I've finally cracked it. Here's how I did it; hopefully it can help others, too.

Purge lowlatency kernel and reboot

Interestingly, several people have found that the upgrade process automatically installs a lowlatency kernel (a kernel variant that isn't typically used on desktop systems). List these with the following apt command and look for ones that are installed: apt search '^linux-(headers|image)-.*-.*-lowlatency*'. Remove these with sudo apt autoremove {package-name-here} - or just sudo apt autoremove --purge '^linux-(headers|image)-.*-.*-lowlatency*'. Make sure that the latest generic kernel image and headers are installed instead.

Remove previous NVIDIA drivers

Running the following command ought to match any NVIDIA-related driver packages and remove them from your system; sudo apt-get autoremove --purge '^nvidia'.

Blacklist the nouveau driver

Next, we need to disable the open-source nouveau driver so that it doesn't get used instead. This should be done automatically by the NVIDIA driver install process that we did earlier - so you might want to check this first by looking in all of the files returned by the command ls /etc/modprobe.d/nvidia-*.conf. If these files exist (and they contain the lines mentioned below), then you can skip this step.

If the files mentioned above don't exist, create a new file in /etc/modprobe.d/blacklist-nouveau.conf and make sure that the following lines are present;

blacklist nouveau
blacklist lbm-nouveau
alias nouveau off
alias lbm-nouveau off

Update the initial ramdisk to remove nouveau

This step may be unnecessary, but it's worth running anyway (because if you do need to run it, it'll save you a whole lot of headache doing it up-front - and if you don't, it won't do you any harm). Simply sudo rmmod nouveau, then run sudo update-initramfs -u, wait a moment, and you're golden.

Reinstall NVIDIA drivers

Don't reboot just yet - now we're going to re-install a version of the NVIDIA driver that I have found to work: sudo apt install nvidia-381.

Add a configuration option that seems to fix things

I found a helpful answer on AskUbuntu that suggests setting the nomodeset parameter for the NVIDIA kernel driver. To do this, create a new file in /etc/modprobe.d/nvidia-drm-nomodeset.conf and make sure the following line is present;

options nvidia-drm modeset=1

Update the initial ramdisk again

Again, run sudo update-initramfs -u, wait a moment (check for errors, too!), and you should be good to go.

Disable Wayland in GDM

After a little more digging, it turns out that Ubuntu 17.10 ships with Wayland as its default display server (instead of the traditional X11) - which doesn't play nice with NVIDIA cards at the moment. You can just ask the GNOME Display Manager (GDM) to run an Xorg session instead (see below image), but I prefer disabling it for good (source).

Switching from Wayland to Xorg in GDM
Image source: ItsFOSS

Disabling it for good is straightforward, just open /etc/gdm3/custom.conf in your favourite editor, and uncomment the WaylandEnable=false line, like so:

# GDM configuration storage
# # See /usr/share/gdm/gdm.schemas for a list of available options.

[daemon] # Uncoment the line below to force the login screen to use Xorg

Reboot and cross your fingers

This set of steps worked for me, but (as usual) these instructions don't come with a warranty. Use them at your own risk and make sure that you know what you're doing before you run each command. Good luck.