Skip to content

Instantly share code, notes, and snippets.

@tomwwright
Last active November 22, 2022 14:06
Show Gist options
  • Save tomwwright/f88e2ddb344cf99f299935e1312da880 to your computer and use it in GitHub Desktop.
Save tomwwright/f88e2ddb344cf99f299935e1312da880 to your computer and use it in GitHub Desktop.
Dell XPS 15 9560: Ubuntu 17.10 + Nvidia 384.90 + Nvidia Prime (No Bumblebee) https://medium.com/@tomwwright/better-battery-life-on-ubuntu-17-10-4588b7f72def
# 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
@luispabon
Copy link

Ubuntu 18.04 bionic update

Took the plunge yesterday and did a do-release-upgrade -d. I have everything working fine again, but it was a bit of a PITA as everything around the discrete GPU was a pain to set up. It auto-updated to nvidia-390.

Upon restart, your DE will fail to start probably. Reboot again and on the boot menu choose recovery mode then choose with network. Make sure nvidia-prime is installed then do prime-select intel, then reboot.

You should be able to boot to your DE now, but the discrete GPU will be on and guzzling power even if you already had bbswitch installed. You need to sudo apt autoremove --purge bbswitch-dkms "bumblebee*" then sudo apt install bbswitch-dkms` and check the GPU is off after installation via

 cat /proc/acpi/bbswitch                                                                                                                                                      
0000:01:00.0 OFF

I haven't been able to finish setting up bumblebee yet.

@fjalvingh
Copy link

Also upgraded to 18.04, with a load of trouble. Mousepad was not working right, this needed to be fixed by installing the xserver-xorg-input-synaptics driver and a gnome-tweaks setting to get the right button to work again.
Graphics was hell, I removed everything done before and reinstalled nvidia-390. Then there was a lot of trouble disabling the nouveau driver from loading - it loaded despite all of the blacklist entries in modprobe.conf.d. I ended up by adding blacklist.nouveau=1 to the kernel command line in grub.
After this I reinstalled bbswitch and bumblebee but that hangs before the login screen comes. It turns out that anything (like bumblebee) that switches off the NVIDIA will cause this hang.
Oddly enough, if you remove bumblebee and keep bbswitch you can logon, but the nvidia is ON after. But now you CAN switch it off using the cat OFF >/proc/acpi/bbswitch command.

No idea yet on how to do this better... Watching this space ;)

@joepadmiraal
Copy link

joepadmiraal commented Jun 4, 2018

I also upgraded to 18.04 on a XPS 9560 and having trouble with nouveau.
I can switch between nvidia and intel with nvidia-settings followed by a reboot.
The issue I have is that closing the lid won't suspend the laptop.
I thought it might be nouveau related so I added blacklist.nouveau=1 to the kernel parameters and blacklist nouveau to modprobe.d/blacklist.conf but it is still being loaded when running with Intel graphics.

cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-4.17.0-041700-generic root=UUID=c9f1f95a-2c7a-4f84-8b02-e7b9b4675b42 ro quiet splash nouveau.runpm=0 blacklist.nouveau=1 vt.handoff=1

lsmod | grep nouveau
nouveau              1724416  2
ttm                   110592  1 nouveau
mxm_wmi                16384  1 nouveau
wmi                    24576  7 intel_wmi_thunderbolt,dell_wmi,wmi_bmof,dell_smbios,dell_wmi_descriptor,mxm_wmi,nouveau
i2c_algo_bit           16384  2 i915,nouveau
drm_kms_helper        172032  2 i915,nouveau
drm                   405504  21 drm_kms_helper,i915,ttm,nouveau
video                  45056  4 dell_wmi,dell_laptop,i915,nouveau

tail /etc/modprobe.d/blacklist.conf 
#Joep
blacklist vga16fb
blacklist nouveau
blacklist rivafb
blacklist nvidiafb
blacklist rivatv

When running with the nvidia card, nouveau is not loaded.
Does anyone have a clue about why nouveau is still loaded?
And do you also have the suspend issue?

@ianrrees
Copy link

I've been setting up an XPS 9570 with Ubuntu 18.04, thanks everyone for putting this together - many tips above have been quite helpful!

Have installed nvidia proprietary drivers, and switched the computer to use Intel graphics. Was having problems with the laptop not going to sleep using Intel graphics, also had problems with crashes. Those two issues were resolved by adding nouveau.nomodeset=0 to kernel boot parameters - even though I wasn't intentionally using nouveau!

It turned out that nouveau was being loaded by the nvidia-fallback service, disabling it via #systemctl disable nvidia-fallback allowed me to remove the nouveau kernel boot arguments without re-introducing any of the above issues.

My fans seem to constantly be spinning up and down, even under minimal load in a cool room. It's not entirely consistent, which makes me think it might be related to some measured temperature - fans will be on for a second or so, then off for ~10 seconds. It seems wasteful and is distracting. Any ideas on how to prevent this?

@istepaniuk
Copy link

@ianrrees Upgrade your BIOS. I am on 1.5.0 and the fans speeds seem more reasonable. I have not tested thoroughly but it's an improvement over 1.3.0 (And the BIOS changelog claims to "solve power management issues in Ubuntu" )

@sushisoosh
Copy link

i'll post my entire notes, which is also a reference to this here doc, but contains more after this guide:

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)
    powertop
    turn nvidia on/off
    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
    editting /etc/X11/xorg.conf or so and setting intel & inactive nvidia in the first section solved the problem
    Section "ServerLayout"
    Identifier "layout"
    Screen 0 "intel"
    Inactive "nvidia"
    EndSection


@philiporlando
Copy link

What would need to be altered for this to work with Xubuntu?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment