Nvidia: Difference between revisions

From NixOS Wiki
imported>Vodkabot2
mNo edit summary
imported>Vodkabot2
No edit summary
Line 21: Line 21:




* Pros: out of box experience, just start the game via ''primusrun'' or ''optirun'' wrapper, works under existing X11 server
* Pros:  
** out of box experience, just start the game via ''primusrun'' or ''optirun'' wrapper
** works under existing X11 server


* Cons: some performance penalty, no Vulkan support, things like CUDA and OpenCL are problematic to configure
* Cons:  
** some performance penalty
** Things like Vulkan, CUDA and OpenCL are problematic to configure


=== Nvidia PRIME ===
=== Nvidia PRIME ===
Line 44: Line 48:
Like with Bumblebee, start the game via ''primerun.sh''.  
Like with Bumblebee, start the game via ''primerun.sh''.  


* Pros: better performance, Vulkan is supported. CUDA and OpenCL should work, though CUDA needs an additional device creation rule https://github.com/NixOS/nixpkgs/blob/05e375d7103ac51e2da917965c37246c99f1ae4f/nixos/modules/hardware/video/nvidia.nix#L72
* Pros:  
** better performance
** 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


* Cons: there are still some rough edges noted on the top of script, but otherwise it works fine for me, starts new X11 server
* Cons:
** there are still some rough edges noted on the top of script
** launches new X11 server


== non-NixOS case ==
== non-NixOS case ==

Revision as of 02:21, 2 October 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 BIOS option to select which card to use for internal display.

Optimus

There are currently two solutions available under NixOS:

Bumblebee

Unofficial solution.

Use

hardware.bumblebee.enable = true;

option.


  • Pros:
    • out of box experience, just start the game via primusrun or optirun wrapper
    • works under existing X11 server
  • Cons:
    • some performance penalty
    • Things like Vulkan, CUDA and OpenCL are problematic to configure

Nvidia PRIME

You need muxless card. Official solution by nvidia.

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.

  • Cons:
    • there are still some rough edges noted on the top of script
    • launches new X11 server

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.