Ubuntu – Install driver for GTX 1070

driversgraphicskernelnvidia

I want to install the latest driver for my GTX 1070 (my monitor flickers sometimes and I think this might be because I never installed a proper driver).

Since NVIDIA supports Linux driver I downloaded the latest driver for my card at https://www.nvidia.com/Download/index.aspx?lang=en-us.

I made the file executable and stated it from terminal

sudo ./NVIDIA-Linux-x86_64-410.93.run

However, I can't install it. It shows me the folloing message:

The distribution-provided pre-install script failed! Are you sure you want to continue?

When I enter yes, I get the following error:

enter image description here

How can I fix it?

THis is the log file:

nvidia-installer log file '/var/log/nvidia-installer.log' creation
time: Fri Jan 25 15:49:58 2019 installer version: 410.93

PATH:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

nvidia-installer command line:
./nvidia-installer

Unable to load: nvidia-installer ncurses v6 user interface

Using: nvidia-installer ncurses user interface
-> Detected 8 CPUs online; setting concurrency level to 8.
-> Installing NVIDIA driver version 410.93.
-> Running distribution scripts executing: '/usr/lib/nvidia/pre-install'…
-> done.
-> The distribution-provided pre-install script failed! Are you sure you want to continue? (Answer: Continue installation) ERROR: The
Nouveau kernel driver is currently in use by your system. This driver
is incompatible with the NVIDIA driver, and must be disabled before
proceeding. Please consult the NVIDIA driver README and your Linux
distribution's documentation for details on how to correctly disable
the Nouveau kernel driver.
-> For some distributions, Nouveau can be disabled by adding a file in the modprobe configuration directory. Would you like nvidia-installer
to attempt to create this modprobe file for you? (Answer: No)

I'm not sure if it matters, but I did apt-get upgrade before and haven't restarted yet.

Best Answer

First remove any nvidia packages you might have had laying around

sudo apt-get purge nvidia*

Add the repository to your repo list

sudo add-apt-repository ppa:graphics-drivers

And update

sudo apt-get update

Then enter the following

ubuntu-drivers devices

in terminal which gives the following output:

== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd00001B81sv00001462sd00003302bc03sc00i00
vendor   : NVIDIA Corporation
model    : GP104 [GeForce GTX 1070]
driver   : nvidia-driver-410 - third-party free
driver   : nvidia-driver-396 - third-party free
driver   : nvidia-driver-415 - third-party free recommended
driver   : nvidia-driver-390 - third-party free
driver   : xserver-xorg-video-nouveau - distro free builtin

Now one may take the recommended driver from the list and installs it by

sudo apt-get install nvidia-driver-415

Credits to j-money for 80% of this answer