Intel Nvidia dual GPU Laptop - need help with setup

Hi there!

I’ve got a laptop here with a dedicated GPU “Nvidia GeForce GTX 1650”
and integrated Intel UHD Graphics 630.

I’d like to use the Intel integrated graphics by default and only use the Nvidia card for certain apps / in certain situations.

This worked previously with prime-run but my setup broke with the big change in nvidia driver packages.

$ prime-run glxgears
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  152 (GLX)
  Minor opcode of failed request:  3 (X_GLXCreateContext)
  Value in failed request:  0x0
  Serial number of failed request:  25
  Current serial number in output stream:  26
$ dmesg
[   52.681628] nvidia: loading out-of-tree module taints kernel.
[   52.681645] nvidia: module license 'NVIDIA' taints kernel.
[   52.681646] Disabling lock debugging due to kernel taint
[   52.693954] nvidia: module verification failed: signature and/or required key missing - tainting kernel
[   52.719313] nvidia-nvlink: Nvlink Core is being initialized, major device number 511

[   52.719928] nvidia 0000:01:00.0: enabling device (0000 -> 0003)
[   52.768313] kernel read not supported for file pci0000:00/0000:00:01.0/0000:01:00.0/config (pid: 2536 comm: modprobe)
[   52.768376] NVRM: loading NVIDIA UNIX x86_64 Kernel Module  460.32.03  Sun Dec 27 19:00:34 UTC 2020
[   54.002742] ACPI Warning: \_SB.PCI0.PEG0.PEGP._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20200925/nsarguments-61)
[   54.898483] kernel read not supported for file pci0000:00/0000:00:01.0/0000:01:00.0/config (pid: 2534 comm: nvidia-smi)
[   62.880567] audit: type=1131 audit(1612337313.313:80): pid=1 uid=0 auid=4294967295 ses=4294967295 subj==unconfined msg='unit=systemd-hostnamed comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
[   63.056405] audit: type=1334 audit(1612337313.485:81): prog-id=10 op=UNLOAD
[   63.056407] audit: type=1334 audit(1612337313.485:82): prog-id=9 op=UNLOAD
[  537.033456] kernel read not supported for file pci0000:00/0000:00:01.0/0000:01:00.0/config (pid: 3768 comm: nvidia-smi)
$ inxi -F
System:    Host: Laptop Kernel: 5.10.7-3-MANJARO x86_64 bits: 64 Desktop: KDE Plasma 5.20.5 Distro: Manjaro Linux 
Machine:   Type: Laptop System: Dell product: XPS 15 7590 v: N/A serial: <superuser required> 
           Mobo: Dell model: 0VYV0G v: A00 serial: <superuser required> UEFI: Dell v: 1.6.0 date: 02/06/2020 
Battery:   ID-1: BAT0 charge: 86.4 Wh condition: 87.3/97.0 Wh (90%) 
CPU:       Info: 6-Core model: Intel Core i7-9750H bits: 64 type: MT MCP L2 cache: 12 MiB 
           Speed: 1395 MHz min/max: 800/4500 MHz Core speeds (MHz): 1: 1395 2: 1978 3: 1838 4: 2289 5: 4248 6: 2008 7: 1436 
           8: 3989 9: 2638 10: 2851 11: 1748 12: 1266 
Graphics:  Device-1: Intel UHD Graphics 630 driver: i915 v: kernel 
           Device-2: NVIDIA TU117M [GeForce GTX 1650 Mobile / Max-Q] driver: nvidia v: 460.32.03 
           Device-3: Microdia Integrated_Webcam_HD type: USB driver: uvcvideo 
           Display: x11 server: X.Org 1.20.10 driver: loaded: modesetting resolution: 1920x1080 
           OpenGL: renderer: Mesa Intel UHD Graphics 630 (CFL GT2) v: 4.6 Mesa 20.3.3 
Audio:     Device-1: Intel Cannon Lake PCH cAVS driver: snd_hda_intel 
           Sound Server: ALSA v: k5.10.7-3-MANJARO 
Network:   Device-1: Intel Wi-Fi 6 AX200 driver: iwlwifi 
           IF: wlp59s0 state: up mac: 08:d2:3e:b6:92:8e 
Drives:    Local Storage: total: 476.94 GiB used: 376.66 GiB (79.0%) 
           ID-1: /dev/nvme0n1 vendor: Micron model: 2200S NVMe 512GB size: 476.94 GiB 
Partition: ID-1: / size: 390.62 GiB used: 376.66 GiB (96.4%) fs: btrfs dev: /dev/dm-0 
           ID-2: /boot/efi size: 125 MiB used: 682 KiB (0.5%) fs: vfat dev: /dev/nvme0n1p3 
           ID-3: /home size: 390.62 GiB used: 376.66 GiB (96.4%) fs: btrfs dev: /dev/dm-0 
Swap:      ID-1: swap-1 type: partition size: 86.19 GiB used: 0 KiB (0.0%) dev: /dev/dm-1 
Sensors:   System Temperatures: cpu: 54.0 C mobo: N/A 
           Fan Speeds (RPM): cpu: 2394 fan-2: 2407 
Info:      Processes: 344 Uptime: 1h 31m Memory: 62.44 GiB used: 7.35 GiB (11.8%) Shell: Bash inxi: 3.2.02
$ xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x46 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 3 outputs: 4 associated providers: 0 name:modesetting
Provider 1: id: 0x7da cap: 0x0 crtcs: 0 outputs: 0 associated providers: 0 name:modesetting
$ nvidia-smi 
Wed Feb  3 10:01:16 2021       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 460.32.03    Driver Version: 460.32.03    CUDA Version: 11.2     |
|-------------------------------+----------------------+----------------------+
| 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  GeForce GTX 1650    Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   57C    P8     1W /  N/A |      0MiB /  3914MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

Did you try optimus-manager? I suggest you installing it (optimus-manager-git, AUR available), which is designed to handle drivers with Multi-GPU, especially Nvidia-Intel (I use AMD but works for me as well).
Follow the instructions carefully on its Github page, and you’ll see how easy it is to switch GPUs with it. Pay extra care if using GNOME, as I personally had hard issues to configure it properly.

yes, I tried optimus-manager, but it didn’ work neither and I’d prefer to just launch single applications with the dedicated GUI instead of switching the whole Desktop-Session.

$ optimus-manager 
ERROR: the active card is "intel" but it should be "nvidia".
Something went wrong during the last GPU setup...
Log at /var/log/optimus-manager/switch/switch-20210203T090649.log

Cannot execute command because of previous errors.
$ cat /var/log/optimus-manager/switch/switch-20210203T090649.log
[6] INFO: # Xorg pre-start hook
[8] INFO: Previous state was: {'type': 'pending_pre_xorg_start', 'requested_mode': 'nvidia', 'current_mode': 'intel'}
[10] INFO: Requested mode is: nvidia
[12] INFO: Checking for GDM display servers
[230] INFO: Available modules: ['nouveau', 'bbswitch', 'nvidia', 'nvidia_drm', 'nvidia_modeset', 'nvidia_uvm']
[232] INFO: Unloading modules ['nouveau'] (if loaded)
[1427] INFO: Loading module nvidia
[1434] INFO: Loading module nvidia_drm
[1888] INFO: Loaded extra Intel Xorg options (0 lines)
[1890] INFO: Loaded extra Intel Xorg options (0 lines)
[1892] INFO: Writing to /etc/X11/xorg.conf.d/10-optimus-manager.conf
[1894] INFO: Writing state {'type': 'pending_post_xorg_start', 'switch_id': '20210203T090649', 'requested_mode': 'nvidia'}
[1896] INFO: Xorg pre-start hook completed successfully.
[3] INFO: # Xorg post-start hook
[3] INFO: Running xrandr commands
[8] ERROR: Cannot setup PRIME : Failed to execute 'xrandr --setprovideroutputsource modesetting NVIDIA-0' :
Could not find provider with name NVIDIA-0

[8] INFO: Running /etc/optimus-manager/xsetup-nvidia.sh
[17] INFO: Writing state {'type': 'done', 'switch_id': '20210203T090649', 'current_mode': 'nvidia'}
[17] INFO: Xorg post-start hook completed successfully.

Please post the output of head -n999 /etc/X11/xorg.conf /etc/X11/xorg.conf.d/*.

$ head -n999 /etc/X11/xorg.conf /etc/X11/xorg.conf.d/*
head: cannot open '/etc/X11/xorg.conf' for reading: No such file or directory
==> /etc/X11/xorg.conf.d/00-keyboard.conf <==
# Read and parsed by systemd-localed. It's probably wise not to edit this file
# manually too freely.
Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "at"
        Option "XkbModel" "pc105"
EndSection

==> /etc/X11/xorg.conf.d/10-optimus-manager.conf.disabled <==
Section "Device"
        Identifier "intel"
        Driver "modesetting"
        BusID "PCI:0:2:0"
        Option "DRI" "3"
EndSection


==> /etc/X11/xorg.conf.d/30-touchpad.conf <==
Section "InputClass"
    Identifier "touchpad"
    Driver "libinput"
    MatchIsTouchpad "on"
    Option "Tapping" "on"
EndSection

==> /etc/X11/xorg.conf.d/90-xpra-virtual.conf <==
# Ignore all xpra virtual devices by default,
# these will be enabled explicitly when needed.
Section "InputClass"
        Identifier "xpra-virtual-device"
        MatchProduct "Xpra"
        Option "Ignore" "true"
EndSection
$ sudo mhwd
> 0000:01:00.0 (0302:10de:1f91) Display controller nVidia Corporation:
--------------------------------------------------------------------------------
                  NAME               VERSION          FREEDRIVER           TYPE
--------------------------------------------------------------------------------
video-hybrid-intel-nvidia-prime            2020.11.30               false            PCI
          video-nvidia            2020.11.30               false            PCI
           video-linux            2018.05.04                true            PCI


> 0000:00:02.0 (0300:8086:3e9b) Display controller Intel Corporation:
--------------------------------------------------------------------------------
                  NAME               VERSION          FREEDRIVER           TYPE
--------------------------------------------------------------------------------
video-hybrid-intel-nvidia-prime            2020.11.30               false            PCI
           video-linux            2018.05.04                true            PCI
     video-modesetting            2020.01.13                true            PCI
            video-vesa            2017.03.12                true            PCI

The problem seems to be the same as here. Please try the suggestion in comment 8 before trying the solution.

got the same result:

dmesg output on TTY2 (which I used to add .disabled to the filename to be able to post this:

so I’m gonna try the config from post18 of that thread next.

UPDATE: the config from post18 boots into KDE fine, but it doesn’t make prime-run work for me…

$ prime-run glxgears
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  152 (GLX)
  Minor opcode of failed request:  3 (X_GLXCreateContext)
  Value in failed request:  0x0
  Serial number of failed request:  25
  Current serial number in output stream:  26

What’s the output of xrandr --listproviders with the configuration from comment 18?

$ xrandr --listproviders
Providers: number : 1
Provider 0: id: 0x46 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 3 outputs: 4 associated providers: 0 name:modesetting

okey so with this config I can now use optimus-manager to switch between intel & nvidia, but hybrid mode doesn’t work (hangs the system needing hardware-restart).

In nvidia mode the KDE plasmashell hangs for a few seconds quite often.

and in intel mode prime-run doesn’t work. (probably as designed):

$ prime-run glxinfo | grep -i renderer
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  152 (GLX)
  Minor opcode of failed request:  24 (X_GLXCreateNewContext)
  Value in failed request:  0x0
  Serial number of failed request:  39
  Current serial number in output stream:  40
$ glxinfo | grep -i renderer
    GLX_MESA_query_renderer, GLX_MESA_swap_control, GLX_OML_swap_method, 
    GLX_INTEL_swap_event, GLX_MESA_copy_sub_buffer, GLX_MESA_query_renderer, 
Extended renderer info (GLX_MESA_query_renderer):
OpenGL renderer string: Mesa Intel(R) UHD Graphics 630 (CFL GT2)

Does anybody have any hints for me what I could try to get hybrid mode with prime-run working again?

I now found that nvidia-xrun from the AUR package nvidia-xrun-pm does work fine.

Also it seems to no longer have the problem that switching directly between this nvidia dedicated X-Server and the default desktop environment without going to a different TTY in between freezes the machine requiring a hardware reboot.

But it seems to not be able to quit correctly preventing the user from starting another application with it without rebooting first.

UPDATE: okey I don’t know what changed but the optimus manager hybrid mode works now too, though what seem’s strange to me is that in that mode even before starting a single application with prime-run the x-server itself is shown in the application list of nvidia-smi