nixos/nvidia: fix CUDA for open driver

For the open driver, the `nvidia-uvm` module does not auto-load after
`nvidia`, which makes CUDA not work.

In this case, we need to add it to `boot.kernelModules` for it to work
again.
This commit is contained in:
eljamm 2024-08-13 10:14:54 +01:00
parent 4877ea239f
commit 4548c39286
No known key found for this signature in database
GPG Key ID: 7630FDF7C8FB1F3F

View File

@ -572,11 +572,16 @@ in
boot = {
extraModulePackages = if cfg.open then [ nvidia_x11.open ] else [ nvidia_x11.bin ];
# nvidia-uvm is required by CUDA applications.
kernelModules = lib.optionals config.services.xserver.enable [
"nvidia"
"nvidia_modeset"
"nvidia_drm"
];
kernelModules =
lib.optionals config.services.xserver.enable [
"nvidia"
"nvidia_modeset"
"nvidia_drm"
]
# With the open driver, nvidia-uvm does not automatically load as
# a softdep of the nvidia module, so we explicitly load it for now.
# See https://github.com/NixOS/nixpkgs/issues/334180
++ lib.optionals (config.services.xserver.enable && cfg.open) [ "nvidia_uvm" ];
# If requested enable modesetting via kernel parameters.
kernelParams =