Sunday, May 20, 2018

How to install Nvidia drivers on Dell Latitude laptop - Ubuntu 16.04




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?



The solutions I found so far gets Bumblebee working (mostly) and provides a means of manually switching off the Nvidia GPU when not in use. I haven't yet gotten glxinfo to work when using prime-select nvidia instead of optirun.




I started following these instructions. I added i915 and bbswitch to /etc/modules. I ran sudo gpasswd -a $USER bumblebee and sudo systemctl enable bumblebeed. Those two commands seem to have finished successfully. After rebooting, the problem remains the same. If I do sudo prime-select nvidia followed by glxinfo I still get the error couldn't find RGB GLS visual or fbconfig.



At this point I decided to install bumblebee-nvidia - the instructions I linked to in my question said don't, the link above did include it however. Surprisingly, this fixed my problems mostly. Now, doing optirun glxinfo or primusrun glxinfo prints out the Nvidia GPU's information. optirun glxgears and optirun glxheads (and also using primusrun) works fine. A word of caution, in a previous iteration through trying to fix this problem, installing bumblebee-nvidia broke optirun/primusrun.



The only thing that doesn't work is prime-select nvidia followed by glxinfo. Then I still get the error about failing to load module "mouse". Also, if I run cat /proc/acpi/bbswitch I keep on getting 0000:04:00.0 ON, which I believe indicates my Nvidia GPU is still on. Running lspci | grep NVIDIA returns 04:00.0 3D controller: NVIDIA Corporation GM108M [GeForce 830M] (rev a2) which confirms the PCIe address of my Nvidia GPU.



The power problem, based on dmesg | grep bbswitch, was that the nvidia module was preventing the GPU from switching off. Manually switching off the Nvidia GPU is possible by running sudo rmmod nvidia_drm, sudo rmmod nvidia_uvm, sudo rmmod nvidia_modeset and sudo rmmod nvidia, followed by sudo tee /proc/acpi/bbswitch <<. Not great though so I went looking for an automatic method to make this work.



To sort out Bumblebee not switching off my Nvidia GPU, I tried the instructions from the bumblebee project but without success. Specifically, my /etc/modprobe.d/bbswitch.conf contains options bbswitch load_state=0 and I added bbswitch load_state=0 to the end of /etc/modules. I did run sudo update-initramfs -u, followed by rebooting, but cat /proc/acpi/bbswitch still shows the GPU is ON. For the moment, I'm working around this by using a script with the rmmod commands to switch off the Nvidia GPU. Running any program with optirun or primusrun automatically reloads those drivers.



No comments:

Post a Comment

11.10 - Can&#39;t boot from USB after installing Ubuntu

I bought a Samsung series 5 notebook and a very strange thing happened: I installed Ubuntu 11.10 from a usb pen drive but when I restarted (...