I can confirm as well, that the udev rules disable my Nvidia GPU when not being used
Hey all, having discovered this thread i now know that i’m out of luck. My GPU seems to be too old (it’s a Thinkpad P43s, lspci
reports 3D controller: NVIDIA Corporation GP108GLM [Quadro P520] (rev a1)
) to support runtime power management properly.
$ cat /proc/driver/nvidia/gpus/*/power
Runtime D3 status: Not supported
Video Memory: Active
GPU Hardware Support:
Video Memory Self Refresh: Not Supported
Video Memory Off: Not Supported
While it seems the nVidia card does go into a low-power state, my battery life is still terrible (i have configured TLP to try to reduce power consumption of all the other things).
I hope this isn’t too out-of-scope for this thread, but i’d love to be able to hard-disable the nVidia card, as in, never turn it on in the first place, offloading be damned. Is this possible? Unfortunately i’m not sure where or how to experiment with this. I have tried blacklisting the nvidia
driver, but that doesn’t seem to turn off the PCI device. Since i just use terminals and things, i’d love to be able to just force Intel-only video.
Thank you to all those already providing assistance in this thread!
EDIT this https://major.io/p/disable-nvidia-gpu-thinkpad-t490/ actually looks quite promising, but i wouldn’t know how to go about doing that in NixOS!
Hey @paul,
you may want to check out the GitHub - NixOS/nixos-hardware: A collection of NixOS modules covering hardware quirks. repository. For my notebook, there is a intel-configuration that switches off the nvidia card entirely:
https://github.com/NixOS/nixos-hardware/blob/40ade7c0349d31e9f9722c7331de3c473f65dce0/dell/xps/15-9560/intel/default.nix (also check out the imports from this file).
Either you can take the commands from that configuration, or maybe there is already something ready to use for your P43s…
Hi! Thank you for your reply. I didn’t know about that nixos-hardware
repo! Very useful-looking.
The only thing that looked different to all the things i’d tried (e.g. manually using bbswitch
, etc.) was the hardware.nvidiaOptimus.disable = lib.mkDefault true;
, but unfortunately that also didn’t work. FWIW i look at lspci
and see (rev a1)
by the GPU, i expect (rev ff)
if it’s working, i believe.
But your GPU/Intel architecure is Turing/Coffee Lake or newer, right?
I think that’s the problem. I have i7-8565U CPU
and lspci
says 3c:00.0 3D controller: NVIDIA Corporation GP108GLM [Quadro P520] (rev a1)
. I haven’t found clear info but i suspect the graphics chip is “too old”.
Surely there must be a way to hard-disable it – at this point i’d physically remove it if i could.
I wonder if something like https://major.io/p/disable-nvidia-gpu-thinkpad-t490/ might work?
For reference, i see on https://www.notebookcheck.net/Lenovo-ThinkPad-P43s-laptop-review-The-mobile-workstation-s-display-and-performance-disappoint.439972.0.html (under the heading “Energy consumption”) that the system idles around 5W in Windows, while for me it’s usually hovering at 7.5-8W when i’m doing nothing at all. This tells me that somehow in Windows the driver is probably able to shut off the GPU completely, because anecdotally i’ve seen folks claim about a 2.5W power usage decrease when a similar nVidia GPU is powered down vs in lowest P-state. Surely it must be possible then?
OK, so i take that back (apologies for the back-and-forth). Even though
$ cat /proc/acpi/bbswitch
0000:3c:00.0 ON
and lspci
still say [Quadro P520] (rev a1)
, it does seem as if the power usage drops lower than it has in the past. If i leave it to settle down, it seems to get as low as about 5.5-6.5W, so that’s already a big win.
Your graphics card should be pascal, which is earlier than Turing: https://www.techpowerup.com/gpu-specs/nvidia-gp108.g808.
You shouldn’t use bbswitch on kernels newer than 4.8 (see arch wiki).
The easiest way is probably to just not install the nvidia drivers. Then, the card shoud not be turned on. The drivers shouldn’t be installed if you simply don’t list them in services.xserver.videoDrivers
. If this does not help, you can try hybrid graphics with the nouveau driver (following the NixOS manual and/or wiki). It probably does not provide any performance gain of the nvidia card over the intel one, but should safely turn off the nvidia card if you don’t start a program with the environment variable DRI_PRIME=1
. nouveau uses the default PRIME mechanism from the Linux kernel instead of the nvidia proprietary solution.
Just wanted to come here to thank you for this.
With a 2060M, these udev rules solved my battery life problem on a Dell G5. Worst part is the same udev rules as per Arch wiki wasn’t working on arch for me so switched to NixOS and was stil struggling with battery life, but now cat /sys/bus/pci/devices/0000:01:00.0/power/runtime_status
shows suspended
and nvidia-offload glxinfo | grep ‘OpenGL render’ shows
OpenGL renderer string: NVIDIA GeForce RTX 2060/PCIe/SSE2
Meanwhile, my idle system wattage is down to ~7.5w instead of 13w!!!
Wooot, thank you!
hardware.nvidia.powerManagement.enable did nothing, at least not on its own. I wonder if that requires other config items but your extra modprobe config and udev rules did the trick!!
I’ve used the udev rules from the arch wiki, and the card got disabled indeed.
But how can I enable it dynamically to use with nvidia-offload
? I just get an Failed to initialize NVML: No supported GPUs were found
error.
For me, this is what worked
hardware.nvidia = {
open = false;
nvidiaPersistenced = true;
prime = {
# PCI:0:2:0 didn't work
intelBusId = "0@0:2:0";
nvidiaBusId = "1@0:0:0";
offload.enable = true;
offload.enableOffloadCmd = true;
};
};
services.xserver.videoDrivers = [
# without modesetting, x server will be run by nvidia
"modesetting"
"nvidia"
];
nixpkgs.config.nvidia.acceptLicense = true;
This allowed me to offload, and x server runs on intel and not nvidia.
This did not work for me.
Jan 12 23:25:16 nixos systemd[1]: Starting Display Manager...
Jan 12 23:25:16 nixos systemd[1]: Started Display Manager.
Jan 12 23:25:17 nixos systemd[1]: display-manager.service: Main process exited, code=exited, status=1/FAILURE
Jan 12 23:25:17 nixos systemd[1]: display-manager.service: Failed with result 'exit-code'.
Jan 12 23:25:17 nixos systemd[1]: display-manager.service: Triggering OnFailure= dependencies.
Jan 12 23:25:17 nixos systemd[1]: display-manager.service: Failed to enqueue OnFailure= job, ignoring: Unit plymouth-quit.service not found.
Jan 12 23:25:17 nixos systemd[1]: display-manager.service: Consumed 1.388s CPU time, 193.5M memory peak, 222.4M read from disk, 76K written to disk.
Jan 12 23:25:18 nixos systemd[1]: display-manager.service: Scheduled restart job, restart counter is at 1.
Jan 12 23:25:18 nixos systemd[1]: Starting Display Manager...
Jan 12 23:25:18 nixos systemd[1]: Started Display Manager.
Jan 12 23:25:19 nixos systemd[1]: display-manager.service: Main process exited, code=exited, status=1/FAILURE
Jan 12 23:25:19 nixos systemd[1]: display-manager.service: Failed with result 'exit-code'.
Jan 12 23:25:19 nixos systemd[1]: display-manager.service: Triggering OnFailure= dependencies.
Jan 12 23:25:19 nixos systemd[1]: display-manager.service: Failed to enqueue OnFailure= job, ignoring: Unit plymouth-quit.service not found.
Jan 12 23:25:19 nixos systemd[1]: display-manager.service: Consumed 1.391s CPU time, 80.8M memory peak, 76K written to disk.
Jan 12 23:25:20 nixos systemd[1]: display-manager.service: Scheduled restart job, restart counter is at 2.
Jan 12 23:25:20 nixos systemd[1]: Starting Display Manager...
Jan 12 23:25:20 nixos systemd[1]: Started Display Manager.
Jan 12 23:25:21 nixos systemd[1]: display-manager.service: Main process exited, code=exited, status=1/FAILURE
Jan 12 23:25:21 nixos systemd[1]: display-manager.service: Failed with result 'exit-code'.
Jan 12 23:25:21 nixos systemd[1]: display-manager.service: Triggering OnFailure= dependencies.
Jan 12 23:25:21 nixos systemd[1]: display-manager.service: Failed to enqueue OnFailure= job, ignoring: Unit plymouth-quit.service not found.
Jan 12 23:25:21 nixos systemd[1]: display-manager.service: Consumed 1.417s CPU time, 80.8M memory peak, 76K written to disk.
Jan 12 23:25:22 nixos systemd[1]: display-manager.service: Scheduled restart job, restart counter is at 3.
Jan 12 23:25:22 nixos systemd[1]: display-manager.service: Start request repeated too quickly.
Jan 12 23:25:22 nixos systemd[1]: display-manager.service: Failed with result 'exit-code'.
Jan 12 23:25:22 nixos systemd[1]: Failed to start Display Manager.
@phanirithvij Thank you – looks like I’ve been running Nvidia Offload Mode wrong all these years!
Indeed, without "modesetting"
in videoDrivers
, nvidia-smi
always show X
in the list of applications that use the Nvidia GPU:
+-----------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=========================================================================================|
| 0 N/A N/A 2905 G ...mjm-xorg-server-21.1.16/bin/X 2MiB |
+-----------------------------------------------------------------------------------------+
I think we should update:
accordingly (EDIT: I’ve done those wiki updates).
But question: What about Sync mode?
Should that also have both modesetting
and nvidia
?
Edit: The NixOS option description for hardware.nvidia.prime.sync.enable
says:
this option only has any effect if the “nvidia” driver is specified in
services.xserver.videoDrivers
, and it should preferably be the only driver there.
I’ve made a PR to update the NixOS option docs for offload.enable
, and the code comments, please review if my changes are corrct:
FWIW, if you’re using nixos unstable and have a Turing or newer GPU, NVK and zink are getting to the point of being pretty good for non-cuda stuff. With the latest version of mesa that’s on unstable, you can just remove anything having to do with graphics drivers from your config and it should work basically the same as it works for amdgpu. That is, I believe mesa, by default, will use the GPU the display is connected to for the desktop, and it’ll use the more powerful GPU for things like games. And when mesa uses the nvidia one, it should use NVK / zink now. And you can set the DRI_PRIME
environment variable for a process to override the default choice.
TL;DR: On NixOS unstable, the mainline drivers in mesa have gotten to the point of basically working fairly well out of the box on nvidia without any configuration, much like they do for amdgpu.
Bumping this thread because I am facing some weird behavior -
I am using Hyprland on my laptop (i7 11800h and RTX 3070), and basically even after setting the proper value in AQ_DRM_DEVICES, hyprland is still running on the nvidia gpu.
My nvidia setup using PRIME Offload
The issue I am suspecting is due to this the nvidia GPU doesn’t deactivate, even after using the udev rules mentioned here.
The weird part is that nothing is listed running under nvidia-smi, but when I run sudo fuser -v /dev/nvidia*
the output is.
USER PID ACCESS COMMAND
/dev/nvidia0: intellomaniac 3162 F.... .Hyprland-wrapp
/dev/nvidiactl: intellomaniac 3162 F.... .Hyprland-wrapp
The output for cat /proc/driver/nvidia/gpus/0000:01:00.0/power
is
File: power
───────┼─────────────────────────────────────────────────────────────────────────────────────
1 │ Runtime D3 status: Enabled (fine-grained)
2 │ Video Memory: Active
3 │
4 │ GPU Hardware Support:
5 │ Video Memory Self Refresh: Supported
6 │ Video Memory Off: Supported
7 │
8 │ S0ix Power Management:
9 │ Platform Support: Not Supported
10 │ Status: Disabled
11 │
12 │ Notebook Dynamic Boost: Supported
Basically I want the nvidia gpu to be disabled, it should run only when I offload something to it.