login infinite loop after installing an Nvidia driver

Solution 1:

As Marc Vanhoomissen has said, there are many questions and many solutions about this problem on askubuntu.com. Many of them don't work in my case.

Here is the solution that worked for me at this link.

Here's the text reproduced from that link:

Here is modern way to install the nvidia drivers for Ubuntu (for 14.04 and newer)

        sudo add-apt-repository ppa:graphics-drivers/ppa
        sudo apt-get update
        sudo ubuntu-drivers autoinstall
        sudo reboot

I would add that if you have had many failed attempts you should start with

sudo apt-get purge nvidia* and

sudo apt-get autoclean and

sudo apt-get autoremove nvidia* and

shutdown and power-off and reboot before installing the driver in the suggested manner.

Solution 2:

This method works only if you have multiple GPUs connected to your system.

First you have to follow H2ONaCl's answer. But sudo ubuntu-drivers autoinstall will not always update all the drives of your GPUs.

You can check your available GPUs by sudo ubuntu-drivers devices command and check the versions of the latest drivers that are available for your GPUs.

Then type sudo apt-get install nvidia-version for all GPU versions available in your system.

You can check installed drivers by nvidia-smi command and check whether all the available GPUs have drivers available.

This methods worked for me for a project that I'm doing using GeForce 8400GS and Tesla K40c GPUs with Ubuntu 16.04.