Nvidia: Difference between revisions

imported>Nadimkobeissi
Fix errors
imported>Nadimkobeissi
No edit summary
Line 6: Line 6:


Make sure to allow 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. 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="bash">
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.beta
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.vulkan_beta
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 390 or 340 branches. If so, you can use the corresponding <code>legacy_390</code> or <code>legacy_340</code> driver.
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 69:
}
}
</nowiki>}}
</nowiki>}}
== Determining the Correct Driver Version ==
As noted in the final comment above, you'll need to determine the appropriate driver version for your card. The following options are available:
<syntaxhighlight lang="bash">
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.beta
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.vulkan_beta
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 390 or 340 branches. If so, you can use the corresponding <code>legacy_390</code> or <code>legacy_340</code> driver.


== Laptop Configuration: Hybrid Graphics (Nvidia Optimus PRIME) ==
== Laptop Configuration: Hybrid Graphics (Nvidia Optimus PRIME) ==
Line 123: Line 125:
</nowiki>}}
</nowiki>}}


=== Optimus PRIME Option A: Offload Mode (Optional, Recommended) ===
=== Optimus PRIME Option A: Offload Mode ===


''Offload Mode is available in NixOS 20.09 and higher, and requires an Nvidia card of the Turing generation or newer, and an Intel chipset from the Coffee Lake generation or newer.''
''Offload Mode is available in NixOS 20.09 and higher, and requires an Nvidia card of the Turing generation or newer, and an Intel chipset from the Coffee Lake generation or newer.''
Line 156: Line 158:
</nowiki>}}
</nowiki>}}


=== Optimus PRIME Option B: Sync Mode (Optional) ===
=== Optimus PRIME Option B: Sync Mode ===
 
Enabling PRIME sync introduces better performance and greatly reduces screen tearing, at the expense of higher power consumption since the Nvidia GPU will not go to sleep completely unless called for, as is the case in Offload Mode. It may also cause its own issues in rare cases. '''PRIME Sync and Offload Mode cannot be enabled at the same time.'''


Enabling PRIME sychronization introduces better performance and greatly reduces screen tearing, at the expense of higher power consumption since the Nvidia GPU will not go to sleep completely unless called for, as is the case in Offload Mode. It may also cause its own issues in rare cases. '''PRIME Sync and Offload Mode cannot be enabled at the same time.'''
PRIME sync may also solve some issues with connecting a display in clamshell mode directly to the GPU.


{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
Line 244: Line 248:
=== Screen Tearing Issues ===
=== Screen Tearing Issues ===


First, try to switch to PRIME Sync Mode, as described above. If that doesn't work, try forcing a full composition pipeline.
First, try to switch to PRIME Sync Mode, as described above. If that doesn't work, try forcing a composition pipeline.


{{note|Forcing a full composition pipeline has been reported to reduce the performance of some OpenGL applications and may produce issues in WebGL. It also drastically increases the time the driver needs to clock down after load.}}
{{note|Forcing a full composition pipeline has been reported to reduce the performance of some OpenGL applications and may produce issues in WebGL. It also drastically increases the time the driver needs to clock down after load.}}