Dell XPS 15 9570 (2018) disable nvidia GPU

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.


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.


These are my notes for disabling the nvidia GPU and enabling the integrating Intel GPU on my processor, on Linux. This has brought down my dell xps 15 power consumption from 25-30 w to 11-12. Improving battery life from 3 hours to 9-10 hours. I had success in disabling the GPU itself, but it would not properly boot into Linux and even when i did get it working it wouldn't let me adjust the backlight. I have now solved all these problems and everything works fine.

System Dell XPS 15 9560 9 cell battery
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.1 LTS"
Linux version 4.15.0-39-generic (buildd@lgw01-amd64-054) (gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)) #42-Ubuntu SMP Tue Oct 23 15:48:01 UTC 2018

I followed mostly this guide, but had to add some tweaks https://gist.github.com/tomwwright/f88e2ddb344cf99f299935e1312da880

Guide is as follows

# perform a fresh install of Ubuntu 17.10

# upgrade the kernel to v4.13.10
mkdir ~/kernel-v4.13.10
cd ~/kernel-v4.13.10
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.13.10/linux-headers-4.13.10-041310_4.13.10-041310.201710270531_all.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.13.10/linux-headers-4.13.10-041310-generic_4.13.10-041310.201710270531_amd64.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.13.10/linux-image-4.13.10-041310-generic_4.13.10-041310.201710270531_amd64.deb
sudo dpkg -i *.deb

# configure required kernel parameter (https://github.com/Bumblebee-Project/bbswitch/issues/148)
sudo nano /etc/default/grub
# change this parameter to: GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_rev_override=1"
# rebuild the bootloader
sudo update-grub2

# install and configure TLP and PowerTOP
sudo apt-get install tlp tlp-rdw powertop
sudo tlp start
# PowerTOP should be reporting a battery discharge rate of ~8-12W
sudo powertop --auto-tune     # auto-tune parameter will configure some recommended power-saving tweaks

# install Nvidia 384.90 drivers
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
sudo apt-get install nvidia-384=384.90-0ubuntu3.17.10.1
sudo apt-mark hold nvidia-384   # stop this package being auto-updated during package resolution

# test that the nvidia drivers are working: nvidia-smi should output some GPU stats
nvidia-smi

# PowerTOP should now be reporting a battery discharge rate of ~15-20W
sudo powertop

# install Nvidia Prime: so we can disable the dedicated GPU when we don't want it
sudo apt-get install nvidia-prime
sudo prime-select intel

# REBOOT: when we boot back in, GPU should now be disabled

sudo powertop   # PowerTOP should be reporting ~8-12W dischargehe 
nvidia-smi      # nvidia-smi should complain about missing drivers

sudo prime-select nvidia  # switch back to dedicated graphics
sudo powertop   # PowerTOP should start reporting ~15-20W discharge
nvidia-smi      # nvidia-smi should report GPU info

sudo prime-select intel   # the GOTCHA: prime-select intel doesn't re-disable the graphics card
sudo powertop   # PowerTOP still reporting ~15-20W discharge
nvidia-smi      # nvidia-smi correctly complaining about missing drivers

After following the guide 1) run powertop and turn nvidia on/off, or

sudo nano /lib/systemd/system/gpuoff.service

to turn off the gpu power in

/sys/bus/pci/devices/0000\:01\:00.0/power/control

has the same effect as disabling the gpu in powertop

sudo nano /lib/systemd/system/gpuoff.service
sudo systemctl start gpuoff
sudo systemctl enable gpuoff 
#prime-select nvidia
prime-select intel
prime-select query

2) sudo vim /etc/default/grub

#grub now that it works:
GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="acpi_backlight=vendor" # < boots
GRUB_CMDLINE_LINUX=""

3) < this was a major fix for getting it to boot properly without nomodeset. edit /etc/X11/xorg.conf or so and setting intel & inactive nvidia in the first section solved the problem. Set the first section to:

Section "ServerLayout"
Identifier "layout"
Screen 0 "intel"
Inactive "nvidia"
EndSection

to now change the backlight i use the "light" command. I think this is something i downloaded from github somewhere