NVIDIA: Difference between revisions
imported>P-h Update to renamed option names |
imported>Eadwu No edit summary |
||
Line 19: | Line 19: | ||
==== offload mode ==== | ==== offload mode ==== | ||
Currently only in unstable, to be included in 20.09. In this mode nvidia card is only activated on demand when you run program(s) with specific environment variables, i.e., here's a sample script | |||
Firstly you need to enable the proprietary nvidia driver | {{file|nvidia-offload|bash|<nowiki> | ||
export __NV_PRIME_RENDER_OFFLOAD=1 | |||
export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0 | |||
export __GLX_VENDOR_LIBRARY_NAME=nvidia | |||
export __VK_LAYER_NV_optimus=NVIDIA_only | |||
exec -a "$0" "$@" | |||
</nowiki>}} | |||
Firstly you need to enable the proprietary nvidia driver (or | |||
{{file|/etc/nixos/configuration.nix|nix|<nowiki> | {{file|/etc/nixos/configuration.nix|nix|<nowiki> | ||
{ | { | ||
Line 28: | Line 36: | ||
</nowiki>}} | </nowiki>}} | ||
Note that on certain laptops and/or if you are using a custom kernel version, you may have issues with your NixOS system finding the primary display. In this case you should also specify | Note that on certain laptops and/or if you are using a custom kernel version, you may have issues with your NixOS system finding the primary display. In this case you should also specify modesetting in videoDrivers as well, i.e. | ||
{{file|/etc/nixos/configuration.nix|nix|<nowiki> | {{file|/etc/nixos/configuration.nix|nix|<nowiki> | ||
{ | { | ||
services.xserver.videoDrivers = [ " | services.xserver.videoDrivers = [ "modesetting" "nvidia" ]; | ||
... | ... | ||
</nowiki>}} | </nowiki>}} | ||
Line 58: | Line 66: | ||
<nowiki>PCI:9:31:0</nowiki> | <nowiki>PCI:9:31:0</nowiki> | ||
An | An possible configuration is shown below | ||
{{file|/etc/nixos/configuration.nix|nix|<nowiki> | {{file|/etc/nixos/configuration.nix|nix|<nowiki> | ||
{ pkgs, ... }: | |||
let | |||
nvidia-offload = pkgs.writeShellScriptBin "nvidia-offload" '' | |||
export __NV_PRIME_RENDER_OFFLOAD=1 | |||
export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0 | |||
export __GLX_VENDOR_LIBRARY_NAME=nvidia | |||
export __VK_LAYER_NV_optimus=NVIDIA_only | |||
exec -a "$0" "$@" | |||
''; | |||
in | |||
{ | { | ||
environment.systemPackages = [ nvidia-offload ]; | |||
hardware.nvidia. | |||
# Bus ID of the | hardware.nvidia.prime.offload.enable = true; | ||
hardware.nvidia.prime = { | |||
# Bus ID of the Intel GPU. You can find it using lspci, either under 3D or VGA | |||
intelBusId = "PCI:0:2:0"; | |||
# Bus ID of the NVIDIA GPU. You can find it using lspci, either under 3D or VGA | |||
nvidiaBusId = "PCI:1:0:0"; | |||
}; | |||
} | } | ||
</nowiki>}} | </nowiki>}} | ||
Line 73: | Line 95: | ||
==== sync mode ==== | ==== sync mode ==== | ||
In this mode nvidia card is turned on constantly, having impact on laptop battery and health. | |||
Possible issues: | Possible issues: | ||
Line 85: | Line 107: | ||
{{file|/etc/nixos/configuration.nix|nix|<nowiki> | {{file|/etc/nixos/configuration.nix|nix|<nowiki> | ||
{ | { | ||
services.xserver.videoDrivers = [ " | services.xserver.videoDrivers = [ "modesetting" "nvidia" ]; | ||
hardware.nvidia.prime.sync.enable = true; | hardware.nvidia.prime.sync.enable = true; | ||
# Bus ID of the NVIDIA GPU. You can find it using lspci, either under 3D or VGA | # Bus ID of the NVIDIA GPU. You can find it using lspci, either under 3D or VGA |