Ubuntu – Dell XPS 15 9570 (2018) disable nvidia GPU

bumblebeedelldriversgraphicsnvidia

I have recently bought a Dell XPS 15 9570 and have successfully installed Ubuntu 18.04 on it.

Mostly things work as expected, but there are some issues related to power and the nvidia GPU.

Currently, I have 2 issues that I consider major:

  1. Nvidia GPU stays on by default on boot even when I run sudo prime-select intel. I can disable it using bbswitch with sudo tee /etc/acpi/bbswitch <<<OFF from the terminal. I would love to be able to disable the graphics card on boot as I only use the laptop for productivity under Linux.
  2. The laptop is unable to go to sleep when on AC power and bbswitch is reporting that the GPU is OFF. It goes to sleep normally when on battery, but on AC power it goes to sleep but hangs when opening the laptop lid again leaving only hard power-off as an option.

Setup

I run Ubuntu 18.04 on a Dell XPS 15 9570 with 16G of RAM, NVidia 1050 TI graphics card, and i7-8750H processor.

Chronological system setup actions

  • Install Ubuntu 18.04 using nouveau.modeset=0 to be able to run live image and the installed system for the first time
  • Install proper nvidia drivers from Additional Drivers panel. This installs drivers along with nvidia-prime
  • Use sudo prime-select intel to pick intel card. Reboot. This makes sure intel card is the one used by the system. However, the discreet card is still on even though it is not in use. This is reported by cat /proc/acpi/bbswitch. This command returns 0000:01:00 ON which indicates that the GPU is ON. Also, powertop shows discharge rate of ~20W in comparison to ~10W when I manually turn off the GPU through bbswitch.
  • Install bbswitch to make sure I can actually disable the discrete card and it works manually with sudo tee /etc/acpi/bbswitch <<<OFF

Things I have tried

  • Tried installing bumblebee as this should take control over bbswitch and disable/enable the discrete GPU when needed. Installing bumblebee leads to a system that I am unable to load. I had to recover the system by going to the root console and purging bumblebee*
  • I have tried modifying /etc/modules/ to contain
    bbswitch load_state=0 unload_state=1 as suggested on bbswitch GitHub page. This does not work, only if I leave bbswitch there it loads bbswitch, but then I need to disable the GPU manually.

Any ideas are welcome. Also feel free to ask me for more details. It is really frustrating that such an otherwise perfect laptop suffers from these issues under Ubuntu.

Best Answer

On my 9750 running Ubuntu 18.04, whenever I turn off the dgpu using bbswitch before logging in or on boot, my system freezes.

After trying many different methods and many reboots I settled on a workaround: scheduling a cron job to activate bbswitch after some delay (60s) on reboot, so that I can login before bbswitch kicks in.

open crontab as root in terminal:

sudo crontab -e

add to cron:

@reboot sleep 60 && /sbin/modprobe bbswitch

replace /sbin/modprobe to where your modprobe executable is, this assumes bbswitch is installed.

Also add to /etc/modprobe.d/bbswitch.conf:

options bbswitch load_state=0 unload_state=1

This turns off the dgpu on loading bbswitch and turns in on on unloading bbswitch. Refer to here for more details.

For the lid problem, I had to edit logind.conf:

sudo nano /etc/systemd/logind.conf

change the following line:

HandleLidSwitchDocked=ignore

to

HandleLidSwitchDocked=suspend 

Strangely if you leave the default settings (=ignore), attach an external display and shut the lid the computer does not freeze on reopening. With =ignore and with an external display the computer suspends when you close the lid but you can wake the external monitor with your mouse/keyboard.

Related Question