Vulkan not working with Nvidia drivers

I’m trying to get steam games to work, with no luck, so I started looking around, I found out that vulkan isn’t working correctly.

I have a laptop with nvidia offload

nixos config

when I run
nix-shell -p vulkan-tools --run "vkcube"

I get

Selected GPU 1: NVIDIA GeForce RTX 3050 Laptop GPU, type: DiscreteGpu
Can't find our preferred formats... Falling back to first exposed format. Rendering may be incorrect.
/tmp/nix-shell-13842-0/rc: line 3: 15875 Segmentation fault      (core dumped) vkcube

I don’t know if this is why my steam games don’t work, but I figured I should fix this anyways.

The steam games I tried were animal well and spelunky, both with nvidia-offload and without, on kde wayland and x11. These both worked on the same laptop on PopOs.

1 Like

Try nvidia-offload nix-shell -p vulkan-tools --run "vkcube"

─λ nvidia-offload nix-shell -p vulkan-tools --run "vkcube"
Selected GPU 0: NVIDIA GeForce RTX 3050 Laptop GPU, type: DiscreteGpu
Can't find our preferred formats... Falling back to first exposed format. Rendering may be incorrect.
/tmp/nix-shell-38370-0/rc: line 3: 40405 Segmentation fault      (core dumped) vkcube

You can see here that vkcube will terminate (fail an assertion) if there are no surface formats.

run vulkaninfo | less and look under the “Presentable Surfaces” section to see if there are any surface formats. For example, mine looks like this:

Presentable Surfaces:
=====================
GPU id : 0 (NVIDIA GeForce GTX 1650):
        Surface types: count = 2
                VK_KHR_xcb_surface
                VK_KHR_xlib_surface
        Formats: count = 2
                SurfaceFormat[0]:
                        format = FORMAT_B8G8R8A8_UNORM
                        colorSpace = COLOR_SPACE_SRGB_NONLINEAR_
KHR
                SurfaceFormat[1]:
                        format = FORMAT_B8G8R8A8_SRGB
                        colorSpace = COLOR_SPACE_SRGB_NONLINEAR_
KHR

nvidia-offload nix-shell -p vulkan-tools --run "vulkaninfo | nvim"

Presentable Surfaces:
=====================
GPU id : 1 (Intel(R) Graphics (RPL-P)):
	Surface types: count = 2
		VK_KHR_xcb_surface
		VK_KHR_xlib_surface
	Formats: count = 2
		SurfaceFormat[0]:
			format = FORMAT_B8G8R8A8_SRGB
			colorSpace = COLOR_SPACE_SRGB_NONLINEAR_KHR
		SurfaceFormat[1]:
			format = FORMAT_B8G8R8A8_UNORM
			colorSpace = COLOR_SPACE_SRGB_NONLINEAR_KHR
	Present Modes: count = 4
		PRESENT_MODE_IMMEDIATE_KHR
		PRESENT_MODE_MAILBOX_KHR
		PRESENT_MODE_FIFO_KHR
		PRESENT_MODE_FIFO_RELAXED_KHR
	VkSurfaceCapabilitiesKHR:
	-------------------------
		minImageCount = 3
		maxImageCount = 0
		currentExtent:
			width  = 256
			height = 256
		minImageExtent:
			width  = 256
			height = 256
		maxImageExtent:
			width  = 256
			height = 256
		maxImageArrayLayers = 1
		supportedTransforms: count = 1
			SURFACE_TRANSFORM_IDENTITY_BIT_KHR
		currentTransform = SURFACE_TRANSFORM_IDENTITY_BIT_KHR
		supportedCompositeAlpha: count = 2
			COMPOSITE_ALPHA_OPAQUE_BIT_KHR
			COMPOSITE_ALPHA_INHERIT_BIT_KHR
		supportedUsageFlags: count = 6
			IMAGE_USAGE_TRANSFER_SRC_BIT
			IMAGE_USAGE_TRANSFER_DST_BIT
			IMAGE_USAGE_SAMPLED_BIT
			IMAGE_USAGE_STORAGE_BIT
			IMAGE_USAGE_COLOR_ATTACHMENT_BIT
			IMAGE_USAGE_INPUT_ATTACHMENT_BIT
	VkSurfaceProtectedCapabilitiesKHR:
	----------------------------------
		supportsProtected = false

	VK_EXT_surface_maintenance1:
	----------------------------
		PRESENT_MODE_IMMEDIATE_KHR:
			minImageCount = 5
			maxImageCount = 0
			VkSurfacePresentScalingCapabilitiesEXT:
				supportedPresentScaling:
					None
				supportedPresentGravityX:
					None
				supportedPresentGravityY:
					None
				minScaledImageExtent:
					width  = 256
					height = 256
				maxScaledImageExtent:
					width  = 256
					height = 256
			VkSurfacePresentModeCompatibilityEXT:
				presentModeCount                = 1
				pPresentModes: count = 1
					PRESENT_MODE_IMMEDIATE_KHR
		PRESENT_MODE_MAILBOX_KHR:
			minImageCount = 5
			maxImageCount = 0
			VkSurfacePresentScalingCapabilitiesEXT:
				supportedPresentScaling:
					None
				supportedPresentGravityX:
					None
				supportedPresentGravityY:
					None
				minScaledImageExtent:
					width  = 256
					height = 256
				maxScaledImageExtent:
					width  = 256
					height = 256
			VkSurfacePresentModeCompatibilityEXT:
				presentModeCount                = 1
				pPresentModes: count = 1
					PRESENT_MODE_MAILBOX_KHR
		PRESENT_MODE_FIFO_KHR:
			minImageCount = 3
			maxImageCount = 0
			VkSurfacePresentScalingCapabilitiesEXT:
				supportedPresentScaling:
					None
				supportedPresentGravityX:
					None
				supportedPresentGravityY:
					None
				minScaledImageExtent:
					width  = 256
					height = 256
				maxScaledImageExtent:
					width  = 256
					height = 256
			VkSurfacePresentModeCompatibilityEXT:
				presentModeCount                = 1
				pPresentModes: count = 1
					PRESENT_MODE_FIFO_KHR
		PRESENT_MODE_FIFO_RELAXED_KHR:
			minImageCount = 3
			maxImageCount = 0
			VkSurfacePresentScalingCapabilitiesEXT:
				supportedPresentScaling:
					None
				supportedPresentGravityX:
					None
				supportedPresentGravityY:
					None
				minScaledImageExtent:
					width  = 256
					height = 256
				maxScaledImageExtent:
					width  = 256
					height = 256
			VkSurfacePresentModeCompatibilityEXT:
				presentModeCount                = 1
				pPresentModes: count = 1
					PRESENT_MODE_FIFO_RELAXED_KHR

GPU id : 2 (llvmpipe (LLVM 17.0.6, 256 bits)):
	Surface types: count = 2
		VK_KHR_xcb_surface
		VK_KHR_xlib_surface
	Formats: count = 2
		SurfaceFormat[0]:
			format = FORMAT_B8G8R8A8_SRGB
			colorSpace = COLOR_SPACE_SRGB_NONLINEAR_KHR
		SurfaceFormat[1]:
			format = FORMAT_B8G8R8A8_UNORM
			colorSpace = COLOR_SPACE_SRGB_NONLINEAR_KHR
	Present Modes: count = 4
		PRESENT_MODE_IMMEDIATE_KHR
		PRESENT_MODE_MAILBOX_KHR
		PRESENT_MODE_FIFO_KHR
		PRESENT_MODE_FIFO_RELAXED_KHR
	VkSurfaceCapabilitiesKHR:
	-------------------------
		minImageCount = 3
		maxImageCount = 0
		currentExtent:
			width  = 256
			height = 256
		minImageExtent:
			width  = 256
			height = 256
		maxImageExtent:
			width  = 256
			height = 256
		maxImageArrayLayers = 1
		supportedTransforms: count = 1
			SURFACE_TRANSFORM_IDENTITY_BIT_KHR
		currentTransform = SURFACE_TRANSFORM_IDENTITY_BIT_KHR
		supportedCompositeAlpha: count = 2
			COMPOSITE_ALPHA_OPAQUE_BIT_KHR
			COMPOSITE_ALPHA_INHERIT_BIT_KHR
		supportedUsageFlags: count = 7
			IMAGE_USAGE_TRANSFER_SRC_BIT
			IMAGE_USAGE_TRANSFER_DST_BIT
			IMAGE_USAGE_SAMPLED_BIT
			IMAGE_USAGE_STORAGE_BIT
			IMAGE_USAGE_COLOR_ATTACHMENT_BIT
			IMAGE_USAGE_INPUT_ATTACHMENT_BIT
			IMAGE_USAGE_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT
	VkSurfaceProtectedCapabilitiesKHR:
	----------------------------------
		supportsProtected = false

	VK_EXT_surface_maintenance1:
	----------------------------
		PRESENT_MODE_IMMEDIATE_KHR:
			minImageCount = 3
			maxImageCount = 0
			VkSurfacePresentScalingCapabilitiesEXT:
				supportedPresentScaling:
					None
				supportedPresentGravityX:
					None
				supportedPresentGravityY:
					None
				minScaledImageExtent:
					width  = 256
					height = 256
				maxScaledImageExtent:
					width  = 256
					height = 256
			VkSurfacePresentModeCompatibilityEXT:
				presentModeCount                = 1
				pPresentModes: count = 1
					PRESENT_MODE_IMMEDIATE_KHR
		PRESENT_MODE_MAILBOX_KHR:
			minImageCount = 3
			maxImageCount = 0
			VkSurfacePresentScalingCapabilitiesEXT:
				supportedPresentScaling:
					None
				supportedPresentGravityX:
					None
				supportedPresentGravityY:
					None
				minScaledImageExtent:
					width  = 256
					height = 256
				maxScaledImageExtent:
					width  = 256
					height = 256
			VkSurfacePresentModeCompatibilityEXT:
				presentModeCount                = 1
				pPresentModes: count = 1
					PRESENT_MODE_MAILBOX_KHR
		PRESENT_MODE_FIFO_KHR:
			minImageCount = 3
			maxImageCount = 0
			VkSurfacePresentScalingCapabilitiesEXT:
				supportedPresentScaling:
					None
				supportedPresentGravityX:
					None
				supportedPresentGravityY:
					None
				minScaledImageExtent:
					width  = 256
					height = 256
				maxScaledImageExtent:
					width  = 256
					height = 256
			VkSurfacePresentModeCompatibilityEXT:
				presentModeCount                = 1
				pPresentModes: count = 1
					PRESENT_MODE_FIFO_KHR
		PRESENT_MODE_FIFO_RELAXED_KHR:
			minImageCount = 3
			maxImageCount = 0
			VkSurfacePresentScalingCapabilitiesEXT:
				supportedPresentScaling:
					None
				supportedPresentGravityX:
					None
				supportedPresentGravityY:
					None
				minScaledImageExtent:
					width  = 256
					height = 256
				maxScaledImageExtent:
					width  = 256
					height = 256
			VkSurfacePresentModeCompatibilityEXT:
				presentModeCount                = 1
				pPresentModes: count = 1
					PRESENT_MODE_FIFO_RELAXED_KHR

GPU id : 1 (Intel(R) Graphics (RPL-P)):
	Surface type = VK_KHR_wayland_surface
	Formats: count = 8
		SurfaceFormat[0]:
			format = FORMAT_A2R10G10B10_UNORM_PACK32
			colorSpace = COLOR_SPACE_SRGB_NONLINEAR_KHR
		SurfaceFormat[1]:
			format = FORMAT_B8G8R8A8_SRGB
			colorSpace = COLOR_SPACE_SRGB_NONLINEAR_KHR
		SurfaceFormat[2]:
			format = FORMAT_B8G8R8A8_UNORM
			colorSpace = COLOR_SPACE_SRGB_NONLINEAR_KHR
		SurfaceFormat[3]:
			format = FORMAT_R8G8B8A8_SRGB
			colorSpace = COLOR_SPACE_SRGB_NONLINEAR_KHR
		SurfaceFormat[4]:
			format = FORMAT_R8G8B8A8_UNORM
			colorSpace = COLOR_SPACE_SRGB_NONLINEAR_KHR
		SurfaceFormat[5]:
			format = FORMAT_R16G16B16A16_UNORM
			colorSpace = COLOR_SPACE_SRGB_NONLINEAR_KHR
		SurfaceFormat[6]:
			format = FORMAT_R16G16B16A16_SFLOAT
			colorSpace = COLOR_SPACE_SRGB_NONLINEAR_KHR
		SurfaceFormat[7]:
			format = FORMAT_R5G6B5_UNORM_PACK16
			colorSpace = COLOR_SPACE_SRGB_NONLINEAR_KHR
	Present Modes: count = 3
		PRESENT_MODE_MAILBOX_KHR
		PRESENT_MODE_FIFO_KHR
		PRESENT_MODE_IMMEDIATE_KHR
	VkSurfaceCapabilitiesKHR:
	-------------------------
		minImageCount = 4
		maxImageCount = 0
		currentExtent:
			width  = 4294967295
			height = 4294967295
		minImageExtent:
			width  = 1
			height = 1
		maxImageExtent:
			width  = 16384
			height = 16384
		maxImageArrayLayers = 1
		supportedTransforms: count = 1
			SURFACE_TRANSFORM_IDENTITY_BIT_KHR
		currentTransform = SURFACE_TRANSFORM_IDENTITY_BIT_KHR
		supportedCompositeAlpha: count = 2
			COMPOSITE_ALPHA_OPAQUE_BIT_KHR
			COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR
		supportedUsageFlags: count = 6
			IMAGE_USAGE_TRANSFER_SRC_BIT
			IMAGE_USAGE_TRANSFER_DST_BIT
			IMAGE_USAGE_SAMPLED_BIT
			IMAGE_USAGE_STORAGE_BIT
			IMAGE_USAGE_COLOR_ATTACHMENT_BIT
			IMAGE_USAGE_INPUT_ATTACHMENT_BIT
	VkSurfaceProtectedCapabilitiesKHR:
	----------------------------------
		supportsProtected = false

	VK_EXT_surface_maintenance1:
	----------------------------
		PRESENT_MODE_MAILBOX_KHR:
			minImageCount = 4
			maxImageCount = 0
			VkSurfacePresentScalingCapabilitiesEXT:
				supportedPresentScaling:
					None
				supportedPresentGravityX:
					None
				supportedPresentGravityY:
					None
				minScaledImageExtent:
					width  = 1
					height = 1
				maxScaledImageExtent:
					width  = 16384
					height = 16384
			VkSurfacePresentModeCompatibilityEXT:
				presentModeCount                = 2
				pPresentModes: count = 2
					PRESENT_MODE_MAILBOX_KHR
					PRESENT_MODE_FIFO_KHR
		PRESENT_MODE_FIFO_KHR:
			minImageCount = 2
			maxImageCount = 0
			VkSurfacePresentScalingCapabilitiesEXT:
				supportedPresentScaling:
					None
				supportedPresentGravityX:
					None
				supportedPresentGravityY:
					None
				minScaledImageExtent:
					width  = 1
					height = 1
				maxScaledImageExtent:
					width  = 16384
					height = 16384
			VkSurfacePresentModeCompatibilityEXT:
				presentModeCount                = 2
				pPresentModes: count = 2
					PRESENT_MODE_FIFO_KHR
					PRESENT_MODE_MAILBOX_KHR
		PRESENT_MODE_IMMEDIATE_KHR:
			minImageCount = 4
			maxImageCount = 0
			VkSurfacePresentScalingCapabilitiesEXT:
				supportedPresentScaling:
					None
				supportedPresentGravityX:
					None
				supportedPresentGravityY:
					None
				minScaledImageExtent:
					width  = 1
					height = 1
				maxScaledImageExtent:
					width  = 16384
					height = 16384
			VkSurfacePresentModeCompatibilityEXT:
				presentModeCount                = 1
				pPresentModes: count = 1
					PRESENT_MODE_IMMEDIATE_KHR

GPU id : 2 (llvmpipe (LLVM 17.0.6, 256 bits)):
	Surface type = VK_KHR_wayland_surface
	Formats: count = 5
		SurfaceFormat[0]:
			format = FORMAT_B8G8R8A8_SRGB
			colorSpace = COLOR_SPACE_SRGB_NONLINEAR_KHR
		SurfaceFormat[1]:
			format = FORMAT_B8G8R8A8_UNORM
			colorSpace = COLOR_SPACE_SRGB_NONLINEAR_KHR
		SurfaceFormat[2]:
			format = FORMAT_A2R10G10B10_UNORM_PACK32
			colorSpace = COLOR_SPACE_SRGB_NONLINEAR_KHR
		SurfaceFormat[3]:
			format = FORMAT_A2B10G10R10_UNORM_PACK32
			colorSpace = COLOR_SPACE_SRGB_NONLINEAR_KHR
		SurfaceFormat[4]:
			format = FORMAT_R16G16B16A16_UNORM
			colorSpace = COLOR_SPACE_SRGB_NONLINEAR_KHR
	Present Modes: count = 3
		PRESENT_MODE_MAILBOX_KHR
		PRESENT_MODE_FIFO_KHR
		PRESENT_MODE_IMMEDIATE_KHR
	VkSurfaceCapabilitiesKHR:
	-------------------------
		minImageCount = 4
		maxImageCount = 0
		currentExtent:
			width  = 4294967295
			height = 4294967295
		minImageExtent:
			width  = 1
			height = 1
		maxImageExtent:
			width  = 16384
			height = 16384
		maxImageArrayLayers = 1
		supportedTransforms: count = 1
			SURFACE_TRANSFORM_IDENTITY_BIT_KHR
		currentTransform = SURFACE_TRANSFORM_IDENTITY_BIT_KHR
		supportedCompositeAlpha: count = 2
			COMPOSITE_ALPHA_OPAQUE_BIT_KHR
			COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR
		supportedUsageFlags: count = 7
			IMAGE_USAGE_TRANSFER_SRC_BIT
			IMAGE_USAGE_TRANSFER_DST_BIT
			IMAGE_USAGE_SAMPLED_BIT
			IMAGE_USAGE_STORAGE_BIT
			IMAGE_USAGE_COLOR_ATTACHMENT_BIT
			IMAGE_USAGE_INPUT_ATTACHMENT_BIT
			IMAGE_USAGE_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT
	VkSurfaceProtectedCapabilitiesKHR:
	----------------------------------
		supportsProtected = false

	VK_EXT_surface_maintenance1:
	----------------------------
		PRESENT_MODE_MAILBOX_KHR:
			minImageCount = 4
			maxImageCount = 0
			VkSurfacePresentScalingCapabilitiesEXT:
				supportedPresentScaling:
					None
				supportedPresentGravityX:
					None
				supportedPresentGravityY:
					None
				minScaledImageExtent:
					width  = 1
					height = 1
				maxScaledImageExtent:
					width  = 16384
					height = 16384
			VkSurfacePresentModeCompatibilityEXT:
				presentModeCount                = 2
				pPresentModes: count = 2
					PRESENT_MODE_MAILBOX_KHR
					PRESENT_MODE_FIFO_KHR
		PRESENT_MODE_FIFO_KHR:
			minImageCount = 2
			maxImageCount = 0
			VkSurfacePresentScalingCapabilitiesEXT:
				supportedPresentScaling:
					None
				supportedPresentGravityX:
					None
				supportedPresentGravityY:
					None
				minScaledImageExtent:
					width  = 1
					height = 1
				maxScaledImageExtent:
					width  = 16384
					height = 16384
			VkSurfacePresentModeCompatibilityEXT:
				presentModeCount                = 2
				pPresentModes: count = 2
					PRESENT_MODE_FIFO_KHR
					PRESENT_MODE_MAILBOX_KHR
		PRESENT_MODE_IMMEDIATE_KHR:
			minImageCount = 4
			maxImageCount = 0
			VkSurfacePresentScalingCapabilitiesEXT:
				supportedPresentScaling:
					None
				supportedPresentGravityX:
					None
				supportedPresentGravityY:
					None
				minScaledImageExtent:
					width  = 1
					height = 1
				maxScaledImageExtent:
					width  = 16384
					height = 16384
			VkSurfacePresentModeCompatibilityEXT:
				presentModeCount                = 1
				pPresentModes: count = 1
					PRESENT_MODE_IMMEDIATE_KHR

You should double-check that you have the correct nvidiaBusId.

What’s the bus info that the sudo lshw -c display command give you?

  *-display                 
       description: i915drmfb
       physical id: 0
       bus info: pci@0000:01:00.0
       logical name: /dev/fb0
       version: a1
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress bus_master cap_list rom fb
       configuration: depth=32 driver=nvidia latency=0 mode=1920x1080 visual=truecolor xres=1920 yres=1080
       resources: iomemory:90-8f iomemory:a0-9f irq:16 memory:81000000-81ffffff memory:900000000-9ffffffff memory:a00000000-a01ffffff ioport:2000(size=128) memory:82000000-8207ffff
  *-display
       product: i915drmfb
       physical id: 2
       bus info: pci@0000:00:02.0
       logical name: /dev/fb0
       version: 04
       width: 64 bits
       clock: 33MHz
       capabilities: pciexpress msi pm bus_master cap_list rom fb
       configuration: depth=32 driver=i915 latency=0 resolution=1920,1080
       resources: irq:178 memory:83000000-83ffffff memory:90000000-9fffffff ioport:1000(size=64) memory:c0000-dffff memory:880000000-886ffffff memory:a20000000-affffffff

nvidia.nix

    package = config.boot.kernelPackages.nvidiaPackages.stable;
    prime = {
      intelBusId = "PCI:0:2:0";
      nvidiaBusId = "PCI:1:0:0";
      offload = {
        enable = true;
        enableOffloadCmd = true;
      };
    };

That seems correct. Does it work when you manually specify the driver?

$ nix-shell -p vulkan-tools --run "VK_DRIVER_FILES='/run/opengl-driver/share/vulkan/icd.d/nvidia_icd.x86_64.json' vkcube"
Selected GPU 0: NVIDIA GeForce RTX 3050 Laptop GPU, type: DiscreteGpu
Can't find our preferred formats... Falling back to first exposed format. Rendering may be incorrect.
/tmp/nix-shell-136247-0/rc: line 3: 138279 Segmentation fault      (core dumped) VK_DRIVER_FILES='/run/opengl-driver/share/vulkan/icd.d/nvidia_icd.x86_64.json' vkcube

This might be caused by something in your /etc/nixos/hardware-configuration.nix, but this file isn’t tracked in your config, so it’s hard to tell.

Also, is the "ibt=off" parameter still needed for new drivers?

hardware-configuration.nix

# Do not modify this file!  It was generated by ‘nixos-generate-config’
# and may be overwritten by future invocations.  Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:

{
  imports =
    [ (modulesPath + "/installer/scan/not-detected.nix")
    ];

  boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "sd_mod" "sdhci_pci" ];
  boot.initrd.kernelModules = [ ];
  boot.kernelModules = [ "kvm-intel" ];
  boot.extraModulePackages = [ ];

  fileSystems."/" =
    { device = "/dev/disk/by-uuid/70fe4fe7-afd4-41c0-b0cc-3874131f1520";
      fsType = "ext4";
    };

  fileSystems."/boot" =
    { device = "/dev/disk/by-uuid/AEE4-2C6B";
      fsType = "vfat";
      options = [ "fmask=0022" "dmask=0022" ];
    };

  swapDevices = [ ];

  # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
  # (the default) this is the recommended approach. When using systemd-networkd it's
  # still possible to use this option, but it's recommended to use it in conjunction
  # with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
  networking.useDHCP = lib.mkDefault true;
  # networking.interfaces.eno0.useDHCP = lib.mkDefault true;
  # networking.interfaces.wlp0s20f3.useDHCP = lib.mkDefault true;

  nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
  hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

You’re right about ibt=off, I couldn’t get the drivers to work so I added a couple lines and when it worked I didn’t touch it or ask questions, I removed it, but that didn’t affect the vulkan test. I’m still getting:

nvidia-offload nix-shell -p vulkan-tools --run "vkcube"
Selected GPU 0: NVIDIA GeForce RTX 3050 Laptop GPU, type: DiscreteGpu
Can't find our preferred formats... Falling back to first exposed format. Rendering may be incorrect.
/tmp/nix-shell-6557-0/rc: line 3:  8590 Segmentation fault      (core dumped) vkcube

Nothing looks odd to me, to be honest. If I were you I’d try the beta drivers as those might have the latest fixes.

I tried changing the package to beta, but it’s not building

─λ sudo nixos-rebuild boot --impure --flake ~/nixos#aster-nixos
warning: Git tree '/home/matteob/nixos' is dirty
building the system configuration...
warning: Git tree '/home/matteob/nixos' is dirty
error: builder for '/nix/store/gj1k60p6l8xd58n0dy4mdfh0a5hlkb5m-linux-6.6.32-modules.drv' failed with exit code 255;
       last 1 log lines:
       > error: collision between `/nix/store/8ll0hlk80rjqg5s4p11h1s4adcnlvczf-nvidia-x11-555.52.04-6.6.32-bin/lib/modules/6.6.32/misc/nvidia-peermem.ko' and `/nix/store/z3dx24dqrc0nxvipypjbwxsywr6756ym-nvidia-x11-550.90.07-6.6.32-bin/lib/modules/6.6.32/misc/nvidia-peermem.ko'
       For full logs, run 'nix log /nix/store/gj1k60p6l8xd58n0dy4mdfh0a5hlkb5m-linux-6.6.32-modules.drv'.
error (ignored): error: cannot unlink '/tmp/nix-build-nvidia-settings-555.52.04.drv-1': Directory not empty
error: 1 dependencies of derivation '/nix/store/8iqkllbdjjb8mwh8l46kg2d0bynffkw8-nixos-system-aster-nixos-24.11.20240612.57d6973.drv' failed to build

I think it’s because this line pulls in the stable driver, which conflicts with the beta one:

  boot.extraModulePackages = [ config.boot.kernelPackages.nvidia_x11 ];

I don’t know why you need this in the first place as the driver should load fine without it. Could you remove it and try again?

Also, if you want to make sure that the driver has loaded correctly, you can run:

$ lspci -nnk | grep -A2 -e VGA

Yep, I removed it and it built with the beta drivers.

The issue is still there, sadly.

─λ nvidia-smi
Sat Jun 15 06:10:59 2024       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 555.52.04              Driver Version: 555.52.04      CUDA Version: 12.5     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce RTX 3050 ...    Off |   00000000:01:00.0 Off |                  N/A |
| N/A   34C    P3             12W /   30W |       1MiB /   4096MiB |     14%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
                                                                                         
+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+
─λ nvidia-offload nix-shell -p vulkan-tools --run "vkcube"
this path will be fetched (0.32 MiB download, 2.02 MiB unpacked):
  /nix/store/2771g43xk36d0qsdif7mvxvnwshv7cmz-vulkan-tools-1.3.283.0
copying path '/nix/store/2771g43xk36d0qsdif7mvxvnwshv7cmz-vulkan-tools-1.3.283.0' from 'https://cache.nixos.org'...
Selected GPU 0: NVIDIA GeForce RTX 3050 Laptop GPU, type: DiscreteGpu
/tmp/nix-shell-2311-0/rc: line 3:  4353 Segmentation fault      (core dumped) vkcube

back on stable nvidia drivers, I ran vulkaninfo --summary and got some warnings

WARNING: [Loader Message] Code 0 : terminator_CreateInstance: Received return code -3 from call to vkCreateInstance in ICD /nix/store/hggpnywm6l7cfh2ml1ynm50ap9x4f9rn-mesa-24.0.7-drivers/lib/libvulkan_dzn.so. Skipping this driver.
WARNING: [Loader Message] Code 0 : terminator_CreateInstance: Received return code -3 from call to vkCreateInstance in ICD /nix/store/hggpnywm6l7cfh2ml1ynm50ap9x4f9rn-mesa-24.0.7-drivers/lib/libvulkan_virtio.so. Skipping this driver.
ERROR while creating surface for extension VK_KHR_xcb_surface : /build/source/vulkaninfo/./vulkaninfo.h:245:vkGetPhysicalDeviceSurfacePresentModesKHR failed with ERROR_UNKNOWN
ERROR while creating surface for extension VK_KHR_xlib_surface : /build/source/vulkaninfo/./vulkaninfo.h:245:vkGetPhysicalDeviceSurfacePresentModesKHR failed with ERROR_UNKNOWN
ERROR while creating surface for extension VK_KHR_wayland_surface : /build/source/vulkaninfo/./vulkaninfo.h:245:vkGetPhysicalDeviceSurfacePresentModesKHR failed with ERROR_UNKNOWN
==========
VULKANINFO
==========

Vulkan Instance Version: 1.3.283


Instance Extensions: count = 23
-------------------------------
VK_EXT_acquire_drm_display             : extension revision 1
VK_EXT_acquire_xlib_display            : extension revision 1
VK_EXT_debug_report                    : extension revision 10
VK_EXT_debug_utils                     : extension revision 2
VK_EXT_direct_mode_display             : extension revision 1
VK_EXT_display_surface_counter         : extension revision 1
VK_EXT_surface_maintenance1            : extension revision 1
VK_EXT_swapchain_colorspace            : extension revision 4
VK_KHR_device_group_creation           : extension revision 1
VK_KHR_display                         : extension revision 23
VK_KHR_external_fence_capabilities     : extension revision 1
VK_KHR_external_memory_capabilities    : extension revision 1
VK_KHR_external_semaphore_capabilities : extension revision 1
VK_KHR_get_display_properties2         : extension revision 1
VK_KHR_get_physical_device_properties2 : extension revision 2
VK_KHR_get_surface_capabilities2       : extension revision 1
VK_KHR_portability_enumeration         : extension revision 1
VK_KHR_surface                         : extension revision 25
VK_KHR_surface_protected_capabilities  : extension revision 1
VK_KHR_wayland_surface                 : extension revision 6
VK_KHR_xcb_surface                     : extension revision 6
VK_KHR_xlib_surface                    : extension revision 6
VK_LUNARG_direct_driver_loading        : extension revision 1

Instance Layers: count = 12
---------------------------
VK_LAYER_INTEL_nullhw               INTEL NULL HW                1.1.73   version 1
VK_LAYER_MANGOAPP_overlay           Mangoapp Layer               1.3.0    version 1
VK_LAYER_MANGOAPP_overlay           Mangoapp Layer               1.3.0    version 1
VK_LAYER_MANGOHUD_overlay_32_x86    Vulkan Hud Overlay           1.3.0    version 1
VK_LAYER_MANGOHUD_overlay_64_x86_64 Vulkan Hud Overlay           1.3.0    version 1
VK_LAYER_MESA_device_select         Linux device selection layer 1.3.211  version 1
VK_LAYER_MESA_overlay               Mesa Overlay layer           1.3.211  version 1
VK_LAYER_NV_optimus                 NVIDIA Optimus layer         1.3.277  version 1
VK_LAYER_VALVE_steam_fossilize_32   Steam Pipeline Caching Layer 1.3.207  version 1
VK_LAYER_VALVE_steam_fossilize_64   Steam Pipeline Caching Layer 1.3.207  version 1
VK_LAYER_VALVE_steam_overlay_32     Steam Overlay Layer          1.3.207  version 1
VK_LAYER_VALVE_steam_overlay_64     Steam Overlay Layer          1.3.207  version 1

Devices:
========
GPU0:
	apiVersion         = 1.3.274
	driverVersion      = 24.0.7
	vendorID           = 0x8086
	deviceID           = 0xa7a0
	deviceType         = PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU
	deviceName         = Intel(R) Graphics (RPL-P)
	driverID           = DRIVER_ID_INTEL_OPEN_SOURCE_MESA
	driverName         = Intel open-source Mesa driver
	driverInfo         = Mesa 24.0.7
	conformanceVersion = 1.3.6.0
	deviceUUID         = 8680a0a7-0400-0000-0002-000000000000
	driverUUID         = 1e700872-f386-c62e-9f41-542d456ed6be
GPU1:
	apiVersion         = 1.3.277
	driverVersion      = 550.90.7.0
	vendorID           = 0x10de
	deviceID           = 0x25a2
	deviceType         = PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
	deviceName         = NVIDIA GeForce RTX 3050 Laptop GPU
	driverID           = DRIVER_ID_NVIDIA_PROPRIETARY
	driverName         = NVIDIA
	driverInfo         = 550.90.07
	conformanceVersion = 1.3.7.2
	deviceUUID         = 143d5b4f-4217-d7c0-7729-ae03f5ce0c15
	driverUUID         = b5230ae0-e881-58d9-92be-f74e3e88076f
GPU2:
	apiVersion         = 1.3.274
	driverVersion      = 0.0.1
	vendorID           = 0x10005
	deviceID           = 0x0000
	deviceType         = PHYSICAL_DEVICE_TYPE_CPU
	deviceName         = llvmpipe (LLVM 17.0.6, 256 bits)
	driverID           = DRIVER_ID_MESA_LLVMPIPE
	driverName         = llvmpipe
	driverInfo         = Mesa 24.0.7 (LLVM 17.0.6)
	conformanceVersion = 1.3.1.1
	deviceUUID         = 6d657361-3234-2e30-2e37-000000000000
	driverUUID         = 6c6c766d-7069-7065-5555-494400000000

Don’t know if this helps

Well, if you don’t mind continuing this process of doing everything until something works, you can try using a different kernel version:

# hardware-configuration.nix
  boot.kernelPackages = pkgs.linuxPackages_latest;

By default, this attribute uses pkgs.linuxPackages which is currently at 6.6.32 while the latest one is at 6.9.3. I’m personally using pkgs.linuxPackages_xanmod_latest which is at 6.8.11.

Now, would that make a difference? Let’s find out :person_shrugging:

I tried both kernels, no luck.

1 Like

for anyone who has this issue, I found a fix somewhere (can’t seem to find it now)

  boot.initrd.kernelModules = [ "nvidia" "i915" "nvidia_modeset" "nvidia_drm" ];

with this, it now works, don’t know why.

1 Like

This is the best explanation I found for why that works: