I had a very similar situation when upgrading my Dell Vostro 1500 (Nvidia 8400M GS) to Ubuntu 16.04.2. There the reason was a wrong proprietary driver version. In particular, the nvidia-304
which used to work fine before needed to be replaced with the newer nvidia-340
.
First find out which driver number you need. Enter your card details on the Nvidia Download page, select Linux and click "Search". It gives you the current nvidia driver number like e.g. 340.102
. The first number is the number you're looking for, in this example it would be 340.
As described above press CTRL+ALT+F1 to get to the text console. Then log in and install the proper driver (use the number you got above) via:
sudo apt install nvidia-340
Now you're almost done, however there is one more important thing. If your previous driver (in my case nvidia-304
) was using bumblebee
and the new driver isn't, you will likely end-up in another pitfall - the infinite login loop. Therefore you need to check one more thing:
Check if bumblebee
is installed:
apt list --installed | grep bumblebee
If not (empty answer from the command) make sure to delete any residual bumblebee module blacklist, which breaks the new driver and causes the infinite login loop:
sudo rm /etc/modprobe.d/bumblebee.conf
After this your graphics should work. Either reboot or restart lightdm by
sudo service lightdm restart