Use nvidia drivers only to silence fans and Intel HD GPU otherwise

I have a Nvidia 1060 GTX in my computer but Nvidia drivers don’t work well with Wayland. Therefore, I would like to use the Intel HD GPU because it mostly “just works”. I don’t need 3D acceleration. The only reason to keep Nvidia drivers is to silence the 1060’s fans which otherwise run at 100%.

How can I have the Nvidia drivers installed and have them silence the GPU’s fans but use Intel HD otherwise?

This is my Nvidia related config (taken from the wiki):

  # NVIDIA
    # Source: https://nixos.wiki/wiki/Nvidia#Modifying_NixOS_Configuration
    # Enable OpenGL
      hardware.opengl = {
        enable = true;
        driSupport = true;
        driSupport32Bit = true;
      };

      # Load nvidia driver for Xorg and Wayland
      services.xserver.videoDrivers = ["nvidia"];

      hardware.nvidia = {
        # Modesetting is required.
        modesetting.enable = true;

        # Nvidia power management. Experimental, and can cause sleep/suspend to fail.
        powerManagement.enable = false;
        # Fine-grained power management. Turns off GPU when not in use.
        # Experimental and only works on modern Nvidia GPUs (Turing or newer).
        powerManagement.finegrained = false;

        # Use the NVidia open source kernel module (not to be confused with the
        # independent third-party "nouveau" open source driver).
        # Support is limited to the Turing and later architectures. Full list of
        # supported GPUs is at:
        # https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus
        # Only available from driver 515.43.04+
        # Do not disable this unless your GPU is unsupported or if you have a good reason to.
        open = false;

        # Enable the Nvidia settings menu,
        # accessible via `nvidia-settings`.
        nvidiaSettings = true;

        # Optionally, you may need to select the appropriate driver version for your specific GPU.
        package = config.boot.kernelPackages.nvidiaPackages.stable;
      };

Your current config sets up your nvidia GPU as the only one to be used, I believe.

Set up offload mode as suggested a bit lower on the same page. This will make everything use your intel GPU by default, and then you can switch on the nvidia one for specific applications when it turns out you need acceleration for something after all.

You can find some shared config to do that on nixos-hardware too, as well as one that completely disables the dGPU so it doesn’t draw power at all: https://github.com/NixOS/nixos-hardware/tree/master/common/gpu

You sure? This hasn’t been the case for a while since they start supporting GBM like everybody else. Works fine for quite a while for me now.

If you really don’t intend to use the GPU at all you might consider just completely shutting it off to save the power instead.

2 Likes

I am not. I have almost an identical configuration (KDE+Wayland) deployed on a laptop and on a desktop. The laptop only has an integrated GPU and works without issue. On the Desktop with the Nvidia GPU, Firefox is missing maximize/minimize buttons. Obsidian shows a black screen. Cursor themes are not applied. When I switch to X11 on the Desktop these problems disappear. This is why I assumed that its a Nvidia+Wayland issue.

I was not aware of GBM and can’t find anything in the docs or wiki. Do I have to actiavte it somehow? Is it even available for older GPUs such as the 1060?

I will try the suggested GPU deactivation techniques.

no, sorry, GBM is not user facing. It’s the underlying buffer API that all the other open linux graphics drivers use underneath Wayland. In the early days of Wayland support on Nvidia, they insisted on using a different eglstreams API, which made compatibility with most wayland desktops a big issue.

They since caved and decided to support GBM like everybody else, so its been a lot better for me since then, but I don’t use KDE, so I can’t comment there.

1 Like

Not really answering your question, but i have this as my Nvidia snippet and runs flawlessy on my desktop.

{ config, pkgs, lib, ... }:

with lib;

{
  #---------------------------------------------------------------------
  # Runs well on my GPU: NVIDIA GeForce GT 1030/PCIe/SSE2
  #---------------------------------------------------------------------
  imports = [

    #---------------------------------------------------------------------
    # Nvidia virtulation for Docker/Virtulization
    #---------------------------------------------------------------------
    #./nvidia-docker.nix

  ];

  hardware = {
    nvidia = {
      modesetting.enable = true;
      nvidiaPersistenced = true;

      #---------------------------------------------------------------------
      # Enable the nvidia settings menu
      #---------------------------------------------------------------------
      nvidiaSettings = true;

      #---------------------------------------------------------------------
      # Enable power management (do not disable this unless you have a reason to).
      # Likely to cause problems on laptops and with screen tearing if disabled.
      #---------------------------------------------------------------------
      powerManagement.enable = true;         # Fix Suspend issue

      #---------------------------------------------------------------------
      # Optionally, you may need to select the appropriate driver version for your specific GPU.
      #---------------------------------------------------------------------
      package = config.boot.kernelPackages.nvidiaPackages.stable;

      # Check legacy drivers https://www.nvidia.com/en-us/drivers/unix/legacy-gpu/
      # hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.legacy_340
      # hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.legacy_390
    };

    #---------------------------------------------------------------------
    # Direct Rendering Infrastructure (DRI) support, both for 32-bit and 64-bit, and 
    # Make sure opengl is enabled
    #---------------------------------------------------------------------
    opengl = {
      enable = true;
      driSupport = true;
      driSupport32Bit = true;

      #---------------------------------------------------------------------
      # Install additional packages that improve graphics performance and compatibility.
      #---------------------------------------------------------------------
      extraPackages = with pkgs; [        
        
        amdvlk
        intel-media-driver      # LIBVA_DRIVER_NAME=iHD
        libvdpau-va-gl
        nvidia-vaapi-driver
        vaapiIntel                  # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium)
        vaapiVdpau
        vulkan-validation-layers
      ];

    };
  };

  #---------------------------------------------------------------------
  # OpenRGB && X Server Video Drivers Configuration
  # Tell Xorg to use the nvidia driver (also valid for Wayland)
  #---------------------------------------------------------------------
  services = {
    hardware.openrgb = {
      enable = true;
      motherboard = "intel";
      package = pkgs.openrgb-with-all-plugins;
    };
    xserver.videoDrivers = [ "nvidia" ];
  };

  #---------------------------------------------------------------------
  # Set environment variables related to NVIDIA graphics:
  #---------------------------------------------------------------------
  environment.variables = {
    GBM_BACKEND = "nvidia-drm";
    LIBVA_DRIVER_NAME = "nvidia";
    __GLX_VENDOR_LIBRARY_NAME = "nvidia";
  };

  #---------------------------------------------------------------------
  # Packages related to NVIDIA graphics:
  #---------------------------------------------------------------------
  environment.systemPackages = with pkgs; [

    clinfo
    gwe
    nvtop-nvidia
    virtualglLib
    vulkan-loader
    vulkan-tools

  ];

}
1 Like

Thanks for the suggestions. I started setting up this Nvidia Prime thing but I am not sure it even applies to my use case. Does the guide work for desktop computers with an Intel iGPU in the CPU and a dedicated PCIE Nvidia GPU? I don’t have a laptop. And the “Offload” options only works with a Turing generation GPU, which I don’t have.

Am I missing something?

Yes. Laptops are just small PCs with components in nonstandard shapes.

Oh, huh, overlooked that. You’ll probably want the full disable then: nixos-hardware/common/gpu/nvidia/disable.nix at 11d50c5d52472ed40d3cb109daad03c836d2b328 · NixOS/nixos-hardware · GitHub

(or use envycontrol, though it’s less useful if you want to switch between integrated-only and discrete-only modes, because that will always require reloading some drivers and your whole desktop env)

Its just that the Wiki talks about “Optimus” in combination with Laptops so I suspect(ed) that it requires some kind of special hardware or things that only mobile GPUs support.

Yep, fair enough, but no it does not to my knowledge. At least I’m aware of other people that have run this with desktop PCs.

I think the wiki (and other similar resources) talk about laptops because 99% of these use cases are laptops, and people haven’t really woken up to desktop PCs even having iGPUs, let alone having a use case for using them in tandem with a dGPU instead of just the dGPU.

The term “laptop” is very vague, but more clear and accurate enough (you’d hope) to people who just install the OS on some hardware they don’t understand. And probably the most common type of hardware anyway.

1 Like

I gained some new insight. The main problems (missing window decorations and cursor theme) were solved by adding programs.dconf.enable = true;. I now understand that the issue was simply a GTK theme not being overridden by KDE and not a Wayland issue. Strangely this expression was not needed on the Laptop or I forgot that I had set it imperatively. I had assumed that it must be Nvidia, since the configs are otherwise almost identical. I think, I had expected the degree of reproducibility in NixOS to be higher :man_shrugging:t2:.

Anyway, my need to disable the Nvidia drivers has disappeared and I will not proceed further. Thank you for your help.

Thanks for posting the config. Although my problem was resolved by other means, I took some inspiration from it and e.g. installed OpenRGB to turn of my GPU’s lights. I also have some questions:

  1. Why the package amdvlk? Isn’t it for AMD?
  2. Why the packages vulkan-validation-layers, vulkan-tools, vulkan-loader etc.? Do you actually need them for something or did you just add them because they are related to Nvidia and you just added all of them “just in case”?
  3. Same with environment variables: Was there a specific need for them or “just in case”?

Majority of it is for nvidia and opencl / opengl utilities. A number of utilities didnt function properly without these. After adding these in as per in the snippet my overall experience with nvidia on nixos, on this desktop, has been flawless both in performance and power management. My system goes into sleep mode alot. I do my tasks and walk away and then happily goes to sleep for days on end and never failed to wake to resume on what i leave open

{ lib, pkgs, config, ... }:

{
  imports = [ ./. ];

  hardware.nvidia.prime = {
    offload = {

      enable = lib.mkOverride 990 true;
      enableOffloadCmd = lib.mkIf config.hardware.nvidia.prime.offload.enable true; # Provides `nvidia-offload` command.

    };
    # Hardware should specify the bus ID for intel/nvidia devices
  };
}
{ config, lib, pkgs, ... }:

{
  # Enable Bumblebee for NVIDIA Optimus support
  hardware.bumblebee.enable = true;
  hardware.bumblebee.driver = "nvidia";
  hardware.bumblebee.pmMethod = "bbswitch";

  # Define an overlay to make necessary adjustments
  nixpkgs.overlays = [
    (self: super: {
      bumblebee = super.bumblebee.overrideAttrs
        (oldAttrs: { meta = oldAttrs.meta // { broken = false; }; });

      # Adjust the NVIDIA driver package
      nvidiaPackages = super.nvidiaPackages // {
        legacy390 = super.nvidia_x11_legacy390;
      };

      # Enable Steam with Primus and extra packages
      steam = super.steam.override {
        withPrimus = true;
        extraPkgs = pkgs: [ pkgs.bumblebee pkgs.glxinfo ];
      };
    })
  ];
}