[BUG] Nvidia driver not loading properly on multi-display setup

Summary: nvidia laptop with 2 external displays, intel mesa driver is loading instead of nvidia which means that the display plugged directly into the nvidia card is displaying only the mouse, nothing else.

Sometimes I can get the nvidia driver to load properly if I reboot the laptop, but many times I can do this 10 times and only the 11th time will work.

  • GPU: NVIDIA RTX 2000 Ada Generation Laptop GPU
  • Nvidia driver version: 575.64.03
  • Nvml version: 12.575.64.03
  • OS: Ubuntu 22.04.5 LTS
  • Kernel version: 6.8.0-65-generic
  • PC setup: Internal display, 1x DP external display, 1x external HDMI display

What I tried:

  • Completely wipe and reinstall the driver many times. Each case, the first startup is OK. Next startup is starting to act up.
  • Install different versions of nvidia driver combined with different kernel version
  • Start the laptop with only one display attached
  • Play around with xorg config files, I can’t tell you exactly what I did because many times I followed suggestions found on the internet, but nothing worked that lasted

Nvidia bug report: nvidia-bug-report.log.gz (398.1 KB)

it’s most probably an X misconfiguration. Assuming that nvidia-smi properly reports your card and that you have fbdev and modesetting params of nvidia-drm module both enabled (fbdev is enabled by default, modesetting is usually enabled somewhere in modproble config, /etc/modprobe.d/nvidia-modeset.conf on Debian), the below config should do the trick:

Section "Device"
        Identifier "Nvidia"
        Driver "nvidia"
        Option "AllowEmptyInitialConfiguration" "true"
        BusID "PCI:1:0:0"
EndSection

Section "Device"
        Identifier "Intel"
        Driver "modesetting"
        BusID "PCI:0:2:0"
EndSection

Section "Screen"
        Identifier "dual GPU"
        Device "Nvidia"  ## primary GPU performing the rendering
        GPUDevice "Intel"  ## secondary GPU providing additional monitors
EndSection