1

I noticed that after upgrading from Loki to Juno my battery life was severally decreased. I have a Dell XPS 9550 with a NVIDI GeForce(R) GTX 960M.

  • I've installed tlp and tlp-rdw
  • I've addded the nvidia graphics drivers ppa: ppa:graphics-drivers/ppa.
  • I'm using nvidia-driver-...
  • I've installed all the recent updates
  • I've switched to intel using prime-select.

I noticed however when checking powertop Tunables, when running from battery the following item:

Bad           Runtime PM for PCI Device NVIDIA Corporation GM107M [GeForce GTX 960M]

I also noticed:

The battery reports a discharge rate of 20.9 W

When I switched the NVIDIA item from bad to good I got:

The battery reports a discharge rate of 12.4 W

Which is quite a significant drop.

I found this possible related question, but the issue seems solved and should have been back-ported to Ubuntu 18.04 already.
https://askubuntu.com/questions/1037977/optimus-nvidia-gpu-turned-on-whatever-prime-select-says/1045767?noredirect=1#comment1799551_1045767

Questions:

  • Why would the NVIDIA card still use power even though I selected Intel?
  • Is there a better way to disable it?
  • Is there an easy way to make this powertop tune permanent?

2 Answers 2

1

Update: Augustin found a better approach for using a SystemD service:

One option to make this powertop tune permanent:

  1. Copy the command powertop executes when switching the nvidia tunable from bad to good. In my case that was:
    /bin/echo auto > /sys/bus/pci/devices/0000:02:00.0/power/control
  2. Add a SystemD service that executes that command: create:
    /etc/systemd/system/nvidia-power-control.service
  3. Fill with:

    [Unit]
    Description=NVIDIA automatic power control
    [Service]
    Type=oneshot
    ExecStart=/bin/sh -c '/bin/echo auto > /sys/bus/pci/devices/0000:02:00.0/power/control'
    KillMode=none
    [Install]
    WantedBy=multi-user.target      
    

    Make sure the command inside the /bin/sh -c '' is the copied command.

  4. Run: systemctl daemon-reload.
  5. Run: systemctl enable nvidia-power-control.
  6. Run: systemctl start nvidia-power-control.
  7. Verify it's running:

    $ systemctl status nvidia-power-control
    ● nvidia-power-control.service - NVIDIA automatic power control
       Loaded: loaded (/etc/systemd/system/nvidia-power-control.service; enabled; vendor preset: enabled)
       Active: inactive (dead) since Thu 2018-11-29 14:21:20 CET; 6s ago
      Process: 28759 ExecStart=/bin/sh -c /bin/echo auto > /sys/bus/pci/devices/0000:02:00.0/power/control (code=exited, status=0/S
     Main PID: 28759 (code=exited, status=0/SUCCESS)
    
    nov 29 14:21:20 xps systemd[1]: Starting NVIDIA automatic power control...
    nov 29 
    14:21:20 xps systemd[1]: Started NVIDIA automatic power control.
    

For me this made sure the powertop tunables always indicates good for the Nvidia card.

Please tell me if there is an easier way to do this.

2
  • pretty cool, your workaround is very easy now.
    – Javier A.
    Commented Nov 28, 2018 at 12:43
  • instead of using /usr/local/bin/powertop-tuning i recommend to use /opt and then add the PATH or create a soft link in /usr/local/bin/ or w/e
    – Sebastian
    Commented Nov 28, 2018 at 21:51
0

I would like to provide alternative way to make PowerTop tune permanent.

// According to Ubuntu ManPage rc.local is now provided for backward compatibility and shouldn't be used unless it's not necessary.

// A proper way is probably to use a particular unit file. See Peter's answer.

Also /etc/rc.local can be used to achieve this. When this file exists it's being executed automatically during late boot.

For more info about rc.local see:

http://manpages.ubuntu.com/manpages/bionic/man8/systemd-rc-local-generator.8.html

1. Create /etc/rc.local file

sudo nano /etc/rc.local

2. Write the script

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

echo auto > /sys/bus/pci/devices/0000:01:00.0/power/control

exit 0

Source: https://hastebin.com/yurufehezi.bash

3. Make it executable

sudo chmod +x /etc/rc.local

4. Reboot your machine

After that systemd rc-local.service is available and loaded:

$ systemctl status rc-local.service 
● rc-local.service - /etc/rc.local Compatibility
   Loaded: loaded (/lib/systemd/system/rc-local.service; enabled-runtime; vendo
  Drop-In: /lib/systemd/system/rc-local.service.d
           └─debian.conf
   Active: active (exited) since Tue 2018-11-27 14:36:30 CET; 1 day 7h ago
     Docs: man:systemd-rc-local-generator(8)
    Tasks: 0 (limit: 4915)
   CGroup: /system.slice/rc-local.service

lis 27 14:36:30 elementaryNix systemd[1]: Starting /etc/rc.local Compatibility.
lis 27 14:36:30 elementaryNix rc.local[1229]: Enabled persistence mode for GPU 
lis 27 14:36:30 elementaryNix rc.local[1229]: All done.
lis 27 14:36:30 elementaryNix systemd[1]: Started /etc/rc.local Compatibility.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.