Askannz / optimus-manager

A Linux program to handle GPU switching on Optimus laptops.
MIT License
2.28k stars 166 forks source link

Power-hungry `modprobe nvidia-uvm` process when using integrated graphics #513

Closed jasper1378 closed 3 months ago

jasper1378 commented 2 years ago

Describe the bug I installed optimus-manager a while ago and everything seemed to be working fine. However I haven't used my laptop on battery much since then, and when I did today, I noticed very poor battery life when using the integrated graphics.

A look at htop showed a very power-hungry/cpu-intensive process called modprobe nvidia-uvm that would continuously respawn.

After switching to my nvidia gpu using optimus-manager, my battery life improved significantly. A look at htop showed that the modprobe nvidia-uvm process was no longer present. After running systemctl disable optimus-manager and rebooting the process was also not present, so I deduced that it must be related to optimus-manager.

I am using the "PCI power control" method of power management as described on the wiki.

Any help would be greatly appreciated!

System info

[nvidia] DPI=96 PAT=yes allow_external_gpus=no dynamic_power_management=no ignore_abi=no modeset=yes options=overclocking

[optimus] auto_logout=yes pci_power_control=yes pci_remove=no pci_reset=no startup_auto_battery_mode=integrated startup_auto_extpower_mode=nvidia startup_mode=integrated switching=nouveau


**Logs**
- `optimus-manager --status`

Optimus Manager (Client) version 1.4

Current GPU mode : integrated GPU mode requested for next login : no change GPU at startup : integrated Temporary config path: no

- `/var/log/optimus-manager/switch`

[37] INFO: # Xorg pre-start hook
1 [37] INFO: Previous state was: {'type': 'pending_pre_xorg_start', 'requested_mode': 'integrated', 'current_mode': None}
2 [37] INFO: Requested mode is: integrated
3 [2031] INFO: Available modules: ['nouveau', 'nvidia', 'nvidia_drm' , 'nvidia_modeset', 'nvidia_uvm']
4 [2031] INFO: Unloading modules ['nvidia_drm', 'nvidia_modeset', 'n vidia_uvm', 'nvidia'] (if loaded)
5 [2038] INFO: switching=nouveau, nothing to do
6 [2038] INFO: Loading module nouveau
7 [8346] INFO: Setting Nvidia PCI power state to auto
8 [8674] INFO: Writing "auto" to /sys/bus/pci/devices/0000:01:00.0/p ower/control
9 [8745] INFO: Writing to /etc/X11/xorg.conf.d/10-optimus-manager.co nf
10 [8745] INFO: Writing state {'type': 'pending_post_xorg_start', 'sw itch_id': '20220909T095429', 'requested_mode': 'integrated'}
11 [8746] INFO: Xorg pre-start hook completed successfully.
12 [16] INFO: # Xorg post-start hook
13 [74] INFO: Running /etc/optimus-manager/xsetup-integrated.sh
14 [161] INFO: Writing state {'type': 'done', 'switch_id': '20220909T 095429', 'current_mode': 'integrated'}
15 [162] INFO: Xorg post-start hook completed successfully.


- `/var/log/optimus-manager/daemon`

[37] INFO: # Daemon pre-start hook
1 [37] INFO: Removing /etc/X11/xorg.conf.d/10-optimus-manager.conf ( if present)
2 [38] INFO: Copying /etc/optimus-manager/optimus-manager.conf to /v ar/lib/optimus-manager/tmp/config_copy.conf
3 [43] INFO: Startup mode is: integrated
4 [43] INFO: Writing state {'type': 'pending_pre_xorg_start', 'reque sted_mode': 'integrated', 'current_mode': None}
5 [44] INFO: Daemon pre-start hook completed successfully.
6 [44] INFO: Calling Xorg pre-start hook.
7 [3] INFO: # Commands daemon
8 [3] INFO: Opening UNIX socket
9 [3] INFO: Awaiting commands

jasper1378 commented 2 years ago

I should add that blacklisting nvidia-uvm seems to have no effect.

jasper1378 commented 2 years ago

Running sudo systemctl stop systemd-udevd systemd-udevd-kernel.socket systemd-udevd-control.socket && sudo systemctl start systemd-udevd systemd-udevd-kernel.socket systemd-udevd-control.socket after booting seems to fix the problem; however it doesn't resolve the root of the issue.

jasper1378 commented 2 years ago

The tree of the process is:

systemd
    systemd-udevd
        nvidia-modprobe
            modprobe
jasper1378 commented 2 years ago

My understanding of the situation so far is that optimus-manager cuts power to the nvidia gpu (as it's supposed to). Because the gpu is powered off, systemd is unable to load the nvidia-uvm kernel module, so it just keeps trying and trying. This would leave me to believe that the problem is not actually the fault of optimus-manager, but rather just a side-effect. However I will leave this issue open in case someone else has more insight into the situation.

nwildner commented 3 months ago

@jasper1378 , Is this still a issue to you? Are you able to still reproduce this using the most recent optimus-manager-git?

Funny thing is that when I was testing envycontrol, I've got a similar problem there where systemd-udev worker would smash my CPU making the battery deplete fast. Here.

Since this issue isn't active for the last 2 years ago and a lot has changed in many aspects of multiple software, we'll keep this case opened for some days and close it if no further comments are provided. We're dealing with backlog here to try to keep optimus-manager in a good shape and active as a project.

Have a nice week ahead.

jasper1378 commented 3 months ago

Unfortunately I'm no longer using a laptop with dual graphics, so I'm not sure if this is still a problem.

I appreciate you looking into this issue!