|
343 | 343 | ]; |
344 | 344 |
|
345 | 345 | # Don't add `nvidia-uvm` to `kernelModules`, because we want |
346 | | - # `nvidia-uvm` be loaded only after `udev` rules for `nvidia` kernel |
347 | | - # module are applied. |
| 346 | + # `nvidia-uvm` be loaded only after the GPU device is available, i.e. after `udev` rules |
| 347 | + # for `nvidia` kernel module are applied. |
| 348 | + # This matters on Azure GPU instances: https://github.com/NixOS/nixpkgs/pull/267335 |
348 | 349 | # |
349 | 350 | # Instead, we use `softdep` to lazily load `nvidia-uvm` kernel module |
350 | 351 | # after `nvidia` kernel module is loaded and `udev` rules are applied. |
351 | 352 | extraModprobeConfig = '' |
352 | 353 | softdep nvidia post: nvidia-uvm |
353 | 354 | ''; |
| 355 | + |
| 356 | + # Exception is the open-source kernel module failing to load nvidia-uvm using softdep |
| 357 | + # for unknown reasons. |
| 358 | + # It affects CUDA: https://github.com/NixOS/nixpkgs/issues/334180 |
| 359 | + # Previously nvidia-uvm was explicitly loaded only when xserver was enabled: |
| 360 | + # https://github.com/NixOS/nixpkgs/pull/334340/commits/4548c392862115359e50860bcf658cfa8715bde9 |
| 361 | + # We are now loading the module eagerly for all users of the open driver (including headless). |
| 362 | + kernelModules = lib.optionals useOpenModules [ "nvidia_uvm" ]; |
354 | 363 | }; |
355 | 364 | systemd.tmpfiles.rules = lib.mkIf config.virtualisation.docker.enableNvidia [ |
356 | 365 | "L+ /run/nvidia-docker/bin - - - - ${nvidia_x11.bin}/origBin" |
|
639 | 648 | boot = { |
640 | 649 | extraModulePackages = if useOpenModules then [ nvidia_x11.open ] else [ nvidia_x11.bin ]; |
641 | 650 | # nvidia-uvm is required by CUDA applications. |
642 | | - kernelModules = |
643 | | - lib.optionals config.services.xserver.enable [ |
644 | | - "nvidia" |
645 | | - "nvidia_modeset" |
646 | | - "nvidia_drm" |
647 | | - ] |
648 | | - # With the open driver, nvidia-uvm does not automatically load as |
649 | | - # a softdep of the nvidia module, so we explicitly load it for now. |
650 | | - # See https://github.com/NixOS/nixpkgs/issues/334180 |
651 | | - ++ lib.optionals (config.services.xserver.enable && useOpenModules) [ "nvidia_uvm" ]; |
| 651 | + kernelModules = lib.optionals config.services.xserver.enable [ |
| 652 | + "nvidia" |
| 653 | + "nvidia_modeset" |
| 654 | + "nvidia_drm" |
| 655 | + ]; |
652 | 656 |
|
653 | 657 | # If requested enable modesetting via kernel parameters. |
654 | 658 | kernelParams = |
|
0 commit comments