I am get stuck in the (in)famous login loop after installing nvidia gpu drivers. I have Ubuntu 16.04, intel cpu, and nvidia geforce 840m.

I installed (in various way, see below) driver, but when I switch to nvidia card with sudo prime-select nvidia and reboot, the login loop issue happens. If I switch back to sudo prime-select intel I manage to login.

Looking here and over the internet I tried various solution:

  • Installing various version of the driver (340, 380, 415, 418)
  • Installing them in different ways:
    • sudo apt install nvidia-xxx
    • sudo apt install nvidia-current
    • sudo ubuntu-drivers autoinstall
    • from software update
    • Running the .run file downloaded from nvidia website (last version, 418)
  • Restarting lightdm, trying with gdm3 (gnome)
  • Secure boot deactivated
  • .Xauthority check permission, and also remove it
  • nomodeset, acpi=off, acpi_osi= (once at time) in the grub before loading ubuntu

Maybe other that will come up in my mind and I will update here.

Anyone that can help me? I really need to use the nvidia GPU.


Not a duplicate of this because solutions there does not solve my problem.

  • I read that discussion (and also others). Following all the solutions explained there does not solve my problem. So I open a new question. – tory_debra Mar 14 '19 at 15:27

Let's say I solved, thanks to bumblebee

From here
1. Fall back to the noveau driver
2. Reboot
3. Now that the issue is gone, but video quality is not good change the latest preferred Nvidia driver active again and DO NOT REBOOT
4. Use command line to set Intel card primary - use terminal and command sudo prime-select intel
5. Now You may reboot
6. do not rejoice there is still a missing sofware, perform the following steps in terminal:

sudo add-apt-repository ppa:bumblebee/stable
sudo apt-get update
sudo apt-get install bumblebee bumblebee-nvidia
  1. Reboot

I also have to solve some config problem with bumblebee : in /etc/bumblebee/bumblebee.conf :

replace nvidia current with nvidia-390

and in /etc/bubmlebee/xorg.conf.nvidia add

  Section "Screen"
         Identifier "Default Screen"
         Device "DiscreteNvidia"

at the end of the file

now when I want use a program with nvidia gpu i launch it with optirun.
Currently I am using nvidia driver-390 but nvidia-prime query return intel


For me I just deleted the .Xauthority and two more of them having different suffixes from my home folder and it was working again fine!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.