Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ubuntu 18.04] prime-select intel is not powering off the nvidia card #8

Open
GordianDziwis opened this issue May 3, 2018 · 85 comments

Comments

@GordianDziwis
Copy link

It is problem upstream, but you may be interested. Bug #1765363 “prime-select intel is not powering off the nvidia ...” : Bugs : nvidia-prime package : Ubuntu

@stockmind
Copy link
Owner

Thanks for feedback, hope it gets fixed soon!

@soncodi
Copy link

soncodi commented May 6, 2018

Manual workaround: https://wiki.archlinux.org/index.php/hybrid_graphics

@tvld
Copy link

tvld commented May 15, 2018

I can get Nvidia to power down with this script:

#!/bin/bash
echo "Switching off nvidia"

# move from Nvidia to intel graphics (if not already done)
prime-select intel

# switch of power to Nvidia (repeat after each laptop start)
echo "auto" > /sys/bus/pci/devices/0000\:01\:00.0/power/control

# Results in power down freeze, but seems needed? 
echo "1" > /sys/bus/pci/devices/0000\:01\:00.0/remove

After running this, sudo powertop shows me about ~6W instead of ~14W !

One nasty issue: the remove of the driver results in freeze during power down. Someone reported they did not need the remove and set power/control to auto was enough, but it was not for me...

@GordianDziwis
Copy link
Author

@tvld freeze during shutdown could be the result of the nouveau driver being loaded after switching to intel. Nouveau does not really work with 10xx gpus. Adding nouveau.modeset=0 as a bootparameter could help.

@tvld
Copy link

tvld commented May 15, 2018

@BonaBeavis my current grub line is:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_osi=Linux acpi_osi=! acpi_osi='Windows 2009' nouveau.runpm=0"

What does nouveau.modeset=0 add to that?

@GordianDziwis
Copy link
Author

@tvld It prevents the nouveau modul from loading, there was a change in prime. Prime now uses the nouveau modul for powering off the dgpu when in intel mode. Bug #1765363 “prime-select intel is not powering off the nvidia ...” : Bugs : nvidia-prime package : Ubuntu

@tvld
Copy link

tvld commented May 15, 2018

@BonaBeavis can you copy your total Grub line here? It makes no difference for me.

@GordianDziwis
Copy link
Author

You are right, maybe i915.modeset=1 is missing

GRUB_CMDLINE_LINUX_DEFAULT="quiet acpi_rev_override=1 enable_fbc=1 enable_psr=1 i915.modeset=1 disable_power_well=0 nouveau.modeset=0"

@qhartman
Copy link
Contributor

qhartman commented May 15, 2018 via email

@GordianDziwis
Copy link
Author

I think those are the necessary ones:

GRUB_CMDLINE_LINUX_DEFAULT="quiet acpi_rev_override=1 i915.modeset=1 nouveau.modeset=0" 

Never had a wifi problem, but it is all trial and error with these boot parameters. Workarounds all the way down.

@qhartman
Copy link
Contributor

Seems that this wasn't the wifi issue. My firmware somehow got nuked at the same time that I was making these parameter changes and I mis-attributed the failure.

@tvld
Copy link

tvld commented May 15, 2018

Running sudo powertop gave me a power usages of about 15W in idle, indicating that the GPU was still on, even after prime-select intel.

I kept powertop running and in another terminal ran:

$ cat /sys/bus/pci/devices/0000\:01\:00.0/power/control
# resulted in "on", which is not good

I then executed ( see bug report ):

sudo sh -c 'echo auto > /sys/bus/pci/devices/0000\:01\:00.0/power/control'

Powertop dropped to about 6W ! ))
So then it was simple, created this startup script to make the change permanent:

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

And pasted contents:

[Unit]
Description=Power-off gpu

[Service]
Type=oneshot
ExecStart=/bin/bash -c "if [[ `prime-select query` == 'intel' ]]; then echo auto > /sys/bus/pci/devices/0000\:01\:00.0/power/control; fi"



[Install]
WantedBy=default.target

To test the script you can run sudo systemctl start gpuoff.

If ok, run sudo systemctl enable gpuoff to enable the script to start on powerup.

To confirm that it works cat /sys/bus/pci/devices/0000\:01\:00.0/power/control should return: "auto" after reboot.

PS For what it is worth, my /etc/default/grub line is:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash i915.modeset=1 nouveau.modeset=0"

@stockmind
Copy link
Owner

Great job all! :) @tvld can i add the service/script to the respin? This may help lot of people!

@tvld
Copy link

tvld commented May 16, 2018

@stockmind for sure, I have cleaned it up a bit.

@damageboy
Copy link

I ended up doing the same with bbswitch...

Can anyone comment on that the difference is between this method and installing bbswitch?

@tvld
Copy link

tvld commented May 18, 2018

@damageboy no idea; I did not try bbswitch... If it works for you a standard package might be better...

@luispabon
Copy link

How about

bash -c 'if [[ "`prime-select query`" == "intel" ]]; then echo auto > /sys/bus/pci/devices/0000\\:01\\:00.0/power/control ; fi'

@tvld
Copy link

tvld commented May 23, 2018

@luispabon Can do... but I dont see a problem with setting device power on "auto" in Nvidia mode as well?

@luispabon
Copy link

Actually there isn't. That was my script to explicitly turn it off changed to auto instead. As you were 👍

@tvld
Copy link

tvld commented May 23, 2018

@luispabon I could be wrong, but I think the only two available modes are "auto" and "on". I thought "off" is not available ...

@luispabon
Copy link

Totally works here 👍

@mablae
Copy link

mablae commented May 27, 2018

Thanks @tvld !

grafik

@nicobonne
Copy link

Sorry for the silly question, is there any chance to switch back to Nvidia card, after applying @tvld 's solution?

@tvld
Copy link

tvld commented May 28, 2018

@nicobonne That is not a silly question: in my case, prime-select nvidia freezes my system on startup and I never see the login prompt.

That said, to be 100% sure it is not the start up script I have modified slightly to ensure the power settings are only applied when on intel mode as @luispabon already mentioned but I changed syntax:

ExecStart=/bin/bash -c "if [[ `prime-select query` == 'intel' ]]; then echo auto > /sys/bus/pci/devices/0000\:01\:00.0/power/control; fi"

For me it does not matter... nvidia prevents the login prompt with or without the powersetting on 'auto'. I dont need Nvidia, so I did not spend time debugging. Maybe someone else can test if they can still get Nvidia to run? With the revised script line?

@tvld
Copy link

tvld commented May 29, 2018

@mablae I have the 54W battery, wifi on and bluetooth mouse, FHD screen at 50%. Your wakeup/s are very high... You must be running something? Did you install TLP ?
screenshot from 2018-05-29 15-03-51

@luispabon
Copy link

That's really good power consumption. I've never seen it lower than 7w on mine. Do you have the FHD or UHD screen? Is this measured on an empty desktop session (eg no other apps other than the DE itself running)?

@luispabon
Copy link

@tvld I have the same problem. I don't believe X is correctly picking up the new graphics card.

@tvld
Copy link

tvld commented May 29, 2018

@luispabon I believe I can boot on Nvidia if I delete /etc/X11/xorg.conf... but I dont wanna go there. Very time consuming to debug this nonsense ;-))
Ps - Got FHD. I run the normal chat apps in the topbar but other than that no applications open of course. Nothing special though.

@ghost
Copy link

ghost commented Jul 30, 2019

@mogul was that a fresh install of 19.04 or an upgrade off a respun ISO?

@tvld
Copy link

tvld commented Jul 31, 2019

I just did a fresh install of 19.04 and yes! ... All worked straight out of the box on my XPS15 9560 FHD.

My idle power usage with 50% screen, WiFi and Bluetooth on:

Without TLP:

  • Nvidia/Prime: 9.84 W
  • Intel: 6.26 W

With TLP installed:

  • Nvidia/Prime: 8.65W
  • Intel: 5.51 W (on 18.04 was reaching 4.65W though.)

Basically, Intel in idle gives me 30% more battery time. In practice this might be a bit more as the fans seem more aggressive with Nvidia.

@damageboy
Copy link

FYI, you can undervolt Intel CPU with undervolt.py

I use:
--core -150 --cache -150 --gpu -100

for my Dell XPS 9560, which saves a bit more...

@tvld
Copy link

tvld commented Jul 31, 2019

@damageboy do you have measurements ?

@damageboy
Copy link

No, I did it a long time ago, but I remember a 5%+ improvement with 50% brightness, don't have it written / logged anywhere...

@tvld
Copy link

tvld commented Aug 2, 2019

Can confirm undervolt --core -150 --cache -150 --gpu -100 works also on my 9560 and seems to save indeed 10C, and the Joules that go with it.

@luispabon
Copy link

@tvld is that running on intel or nvidia graphics?

@tvld
Copy link

tvld commented Aug 2, 2019

@luispabon what, the 10C? Seems on both. But it did not help me a lot. I was hoping I could get the fan under 3000rpm as that is a real noise threshold for me, during working with Nvidia but that only happens in absolute idle. Normal work I sadly am back to Intel now...

@ghost
Copy link

ghost commented Aug 3, 2019

just did a fresh install of 19.04 on my 9560 (4k monitor) and it worked flawlessly. getting about ~7W running idle with prime intel profile selected, brightness turned all the way down, and bluetooth off.

@markkosorus
Copy link

To those who did a fresh install of 19.04, I have a couple of questions. Do you mean the respun version of it or just the standard ISO? Does multi-monitor work out of the box? And could the fact that I am running dual boot affect this in any way?

@tvld
Copy link

tvld commented Aug 5, 2019

@mablae :
1- standard ISO
2- multi monitor works great, using it every day
3- no clue. Never liked multiboot myself so never used that setup

@markkosorus
Copy link

Thanks @tvld! I'll give 19.04 a shot on dual boot and post an update.

@luispabon
Copy link

luispabon commented Aug 5, 2019

Vanilla 19.04 works fine on the laptop. Including multimonitor - I've tried dp over thunderbolt and hdmi (3 displays inc laptop), and also via thunderbolt dock (tb16, also 3 displays). All good.
Can't say about dual boot as I needed full disk encryption, so had to nuke the whole system.

@ghost
Copy link

ghost commented Aug 5, 2019

@markkosorus i have my xps dual booted with windows and it all works without any issues

@markkosorus
Copy link

@paulyu99 yeah, was about to post an update. 19.04 works out of the box on dual boot.

@mobimation
Copy link

mobimation commented Aug 5, 2019

The power control worked on my XPS 15 9570 with UHD 4K touch screen, 18.04LTS.
With the NVidia hardware disabled I saved some 20 Watts.
I checked with powertop to see what further savings were possible.
After the NVidia turnoff I was at 12.8 W with display intensity on max, connected HDMI 1920x1200 display, USB mouse, USB keyboard. No browser or additional app running.

  • Reducing brightness to "decent level" -> 9.3W
  • Pulling HDMI cable -> 6.49W
  • Removing USB Mouse + Kb -> 6.26W = insignificant
  • Wifi off, Screen brightness down to minimal setting -> 4.33 W !
    So, screen intensity contributes a lot.

@naschpitz
Copy link

The solution pointed by @tvld worked flawlessly until kernel 4.15.0-54. For kernel 4.15.0-58 even after running echo auto > /sys/bus/pci/devices/0000\:01\:00.0/power/control the power consumption is still high (~20W). Curiously running cat /sys/bus/pci/devices/0000\:01\:00.0/power/control will still return "auto".

Is anyone facing the same issue?

@tvld
Copy link

tvld commented Nov 1, 2019

Installed Ubuntu 19.10. Sad to say, my idle CPU on Intel only raised with 15% to 7W. I dont know what causes yet, but first glance seemed that tick_sched_timer is high in powertop. Will monitor a bit.
Did anybody else see a power raise after upgrading?

@tvld
Copy link

tvld commented Nov 2, 2019

Ok, found the culprit, it seems.

After I upgraded to 19.10, I got flooded with syslog errors with Nvidia enabled or on-demand: PCIE Bus Error: Severity=Corrected after booting into Ubuntu. To get rid of those, I edited /etc/default/grub to contain GRUB_CMDLINE_LINUX_DEFAULT="quiet splash pci=nomsi". That helped, the errors no longer appeared...

But now I know that this also shot up my power consumption. So, today, I removed the pci-nomsi and now we are to an astonishing great 3.74W with 50% display and BT mouse!

Screenshot from 2019-11-02 11-36-59

So, for now, can not use Nvidia at all, unless I change the grub every time... bummer :(
See what Nvidia has to say.

@advance512
Copy link

Ok, found the culprit, it seems.

After I upgraded to 19.10, I got flooded with syslog errors with Nvidia enabled or on-demand: PCIE Bus Error: Severity=Corrected after booting into Ubuntu. To get rid of those, I edited /etc/default/grub to contain GRUB_CMDLINE_LINUX_DEFAULT="quiet splash pci=nomsi". That helped, the errors no longer appeared...

But now I know that this also shot up my power consumption. So, today, I removed the pci-nomsi and now we are to an astonishing great 3.74W with 50% display and BT mouse!

Screenshot from 2019-11-02 11-36-59

So, for now, can not use Nvidia at all, unless I change the grub every time... bummer :(
See what Nvidia has to say.

That's great! So did you create two Grub configurations, so you can reboot and pick "with nVidia" or "without nVidia"?

@luispabon
Copy link

luispabon commented Nov 24, 2019 via email

@tvld
Copy link

tvld commented Nov 25, 2019

@luispabon no " syslog errors with Nvidia" ?

@luispabon
Copy link

Nothing that I can see when I enable the driver. I get some when I connect my TB16 dock though, but doesn't seem to impede operation.

@advance512
Copy link

@luispabon @tvld
do you want mind offering a "bottom line" for this entire thread, specifically focused on Ubuntu 19.10?
What is the current recommended configuration for power saving, how do you re-enable the nVidia GPU?

What is the configuration you're using on your own machine?

Thank you!

@tvld
Copy link

tvld commented Dec 7, 2019

@advance512 for myself I don't have a bottom line for Ubuntu 19.10 Nvidia on XPS15. Two grubs is not really feasible. For now, sad to say I dont use Nvidia.
( Recommendation: bought other new HP laptop with AMD's new chips and all graphics work out of the box blazing fast. So until Dell get it's act together, no more Dell or Nvidia for our company )

@luispabon
Copy link

luispabon commented Dec 7, 2019

Of course. Laptop runs fine on 19.10 default installation, including recommended nvidia drivers (nvidia-435) which are also installed during system installation (if from scratch). Some notes:

  • No need for any custom kernel boot parameters, for instance to ensure suspend/resume works (no acpi_rev_override for instance)
  • Switch back and forth using prime-select
  • If you're using gnome, it only requires you to log out & back in, not a reboot. It basically requires X to restart. I'm not sure how this works in gnome wayland since I'm a sway user
  • If you do not want the nvidia drivers installed (or you must at some point reboot with the driver uninstalled for whatever reason), you must blacklist nouveau. The driver simply won't work on this GTX 1050 and the system will bot to a blank screen. This is the only custom config I've needed.
/etc ~ ack nouveau 
modprobe.d/blacklist-nouveau.conf
1:blacklist nouveau
2:options nouveau modeset=0

I haven't yet tried the new optimus-like gpu offloading (requires a newer version of X as well as the nvidia driver). I'm unsure if it's even compatible with pre 2xxx series. Something to check out for 20.04.

@lacoursj
Copy link

lacoursj commented Dec 8, 2019 via email

@tvld
Copy link

tvld commented Dec 9, 2019

@lacoursj It should do boot just fine. I have latest BIOS, so you might check if you need to upgrade? Further, I think I have Legacy Boot setting in BIOS on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests