March 03, 2017

Install latest Nvidia drivers in Ubuntu 16.04

Install latest Nvidia drivers in Ubuntu 16.04

1. Blocklist nouveau

nouveau is Nvidia free/libre software drivers for nVidia cards.

So when you want to install the proprietary Nvidia drivers, you have to disable nouveau by blocklisting them, regenerating the initramfs (next step) and rebooting without them.

To blocklist nouveau, create /etc/modprobe.d/disable-nouveau.conf file with these contents:

blacklist nouveau
options nouveau modeset=0

2. Regenerate initrd (initramfs)

$ sudo update-initramfs -u

3. Reboot and stop graphics (lightdm)

$ sudo systemctl stop lightdm

4. Install Linux headers and dkms

dkms is necessary so that nvidia driver will be automatically rebuild when you install newer Linux kernel

$ sudo apt -y install linux-headers-generic dkms

5. Install 32-bit libraries and dkms

The 32-bit libc library is required so that nvidia installer will be able to build 32-bit nvidia libraries

$ sudo dpkg --add-architecture i386
$ sudo apt -y install libc6:i386

I also had $ sudo apt -y install libxext6:i386 libxdmcp6:i386 libxcb1:i386 libxau6:i386 libx11-6:i386 installed. But I presume having only libc6:i386 should be enough. Please try with only libc6:i386 and let me know if it worked.

6. Download and install latest Nvidia drivers

You can find and download them at nvidia.com

$ chmod +x NVIDIA-Linux-x86_64-375.39.run
$ sudo ./NVIDIA-Linux-x86_64-375.39.run --dkms

Check whether the NVIDIA’s 32-bit compatibility libraries have been really installed along with 64-bit ones:

$ find /usr/lib* -name "*GLdispatch*" -ls 
   245043    245 -rwxr-xr-x   1 root     root       822584 Feb  9 18:54 /usr/lib/x86_64-linux-gnu/libGLdispatch.so.0
   245161    249 -rwxr-xr-x   1 root     root       546840 Feb  9 18:54 /usr/lib/i386-linux-gnu/libGLdispatch.so.0

Troubleshooting

In case of problems check logs:

$ cat /var/log/nvidia-installer.log

When you updated the kernel, but dkms did not work as expected, you can instruct it to manually rebuild the nvidia driver:

you should have /usr/src/nvidia-375.39/dkms.conf file

# dkms build nvidia/375.39
# dkms install nvidia/375.39
# find /lib/modules/ -name nvidia.ko -ls