After installing Ubuntu 18.04 with the Nvidia driver, I was trapped in a login loop. I found a solution online: install Bumblebee and the Nvidia integration package.
If you cannot reach the desktop, switch to a TTY with Ctrl + Alt + F3, log in, and run:
sudo add-apt-repository ppa:bumblebee/stable
sudo apt-get update
sudo apt-get install bumblebee bumblebee-nvidia
After that, I was able to log in. However, the keyboard and mouse became unusable after entering the desktop.
The fix for that input problem was to install the full X.Org input driver package:
sudo apt install xserver-xorg-input-all
Then reboot:
sudo reboot
This restored the desktop login and fixed the frozen keyboard and mouse after login.
