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

If nvidia drivers are installed, Alacritty wakes up the dGPU despite not using it #6366

Closed
chris-morgan opened this issue Sep 27, 2022 · 14 comments

Comments

@chris-morgan
Copy link
Contributor

I use a laptop (ASUS Zephyrus G15 (2021), GA503QM) with AMD integrated graphics (from the Ryzen 5800HS) and an NVIDIA dedicated GPU. Normally I don’t have a driver installed for the NVIDIA GPU. supergfxctl --get reports hybrid, and supergfxctl --status will report suspended.

But recently I’ve taken to sometimes having the nvidia-dkms package installed.

Observation: When it is installed, starting Alacritty loads the nvidia kernel module, spins up the dGPU if it is suspended (which it almost certainly is), which makes startup take 2–5 seconds instead of a couple of hundred milliseconds, and consumes a bunch of extra power, even though Alacritty doesn’t end up using the dGPU, according to nvtop and the observation that the dGPU goes back to sleep after ten seconds or something (supergfxctl --status goes from reporting active back to reporting suspended, and power consumption drops significantly), after just having shortened my battery life by a minute or so each time. Alacritty also prevents me from unloading the nvidia kernel module. (lsof tells me it’s keeping /dev/nvidia0 and /dev/nvidiactl open).

Expectation: If Alacritty isn’t going to use the dGPU, I expect it to not wake it up or load its kernel module. And given a dual-GPU configuration like mine, I expect it to stick with the iGPU and not touch the dGPU.

System

Arch Linux, Sway (Wayland). Alacritty 0.10.1.

@chrisduerr
Copy link
Member

Can you try 0.11.0, just to be sure it's still broken with the latest version?

@Quaqqer
Copy link

Quaqqer commented Dec 14, 2022

I am having the same problem with the same symptoms, on version 0.11.0.

It takes about 1.3s to start when the nvidia card is sleeping. It's even slow to startup for me when the dGPU is disabled in bios but I still have the nvidia driver installed. If I remove the nvidia drivers the startup time is ~130ms as expected.

These are the options i use in NixOS:

  services.xserver.videoDrivers = [ "nvidia" ];

  hardware.nvidia = {
    modesetting.enable = true;

    powerManagement = {
      enable = true;
      finegrained = true;
    };

    prime = {
      offload.enable = true;
      nvidiaBusId = "PCI:1:00:0";
      amdgpuBusId = "PCI:4:00:0";

    };
  };

Here is a flamegraph that may be of use:
flamegraph

@kchibisov
Copy link
Member

I'd suggest to try latest master. Also the issue is not related to alacritty, but libglvnd issue. It's likely even if you have disabled nvidia card everywhere you still have a config in libglvnd to use it, so it tries to open it.

Would suggest to try disabling nvidia config in libglvnd, but not sure how to do that on nixos...

@D0ot
Copy link

D0ot commented Mar 23, 2023

same issue met here,

alacritty would try loading nvidia modules on launch though the nvidia card is already using vfio-pci driver

it slows down the launching

@D0ot
Copy link

D0ot commented Mar 23, 2023

It seems that the libnvidia-glsi.so in nvidia-utils causes the problem.

@D0ot
Copy link

D0ot commented Mar 23, 2023

To address slow lunch time issue a possible workaround could be to rename the file /usr/bin/nvidia-modprobe.

@kchibisov
Copy link
Member

You might try latest master, it might do something better. But if you want to solve it, the solution is to address it on libglvnd level, because that's what is responsible for resolving between nvidia and mesa...

On systems with only mesa or only nvidia that won't be an issue(or if you keep only mesa/nvidia in libglvnd).

@D0ot
Copy link

D0ot commented Mar 24, 2023

Yes, renaming the bin is just a temporary and dirty workaround...

I have just found another solution, just set env variable __EGL_VENDOR_LIBRARY_FILENAMES like these:

export __EGL_VENDOR_LIBRARY_FILENAMES="/usr/share/glvnd/egl_vendor.d/50_mesa.json"

or

export __EGL_VENDOR_LIBRARY_FILENAMES="/usr/share/glvnd/egl_vendor.d/10_nvidia.json"

to choose a vendor.

The environment variable is used in libglvnd

image

@dm17
Copy link

dm17 commented Apr 10, 2023

Any updates? The temporary solution would be to uninstall the dGPU drivers entirely and just use the integrated GPU, it seems.

@kchibisov
Copy link
Member

Setup libglvnd variable for alacritty to always pick the integrated GPU? Alacritty have zero control what GPU it'll pick, because you don't have control over it with OpenGL.

The variable was already suggest here.

@peterzky
Copy link

NixOS

environment.sessionVariables = {
  "__EGL_VENDOR_LIBRARY_FILENAMES" = "/run/opengl-driver/share/glvnd/egl_vendor.d/50_mesa.json";
};

@moreka
Copy link

moreka commented Jan 8, 2024

With setting "__EGL_VENDOR_LIBRARY_FILENAMES" to only mesa, still the lag is there and the nvidia card turns on for a while. In alacritty -vv, I see that after a lag, mesa driver is chosen (Intel UHD Graphics). This makes me wonder if the problem is really with libglvnd. I tested with kitty, and the lag (and turning on of the nvidia card) did not happen. Glxgears, for example, does not have a lag when opening and does not turn the nvidia card on. Is there a way to dig into this issue deeper? Are there more verbose debug options to see why the lag is there?

@kchibisov
Copy link
Member

@moreka is it with the 0.13.1?

@moreka
Copy link

moreka commented Jan 8, 2024

After updating to 0.13.1, it is fixed completely, without needing to set __EGL_VENDOR_LIBRARY_FILENAMES. Thanks a lot!

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

No branches or pull requests

8 participants