After upgrading from Ubuntu 15.10 to 16.04.1, both 64 bit, I got stuck in an infinite login loop - every time I logged in on lightdm, after logging in the screen would go black and then come back to the login screen. Logging in on tty0 worked fine. I have a Del Latitude 3350 laptop with a Core i5 5200U and an Nvidia GeForce 830M. The upgrade decided I needed the nvidia-361 drivers, before I had been using nvidia-352. A lot of the instructions I came across early on mentioned Secure Boot in my UEFI BIOS, but that was already off (I can't remember if I switched it off as soon as I got the laptop or if it shipped that way from Dell). Re-installing and/or reconfiguring lightdm didn't help. They did at least point me in the direction of uninstalling the Nvidia drivers but that's only a partial solution. This is not a duplicate of other questions I've seen on askubuntu as the steps that worked for others didn't work for me. Possibly the closest guide is How to install sane graphics drivers for Nvidia Optimus hardware on *Ubuntu 16.04?. However, that doesn't make the Nvidia GPU usable for me, I had to install Bumblebee. Also, that guide links to [Bumblebee on a Lenovo T440p [NVidia GT 730M] with XUbuntu/Ubuntu 16.04 LTS]{http://lenovolinux.blogspot.co.za/2016/05/bumblebee-on-lenovo-t440p-nvidia-gt.html?m=1} except that following those instructions actually left me without a working Bumblebee too.
After much Googling I found that the partial solution was to uninstall the Nvidia drivers. I eventually found these instructions which got me to the point of being able to log in.
An important note before continuing, it seems you need to have the intel-microcode drivers installed using the Additional Drivers tab in System Settings. I already had them installed (probably from Ubuntu 15.10 days) so I never tested what happens if they're not installed.
I used the following commands to remove Bumblebee and the Nvidia drivers, followed by re-installing the Nvidia drivers. Note that you need to add the graphics drivers repository to get the latest Nvidia drivers:
sudo apt-get purge .*nvidia.* bumblebee.* .*primus.*
sudo apt-get --purge autoremove
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt install nvidia-367 nvidia-prime nvidia-settings
This resulted in the following packages being installed:
bbswitch-dkms libcuda1-367 libjansson4 nvidia-367 nvidia-opencl-icd-367 nvidia-prime nvidia-settings screen-resolution-extra
Then I did rm .nvidia-settings-rc.
At this point, the instructions say to run some programs that use the GPU. If I run clinfo (I do use the GPU for OpenCL development) then everything works fine. Other OpenCL programs also work fine. However, If I run glxinfo I get the following output:
name of display: :0
Error: couldn't find RGB GLX visual or fbconfig
I carried on with the instructions so I could get Bumblebee running. sudo prime-select intel was needed because otherwise, after rebooting, I get back to the infinite login loop. After rebooting, I did sudo apt install bumblebee followed by editing /etc/bumblebee/bumblebee.conf to change all the instances of nvidia-current to nvidia-367. I also edited /etc/modprobe.d/bumblebee.conf to include the line blacklist nvidia-367. Since there's no nvidia-367-updates or nvidia-experimental-367 packages for me to install, I did not blacklist them.
After rebooting, I can run primusrun clinfo and it prints out the Nvidia platform. Running OpenCL programs on the Nvidia GPU also works when using primusrun. However, primusrun glxinfo gives me an error:
primus: fatal: Bumblebee daemon reported: error: [XORG] (EE) Failed to load module "mouse" (module does not exist, 0)
Using optirun for anything gives me a similar error, e.g. optirun clinfo and optirun glxinfo both give:
[ 462.796690] [ERROR]Cannot access secondary GPU - error: [XORG] (EE) Failed to load module "mouse" (module does not exist, 0)
[ 462.796725] [ERROR]Aborting because fallback start is disabled.
I tried changing the line Bridge= to Bridge=primus and the line PMMethod=auto to PMMethod=bbswitch in /etc/bumblebee/bumblebee.conf. That didn't help.
How do I get Bumblebee and Nvidia's drivers working here, it seems no single set of instructions works? Bonus: How do I get Nvidia drivers working fully when using prime-select nvidia instead of Bumblebee?