Skip to content

Fix Vulkan device selection on Intel+NVIDIA PRIME systems#315

Merged
kvark merged 1 commit intomainfrom
claude/nvidia-prime-investigation-wUmwH
Mar 21, 2026
Merged

Fix Vulkan device selection on Intel+NVIDIA PRIME systems#315
kvark merged 1 commit intomainfrom
claude/nvidia-prime-investigation-wUmwH

Conversation

@kvark
Copy link
Owner

@kvark kvark commented Mar 19, 2026

Summary

  • Replace the Ubuntu-specific /etc/prime-discrete heuristic with proper multi-GPU detection
  • On Intel+NVIDIA PRIME systems, hard-reject the GPU that cannot present based on the display server
  • Detect GPU topology via sysfs (/sys/bus/pci/devices/) — zero Vulkan overhead
  • Detect display server via WAYLAND_DISPLAY / DISPLAY environment variables

Background

On Linux systems with both Intel iGPU and NVIDIA dGPU (PRIME topology), Vulkan presentation
is broken for one of the two GPUs depending on the display server:

Display server Broken GPU Root cause
X11 Intel iGPU Mesa bug #4688 — Intel cannot present when NVIDIA PRIME is active
Wayland NVIDIA dGPU Surface is owned by the compositor's GPU (Intel); NVIDIA has no display path

This is an architectural limitation in the Linux Vulkan ecosystem — there is no automatic
cross-GPU presentation mechanism. The issue spans NVIDIA drivers 460.x–570.x and Mesa 23.x–25.x,
confirming it is systemic rather than a single driver bug.

The previous workaround read /etc/prime-discrete, which is Ubuntu-specific and did not
distinguish between X11 and Wayland (where the opposite GPU is broken).

Test plan

  • Verify on single-GPU system: no adapters rejected, detect_gpu_vendors() returns one entry
  • Verify on Intel+NVIDIA X11: Intel adapter rejected, NVIDIA selected
  • Verify on Intel+NVIDIA Wayland: NVIDIA adapter rejected, Intel selected
  • Verify device_id override still works to force a specific adapter
  • Verify on non-Linux (macOS/Windows): detect_gpu_vendors() returns empty, no rejections

Closes #205

@kvark kvark force-pushed the claude/nvidia-prime-investigation-wUmwH branch from 6b673c7 to 00289ad Compare March 21, 2026 16:49
Detect multi-GPU topology via sysfs and the display server via
environment variables, then hard-reject adapters that are known to
fail presentation:
- X11: reject Intel iGPU (Mesa bug #4688)
- Wayland: reject NVIDIA dGPU (surface owned by compositor's GPU)

Replaces the Ubuntu-specific /etc/prime-discrete heuristic.

https://claude.ai/code/session_01W9jSvpnbXEXmoHFuUVFdUN
@kvark kvark force-pushed the claude/nvidia-prime-investigation-wUmwH branch from 00289ad to 31c55b8 Compare March 21, 2026 16:53
@kvark kvark merged commit bed7477 into main Mar 21, 2026
12 checks passed
@kvark kvark deleted the claude/nvidia-prime-investigation-wUmwH branch March 21, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[meta] Vulkan presentation on Nvidia Optimus/Prime

2 participants