Skip to content

Instantly share code, notes, and snippets.

@tomwwright
Last active November 22, 2022 14:06
Star You must be signed in to star a gist
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
@joshu256
Copy link

joshu256 commented Jan 4, 2018

How would I make this a long term solution? I'm running this setup on my Dell XPS and I was wondering if there's any way to keep switching between the two graphics cards.

@scrat98
Copy link

scrat98 commented Jan 13, 2018

@machin3io
Copy link

machin3io commented Feb 5, 2018

@olivertappin as @vegbrasil suggested 387 seems to be working great instead. I don't think there's a need for the 'apt-mark hold' either anymore, at least I hope so.

Thanks @tomwwright and @vegbrasil It looks like I have it sorted now, when I was ready the the xps back before coming across this gist.

I still have problems with the Qualcomm Atheros QCA6174 rev32, which just won't connect to the wifi router. I've tried 16.04, 16.10, 17.10, Arch, Manjaro and even Fedora. I've tried various firmware versions, I've tried the https://github.com/kvalo/ath10k-firmware drivers etc - nothing works, all the things that seemed to work for many others failed for me. It worked fine under Windows of course. Without an ethernet port I'm doing wifi via mobile phone usb tethering for now.
So, I'm really happy to have the issues I had on top of the wifi problems sorted now. I might replace the QCA6174 in favour of an Intel 8265.

@clschnei
Copy link

clschnei commented Feb 8, 2018

NVidia has released 390 as well. So far seems to have fixed most of my issues. We'll see, thought. It's only been an hour. 😏

@viniciushsantana
Copy link

Confirmed working:

  • Ubuntu 17.10 with kernel 4.15.3-041503-generic
  • Nvidia drivers nvidia-graphics-drivers-390

Just need to update kernel, set the Grub parameter and install Nvidia drivers.

@DeuceTheCoder
Copy link

@vegbrasil, I was finally able to get it working with the latest versions you specified!

Are you able to disable and enable the GPU with Prime Indicator? Does it require a restart?

@Catbodi
Copy link

Catbodi commented Feb 17, 2018

@vegbrasil, I just installed today and used the kernel and driver version you listed so far so good.

It's been a while since I've tried using Ubuntu as my main OS. Curious for anybody to answer, are you guys using x11 or wayland when Nvidia drivers are disabled? I've been switching between both but for some reason I'm noticing a lot of delay/lag issues with animations & mouse on wayland vs x11. Honestly I do not recall Gnome being this laggy in general?

@viniciushsantana
Copy link

viniciushsantana commented Feb 18, 2018

@DeuceTheCoder The original Prime Indicator I mentioned on my first comment is an applet for Unity, and since I'm using GNOME now, its a no go... There's a equivalent for GNOME but it does not seems to be working recently. So yeah, kind stuck on that.

One interesting thing is that, Nvidia drivers used to allow switching betweens GPUs in Ubuntu 16.04, even when using Intel - effectively giving three options for the task: Prime Indicator, Nvidia drivers or directly in the terminal. Now, in 17.10, the only option left is terminal commands because Nvidia drivers won't open when the card is disabled. Not sure why.

I think 16.04 may be still the way to go... Touchscreen is slightly better on 17.10 (still not usable), Wi-Fi sucks on both (shitty Killer card).

@Catbodi Wow! I thought I was going crazy, it is indeed very laggy by default (Wayland and Nvidia disabled). I "solved" the issue by disabling all animations using Tweak Tool. Gonna try using X11 - is there any trade offs?

@viniciushsantana
Copy link

Quick update: Trying Cinnamon which appears to be much better than GNOME 3, there's an applet that works somewhat similar to Prime Indicator. In Cinnamon, the Nvidia panel works, just like Ubuntu 16.04 with Unity.

Screenshots:

The indicator

NVIDIA Panel that opens when you click in the indicator applet

@Catbodi
Copy link

Catbodi commented Feb 18, 2018

@vegbrasil, you are definitely not going crazy. I also thought I was crazy and even started beginning to think that my hardware was defective... I believe I'm getting things narrowed down here though... I tried Ubuntu 17.10 then went to Ubuntu 16.04 LTS... Why? I initially thought it was Wayland issues, but I saw the problems persisted when also with X11. Then I guessed that Gnome was probably just terrible, after all this was the first time in many years since Ubuntu switched from Unity to Gnome. I installed Ubuntu 16.04 LTS, upgraded kernel to 4.15 + 390.25. I saw improvement with performance/lag but really it wasn't where it should be. The XPS 9560 is an insanely powerful laptop and this doesn't really add up.

I did some searching, and found this, it's a Nvidia forum thread filled with people complaining about huge performance stuttering issues with driver 390.25 installed. A ran through the pages and saw people experiencing the same thing I did. Strange stuttering inside Chromium/Firefox scrolling quickly through pages, YouTube being insanely slow just trying to load the page and the video. I guess this is why our friend @tomwwright installed 384 in the original post then held the package it so it wouldn't be updated...

Now, still on Ubuntu 16.04, I purged everything Nvidia (390) and the dependencies, then tried installing nvidia-384, switched to Nvidia in the settings then logged out to try nvidia-smi, I couldn't log back in since it would just crash after entering the password. So I'm at a loss for what to do. From what I understand, if I downgrade to 4.13 then more than likely 384 will work and performance will be okay, 4.15 has the latest Spectre/Meltdown patches. For now I've just uninstalled everything Nvidia completely and performance is better overall. What are your thoughts on this, we've come to a frustrating block. Picking between performance for our hardware versus security for our hardware.

@viniciushsantana
Copy link

@Catbodi I was pessimistic overall but now I think Cinnamon was the last the piece of the puzzle. Although, nvidia-390 really seems to have some issues but it feels usable right now, no major lagging. Maybe it will get better when a new version comes.

Please note that I don't game on Linux, only on Windows.

Current setup:

  • Ubuntu 17.10 and kernel 4.15.3-041503-generic (updated kernel)
  • Drivers: nvidia-graphics-drivers-390 (latest version)
  • Desktop environment: Cinnamon 3.6.7 (latest version)
  • Windows manager: Mutter 3.26.2 (latest version, comes with Cinnamon)
  • X.org 1:7.7+19ubuntu3 (default version)

Powertop reports around 10W when idle, which seems OK for me, considering the Core i7 and the 4K screen.

Is there any other use cases where you are getting stuttering? Firefox, YouTube and system UI effects are fine here.

@Catbodi
Copy link

Catbodi commented Feb 18, 2018

@vegbrasil, I've re-installed nvidia-390 but definitely just going to keep it disabled and only on Intel since performance is better even for just productivity. I do not game at all, I only use this laptop for tasks and have a Windows machine for any gaming I want to do (wish I had more time 😢). The performance issues I was talking about are identical to videos the OP of the Nvidia thread I linked. These specifically: website lagging and video playback. Switch to the Nvidia profile, reboot, and attempt quickly scrolling, closing opening tabs, switching between tabs fast and you should likely see the problem. Then again Cinnamon could have fixed the issue for you, I'm not sure.

When you run "sudo Xorg -version", what does the first line return?

@Catbodi
Copy link

Catbodi commented Feb 18, 2018

@vegbrasil, also! Throw that Killer card in the trash and swap it with an Intel 8265. I cannot believe right now laptop manufacturers like Dell and Razer are actually including that card in their high-end laptops... When I had that in my laptop the performance was piss poor but that wasn't the worse part. Depending on your router and in my case, I would literally bring down the router and everybody connected periodically throughout the week or two I had it in the laptop when I purchased it... how a company like Killer which has been around for a decent amount of time managed to pull off a card/driver issue so shitty it not only ruins the experience of your laptop but those just on the same network as you is beyond me.

@viniciushsantana
Copy link

viniciushsantana commented Feb 18, 2018

@Catbodi I've installed nvidia-390 but I almost never use it. Intel works fine for me, even with multiple external displays. I think its good to have the option to switch, just in case.

Using Intel or nvidia-390 with Firefox, I wasn't able to reproduce the problems shown on the videos you mentioned.

Here's the sudo Xorg -version output:

$ sudo Xorg -version
X.Org X Server 1.19.5
Release Date: 2017-10-12
X Protocol Version 11, Revision 0
Build Operating System: Linux 4.4.0-97-generic x86_64 Ubuntu
Current Operating System: Linux xps 4.15.3-041503-generic #201802120730 SMP Mon Feb 12 07:31:14 UTC 2018 x86_64
Kernel command line: BOOT_IMAGE=/boot/vmlinuz-4.15.3-041503-generic root=UUID=76362f42-162e-44dd-bcf0-823d2b9f8d0a ro quiet splash acpi_rev_override=1 vt.handoff=7
Build Date: 15 October 2017  05:51:19PM
xorg-server 2:1.19.5-0ubuntu2 (For technical support please see http://www.ubuntu.com/support) 
Current version of pixman: 0.34.0
	Before reporting problems, check http://wiki.x.org
	to make sure that you have the latest version.

With my current setup, a restart is needed to switch between cards.


About the Killer card... I don't even know how to blame, Dell or Killer...

I have a lot of mixed results with this card: on Windows, any wi-fi network works great. On Linux, my home network works great, at work I have the opposed result. Can't find the pattern to success.

I really need to buy a Intel 8265 - the only problem is that they don't ship directly to my country (just like the XPS itself) and a company to redirect the package is a little expensive. I'll probably pay like US$ 100+ in total for the card.

@stockmind
Copy link

If this can help, after struggling to get Ubuntu working on Dell of a friend we put together those tips with the ones for the Atheros wifi cards and made a working out-of-the-box Ubuntu ISO for Dell XPS 15 9560!

You can find everything here:
https://github.com/stockmind/dell-xps-9560-ubuntu-respin

In the repo you can find all the scripts to respin any ISO supported by Isorespin script

@viniciushsantana
Copy link

@stockmind I assume the finger print does not work, right?

@maxence33
Copy link

maxence33 commented Mar 2, 2018

I am rather noob regarding Ubuntu configuring. I have installed Ubuntu 16.04 and experienced a few things (wifi drops..) but it seems all ok now. No lag or freeze etc.. pretty satisfied.
Yet Powertop reports 17W and the fans sometimes activates (as I do no games or stuff)
I am running Nvidia 384.111.
I would like a better performance and have disabled a few things in the bios (no double threads on cores etc). I do only coding, web browsing etc .. So my question is : what is the best driver to chose in my situation : Nvidia or X ? Should I try the above on my current install ? ... also I have tried to enhance battery longevity in Nvidia-settings by selecting "run on windows motherboard GPU for better longevity" (or so) and it wreaked everything : couldnt sart Ubuntu, Name of Graphic card changed from GTX 1050 to HD Graphics 630 (Kabylake GT2), and the unknown device additionnal driver has disappeard...
I got everything working again (still name of GPU is HD Graphics 630) but I am sure it is all messy inside and this 17W does not look great ...

(also does Nvidia driver ticked = running on card and X driver ticked = running on motherboard ? it's a stupid question but as I don't need performance it could do the trick)

@maxence33
Copy link

Ok I have switched to X and removed and purged everything nvidia. Now powertop is between 12 and 14which is better. I guess I won't be able to do better as I use X now. (Also eventhough I have removed Nvidia, the nvidia driver is still offered as an option in additional drivers...)

@luispabon
Copy link

Some things to consider:

  • Gnome is laggy, especially with multiple monitors and performance degrades over time
  • The killer wifi never gave me any trouble, works out of the box on 4.13.0-37-generic / 17.10
  • I've given up for now on mixed dpi wayland due again to gnome being so laggy and a lot of important apps being only Xwayland, which again is laggy by itself - Xorg 1.20 comes with a lot of improvements on Xwayland so might give it another go on 18.10. I'm simply setting the laptop's monitor to 1080p when a non 4k external monitor is connected which is fine, although a waste considering how sharp the screen is

@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