Q:

Can't install NVIDIA driver cause of login loop

I have some problems with rendering in Chromium-based browsers, so, I decided to install proprietary Nvidia drivers. I have this two options in Software & Updates:

When I chose one of this two options I had got login loop. I had to remove it manually and install:
sudo apt-get purge nvidia\*
sudo apt install nvidia-304 # or nvidia-340

After reboot I got login loop again. The content of .xsession-errors is
Xlib:  extension "GLX" missing on display ":0".
openConnection: connect: No such file or directory
cannot connect to brltty at :0
upstart: gnome-session (Unity) main process (2668) terminated with status 1
upstart: unity-settings-daemon main process (2661) killed by TERM signal
upstart: logrotate main process (2391) killed by TERM signal
upstart: bamfdaemon main process (2453) killed by TERM signal
upstart: hud main process (2659) killed by TERM signal
upstart: indicator-bluetooth main process (2721) killed by TERM signal
upstart: indicator-power main process (2726) killed by TERM signal
upstart: indicator-datetime main process (2728) killed by TERM signal
upstart: indicator-keyboard main process (2729) killed by TERM signal
upstart: indicator-printers main process (2733) killed by TERM signal
upstart: indicator-session main process (2734) killed by TERM signal
upstart: Disconnected from notified D-Bus bus
upstart: unity-panel-service main process (2680) killed by TERM signal
upstart: indicator-sound main process (2730) killed by TERM signal

P.S. .Xauthority and .ICEauthority is owned by my user.
Now I switched to X.Org drivers but I would like to install Nvidia. How?
My system is Ubuntu 16.04.5
UPD: nvidia-prime package does not help
UPD: Guest session does not work too
UPD: Problem is still exists after last kernel update

A:

NVIDIA support helped to resolve the issue:

Remove previous driver installation attempts:
sudo apt purge nvidia-\*

Blacklist the open source nouveau driver
echo "blacklist nouveau\nblacklist lbm-nouveau" | sudo tee /etc/modprobe.d/blacklist-nouveau.conf
sudo update-initramfs -u

sudo reboot

Download the current driver from here: http://www.nvidia.com

Open Terminal and stop X server:
Ctrl+Alt+F1
sudo service lightdm stop

sudo sh <driver_name>

if you get a message that the pre-install script failed, select 'continue'

when completed, reboot

