Jump to content

Nvidia: Difference between revisions

1,195 bytes added ,  Tuesday at 20:25
m
fixed link to „Unfree software“ (capitalization)
No edit summary
m (fixed link to „Unfree software“ (capitalization))
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
There are several drivers that allow Nvidia GPUs to work:
There are several kernel drivers that allow Nvidia GPUs to work:


* Nouveau is the stable 3rd-party open-source driver. You probably have it by default.
* Nouveau is the stable 3rd-party open-source driver. You probably have it by default.
* Nvidia's proprietary kernel module. Better 3D performance than nouveau.
* Nvidia's proprietary kernel module. Better 3D performance than nouveau.
* Nvidia's open-source kernel module, which is beta-quality and x11-only.
* Nvidia's open-source kernel module, which is beta-quality and x11-only.
* Nvidia's mesa-nvk.


This article aims to explain how to use all three of the non-default drivers, and how to disable the Nvidia GPU if you don't want it to make heat.
This article aims to explain how to use all three of the non-default drivers, and how to disable the Nvidia GPU if you don't want it to make heat.
(A GPU driver is not ''purely'' kernel-mode; there are also userspace parts that allow the graphics API to use the kernel part. Mesa, for example, has userspace parts for Nouveau and NVK; they are automatically used when appropriate, so no configuration is needed.<ref>If you insist on checking which driver is in use, try running <code>vulkaninfo | grep -i "deviceName\|driverID"</code>. If you see DRIVER_ID_MESA_NVK, that means you are on the shiny new open-source Vulkan driver.</ref> Nvidia's two kernel drivers also need to be hooked up using userspace libraries provided by Nvidia.)


= The proprietary driver =
= The proprietary driver =
Line 15: Line 16:
* [https://nixos.org/manual/nixos/unstable/#sec-x11-graphics-cards-nvidia Nvidia section] in the NixOS Manual offers a shorter guide.
* [https://nixos.org/manual/nixos/unstable/#sec-x11-graphics-cards-nvidia Nvidia section] in the NixOS Manual offers a shorter guide.
* Basic installation is as simple as <code>services.xserver.videoDrivers = [ "nvidia" ];</code> (once you have unfree software enabled), which causes the default stable version to be pulled in.
* Basic installation is as simple as <code>services.xserver.videoDrivers = [ "nvidia" ];</code> (once you have unfree software enabled), which causes the default stable version to be pulled in.
* Older cards may need an older driver; see [[#Determining the correct driver version]], which describes <code>hardware.nvidia.package</code>.
* Older cards may need an older driver; see [[#Determining the correct driver version|Determining the correct driver version]], which describes <code>hardware.nvidia.package</code>.
* [[#Modifying the NixOS Configuration]] puts it all together and shows the other <code>hardware.nvidia</code> settings, some irrelevant to this driver (e.g. <code>hardware.nvidia.open</code>, which takes you to the Nvidia open kernel driver.)
* [[Nvidia#Modifying NixOS configuration|Modifying the NixOS Configuration]] puts it all together and shows the other <code>hardware.nvidia</code> settings, some irrelevant to this driver (e.g. <code>hardware.nvidia.open</code>, which takes you to the Nvidia open kernel driver.)


== Enable unfree software repositories ==  
== Enable unfree software repositories ==  


Make sure to allow [[Unfree Software|unfree software]]. The unfree NVIDIA packages include <code>nvidia-x11</code>, <code>nvidia-settings</code>, and <code>nvidia-persistenced</code>.
Make sure to allow [[Unfree software|unfree software]]. The unfree NVIDIA packages include <code>nvidia-x11</code>, <code>nvidia-settings</code>, and <code>nvidia-persistenced</code>.
 
== Determining the correct driver version ==
 
You will next need to determine the appropriate driver version for your card. The following options are available:
 
<syntaxhighlight lang="nix">
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable;
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.beta;
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.production;  # (installs 550)
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.vulkan_beta;
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.legacy_470;
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.legacy_390;
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.legacy_340;
</syntaxhighlight>
 
Out of the above, `stable` and `beta` will work for the latest RTX cards and some lower cards so long as they're not considered "legacy" by Nvidia. For "legacy" cards, you can consult the [https://www.nvidia.com/en-us/drivers/unix/legacy-gpu/ Nvidia official legacy driver list] and check whether your device is supported by the 470, 390 or 340 branches. If so, you can use the corresponding <code>legacy_470</code>, <code>legacy_390</code> or <code>legacy_340</code> driver. For a full list of options, consult the [https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/os-specific/linux/nvidia-x11/default.nix nvidia-x11 module repository].
 
{{note|As of early March 2024 the <code>production</code> driver has been updated from <code>535</code> to <code>550</code>. This is a breaking change for some people, especially those on Wayland.
To resolve this, follow the steps under [[Nvidia#Running the new RTX SUPER on NixOS stable|Running the new RTX SUPER on NixOS stable]]}}
 
Once you've determined the correct driver version, note it down; you'll need it in the next step.


== Modifying NixOS configuration ==
== Modifying NixOS configuration ==
Line 53: Line 33:
{
{


   # Enable OpenGL
   # Enable graphics driver in NixOS unstable/NixOS 24.11
   hardware.opengl = {
   hardware.graphics.enable = true;
    enable = true;
  # The same as above but for NixOS 23.11
    driSupport = true;
  #hardware.opengl = {
    driSupport32Bit = true;
  #  enable = true;
   };
  #  driSupport = true;
   #};


   # Load "nvidia" driver for Xorg and Wayland
   # Load "nvidia" driver for Xorg and Wayland
Line 84: Line 65:
     # https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus  
     # https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus  
     # Only available from driver 515.43.04+
     # Only available from driver 515.43.04+
     # Currently alpha-quality/buggy, so false is currently the recommended setting.
     # Currently "beta quality", so false is currently the recommended setting.
     open = false;
     open = false;


Line 97: Line 78:
}
}
</nowiki>}}
</nowiki>}}
=== Determining the correct driver version ===
You might need to determine the appropriate driver version for your card. Some of the options available are:
<syntaxhighlight lang="nix">
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable;      # (390 on i686, else production)
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.beta;        # (555)
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.production;  # (installs 550)
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.vulkan_beta; # (550, but different)
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.legacy_470;
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.legacy_390;
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.legacy_340;
</syntaxhighlight>
Out of the above, <code>stable</code> and <code>beta</code> will work for the latest RTX cards and some lower cards so long as they're not considered "legacy" by Nvidia. For "legacy" cards, you can consult the [https://www.nvidia.com/en-us/drivers/unix/legacy-gpu/ Nvidia official legacy driver list] and check whether your device is supported by the 470, 390 or 340 branches. If so, you can use the corresponding <code>legacy_470</code>, <code>legacy_390</code> or <code>legacy_340</code> driver. For a full list of options, consult the [https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/os-specific/linux/nvidia-x11/default.nix nvidia-x11 module repository].
{{note|As of early March 2024 the <code>production</code> driver has been updated from <code>535</code> to <code>550</code>. This is a breaking change for some people, especially those on Wayland.
To resolve this, follow the steps under [[Nvidia#Running the new RTX SUPER on NixOS stable|Running the new RTX SUPER on NixOS stable]]}}
Once you've determined the correct driver version, note it down; you'll need it in the next step.


== Laptop configuration: hybrid graphics (Optimus PRIME) ==
== Laptop configuration: hybrid graphics (Optimus PRIME) ==
Line 300: Line 302:


{
{
  # Enable graphics driver in NixOS unstable/NixOS 24.11
  hardware.graphics.enable = true;
  # The same as above but for NixOS 23.11
  #hardware.opengl = {
  #  enable = true;
  #  driSupport = true;
  #};


# Enable OpenGL
   # Load nvidia driver for Xorg and Wayland
   hardware.opengl = {
    enable = true;
    driSupport = true;
    driSupport32Bit = true;
  };
 
# Load nvidia driver for Xorg and Wayland
   services.xserver.videoDrivers = ["nvidia"];
   services.xserver.videoDrivers = ["nvidia"];
    
    
Line 384: Line 386:
</syntaxHighlight>
</syntaxHighlight>


= The nvidia-open driver =
= The Nvidia open driver =
The Nvidia open driver is enabled via:
The Nvidia open driver is enabled via:
<pre>
<syntaxHighlight lang="nix">
services.xserver.videoDrivers = [ "nvidia" ];
services.xserver.videoDrivers = [ "nvidia" ];
hardware.nvidia.open = true;
hardware.nvidia.open = true;
</pre>
</syntaxHighlight>
 
The Nvidia open driver is ''very'' similar to its proprietary sibling. Most content in the proprietary section above apply; just copy over the proprietary config above and toggle the "open" option, and you are set.


Really, just copy over the proprietary config above and toggle the "open" option. A lot of the userspace parts are shared, so you still need to enable unfree.
Like its proprietary sibling, it also requires some non-free userspace packages that allow software to talk to the kernel driver. As a result, you still need to enable unfree packages.


Not everything will work, and it will probably not be as stable as its proprietary sibling. Performance may be lower.
Be warned that the Nvidia open driver is considered "beta quality". Performance may be very slightly lower.


= Disable Nvidia dGPU completely =
= Disable Nvidia dGPU completely =
trusted
602

edits