NVK error when using prop nvidia drivers

I am using the proprietary nvidia driver with this config:

services.xserver.videoDrivers = ["nvidia"];
boot.kernelParams = [ "nvidia.NVreg_PreserveVideoMemoryAllocations=1" ];
hardware.nvidia = {
  modesetting.enable = true;
  powerManagement.enable = true;
  powerManagement.finegrained = false;
  open = false;
  nvidiaSettings = false;
  package = config.boot.kernelPackages.nvidiaPackages.beta;
};

In some applications (some electron apps under wayland, rio terminal and some more native wayland apps) I get errors, all including DRM kernel driver 'nvidia-drm' in use. NVK requires nouveau.. My understanding is that I am not using the nouveau kernel drivers nor NVK. Why am I getting an error from some mesa nouveau device code?

error printed by src/nouveau/winsys/nouveau_device.c · main · Mesa / mesa · GitLab

618693:0412/223607.303310:ERROR:browser_main_loop.cc(275)] Gtk: gtk_widget_get_scale_factor: assertion 'GTK_IS_WIDGET (widget)' failed
DRM kernel driver 'nvidia-drm' in use. NVK requires nouveau.
libEGL warning: egl: failed to create dri2 screen
DRM kernel driver 'nvidia-drm' in use. NVK requires nouveau.
[618746:0412/223607.632139:ERROR:gbm_wrapper.cc(253)] Failed to export buffer to dma_buf: No such file or directory (2)
[618746:0412/223607.632271:ERROR:gbm_pixmap_wayland.cc(82)] Cannot create bo with format= RGBA_8888 and usage=SCANOUT
[618746:0412/223607.632439:ERROR:gbm_wrapper.cc(253)] Failed to export buffer to dma_buf: No such file or directory (2)
[618746:0412/223607.632497:ERROR:gbm_pixmap_wayland.cc(82)] Cannot create bo with format= RGBA_8888 and usage=GPU_READ
[618746:0412/223607.632556:ERROR:shared_image_factory.cc(926)] CreateSharedImage: could not create backing.
[618746:0412/223607.632610:ERROR:shared_image_factory.cc(758)] DestroySharedImage: Could not find shared image mailbox
[618746:0412/223607.632716:ERROR:gpu_service_impl.cc(1089)] Exiting GPU process because some drivers can't recover from errors. GPU process will restart shortly.
[618763:0412/223607.642137:ERROR:command_buffer_proxy_impl.cc(127)] ContextResult::kTransientFailure: Failed to send GpuControl.CreateCommandBuffer.
[618693:0412/223607.657802:ERROR:gpu_process_host.cc(991)] GPU process exited unexpectedly: exit_code=8704
DRM kernel driver 'nvidia-drm' in use. NVK requires nouveau.
libEGL warning: egl: failed to create dri2 screen

Config change removed the line DRM kernel driver 'nvidia-drm' in use. NVK requires nouveau. other errors still exist. I have now set hardware.opengl.package to config.boot.kernelPackages.nvidiaPackages.beta fore some reason it defaulted to pkgs.mesa.driver even thought I am running the proprietary nvidia drivers.

My config now:

{ config, ... }:

let
  driverPkg = config.boot.kernelPackages.nvidiaPackages.beta;
in
{
  services.xserver.videoDrivers = ["nvidia"];
  boot.kernelParams = [ "nvidia.NVreg_PreserveVideoMemoryAllocations=1" ];
  hardware.nvidia = {
    modesetting.enable = true;
    powerManagement.enable = true;
    powerManagement.finegrained = false;
    open = false;
    nvidiaSettings = false;
    package = driverPkg;
  };
  hardware.opengl = {
    enable = true;
    driSupport = false;
    package = driverPkg;
  };
  nixpkgs.config.allowUnfree = true;
  nixpkgs.config.nvidia.acceptLicense = true;
}

Am I expected to manually set hardware.opengl.package, I thought the nvidia hardware module should take care of that.

I think that message just means the ICD loader tried the NVK driver before trying the proprietary driver, and it’s safe to ignore. To actually silence it, you can set the environment variable VK_DRIVER_FILES. I have this in my NixOS config:

  environment.sessionVariables.VK_DRIVER_FILES = "/run/opengl-driver/share/vulkan/icd.d/nvidia_icd.x86_64.json";

If you also have integrated graphics (such as on a laptop), you will want to set that to a colon-separated list of all the driver files for your GPUs, otherwise Vulkan will never work on your other GPU(s).

3 Likes