NVIDIA: Difference between revisions
imported>Bitmappergit m conciseness |
imported>Cyounkins m Correcting link to official manual |
||
Line 6: | Line 6: | ||
== Non-optimus mode == | == Non-optimus mode == | ||
'''You need MXM card'''. Follow [https://nixos.org/nixos/manual/# | '''You need MXM card'''. Follow [https://nixos.org/nixos/manual/#sec-x11-graphics-cards-nvidia NVIDIA Graphics Cards] section in official manual. | ||
In case of laptop you may also need to use a BIOS option to select which card to use for the internal display. | In case of laptop you may also need to use a BIOS option to select which card to use for the internal display. |
Revision as of 18:59, 3 December 2018
Card type
- MXM / output-providing card (shows as VGA Controller in lspci), i.e. graphics card in desktop computer or in some laptops
- muxless/non-MXM Optimus cards have no display outputs and show as 3D Controller in lspci output, seen in most modern consumer laptops
Non-optimus mode
You need MXM card. Follow NVIDIA Graphics Cards section in official manual.
In case of laptop you may also need to use a BIOS option to select which card to use for the internal display.
Optimus
There are currently two solutions available under NixOS:
Bumblebee
Unofficial solution.
- Pros:
- works out of the box, just start the game via the primusrun or optirun wrapper
- works under existing X11 server
- Cons:
- some performance penalties, running under wayland decreases performance even more
- things like Vulkan, CUDA and OpenCL are problematic to configure
Use option
hardware.bumblebee.enable = true;
Nvidia PRIME
You need muxless card. Official solution by nvidia.
dynamic mode
Like with Bumblebee, in this mode nvidia card is only turned on by need, other time it stays in power saving mode.
- Pros:
- Has better performance than Bumblebee
- Vulkan, CUDA and OpenCL work, though CUDA needs an additional device creation rule https://github.com/NixOS/nixpkgs/blob/05e375d7103ac51e2da917965c37246c99f1ae4f/nixos/modules/hardware/video/nvidia.nix#L72
- Using a pure wayland setup is supported
- Cons:
- There are still some slight issues noted at the top of script
- Launches new X11 server (and so it's preferable to run the WM/DE alongside the program)
1. Configure NixOS to allow Intel and Nvidia X.Org drivers coexist together (only needed because NixOS forces LD_LIBRARY_PATH variable propagation), and also to disable nvidia card by default.
/etc/nixos/configuration.nix
{
# disable card with bbswitch by default
hardware.nvidiaOptimus.disable = true;
# install nvidia drivers in addition to intel one
hardware.opengl.extraPackages = [ pkgs.linuxPackages.nvidia_x11.out ];
hardware.opengl.extraPackages32 = [ pkgs_i686.linuxPackages.nvidia_x11.out ];
}
2. Download primerun script.
Like with Bumblebee, start the game via primerun.sh.
static mode
In this mode nvidia card is turned on constantly, having impact on laptop battery and health.
- Pros:
- better performance than Bumblebee
- out of box experience
- works under existing X11 server
- Cons:
- nvidia is turned on constantly
- things like Vulkan, CUDA and OpenCL are not tested
- no wayland support
/etc/nixos/configuration.nix
{
services.xserver.videoDrivers = [ "nvidia" ];
hardware.nvidia.optimus_prime.enable = true;
# Bus ID of the NVIDIA GPU. You can find it using lspci
hardware.nvidia.optimus_prime.nvidiaBusId = "PCI:1:0:0";
# Bus ID of the Intel GPU. You can find it using lspci
hardware.nvidia.optimus_prime.intelBusId = "PCI:0:2:0";
}
non-NixOS case
- The nixGL project provides wrapper to use GL drivers outside of NixOS. You need to have nvidia drivers installed on your distro (for kernel modules). Then supply nvidia driver version you use on host system to nixGL.
- Optimus only. Primerun will build nvidia kernel modules against your currently running kernel.