Can't switch to NVIDIA graphics card on Wayland KDE (Integrated NVIDIA/Intel)

On wayland session

glxinfo | grep "OpenGL renderer"
OpenGL renderer string: Mesa Intel(R) UHD Graphics 620 (KBL GT2)

On X11

OpenGL renderer string: NVIDIA GeForce MX150/PCIe/SSE2
sudo prime-select nvidia 
nvidia catched
nvidia driver already in use!

It also shows me in the “About this system” settings on Wayland: Graphics card - Mesa Intel® UHD Graphics 620, When on X11, it shows me my Nvidia MX150.

Do I understand correctly that in a Wayland session my laptop uses only an Intel card even for games? If so, how do I switch to Nvidia? My goal is to have all applications use the NVIDIA card under the Wayland so that I don’t have to run every single application through prime-run.

You can use switcheroo-control alongside PRIME (PRIME not required), enable it though systemd, and enable dGPU for .desktop files or applications entries.

sudo zypper in switcheroo-control
sudo systemctl enable --now switcheroo-control

Then right-click your application entry or .desktop file > Edit application… > Application > Advanced options > and mark “Run using dedicated graphics card”

Alternatively, you may also use these environment variables:

__GLX_VENDOR_LIBRARY_NAME=nvidia __NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=NVIDIA_only

If using PRIME, make sure you’re using Offload mode.

1 Like

Well, your option helps to run individual applications through NVIDIA, but is it possible for the entire system to use an NVIDIA video card instead of Intel as in an X11 session?

@JabaTheFrog prime-select boot nvidia
Ref: SDB:NVIDIA SUSE Prime - openSUSE Wiki

Offload is a better choice if on battery…

I guess you can do so by using PRIME (command given by malcolmlewis), but to what chip the output is connected to also matters. Many modern laptops with dedicated GPUs use a muxless connection in which the output goes to the iGPU and the dGPU can be used to render graphics, then the dGPU sends the rendered content to the iGPU which will output the buffer to the display, this way, rendering the entire system on the dGPU would only increase delay a bit and would also put more stress on it. There could be a exception if you got a external video output connected on the dGPU like on my case.

To check your architecture, use:

/sbin/lspci -nnk | grep -EA3 "VGA|Display|3D"

This is what it outputs for me:

01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GA107M [GeForce RTX 3050 Mobile] [10de:25a2] (rev a1)
        Subsystem: Acer Incorporated [ALI] Device [1025:159e]
        Kernel driver in use: nvidia
        Kernel modules: nouveau, nvidia_drm, nvidia
--
75:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Rembrandt [Radeon 680M] [1002:1681] (rev 0b)
        Subsystem: Acer Incorporated [ALI] Device [1025:159e]
        Kernel driver in use: amdgpu
        Kernel modules: amdgpu

Both are VGA, which means my dGPU got a direct output.
I got a Thunderbolt video output, which is connected to the AMD Radeon iGPU (as the built-in display), and a HDMI that’s connected to the NVIDIA GPU. By default, Wayland manages it by rendering the HDMI output on the dGPU and the Thunderbolt and built-in display output on the iGPU.

Anyways. ¿Why would you want to use the NVIDIA GPU for the system? I would recommend keeping it on Intel UHD for battery life and for the durability of your dGPU, also to save resources on it so the dGPU can focus on high-demanding activities like gaming, and also as the NVIDIA driver is kinda buggy and you would suffer from it.

The battery of my laptop is already 50 per cent worn out, so I only use it when it’s charging. So I would like to use the full power of the laptop, even at the OS level, without considering the battery.

¿What does your /sbin/lspci -nnk | grep -EA3 "VGA|Display|3D" shows?

00:02.0 VGA compatible controller [0300]: Intel Corporation UHD Graphics 620 [8086:5917] (rev 07)
        Subsystem: Xiaomi Device [1d72:1701]
        Kernel driver in use: i915
        Kernel modules: i915

01:00.0 3D controller [0302]: NVIDIA Corporation GP108M [GeForce MX150] [10de:1d12] (rev a1)
        Subsystem: Xiaomi Mi Notebook Pro [GeForce MX150] [1d72:1701]
        Kernel driver in use: nvidia
        Kernel modules: nouveau, nvidia_drm, nvidia

Your hardware is designed to send NVIDIA buffer to the Intel GPU so the integrated graphics will send it to the display, there’s no video output connected on the NVIDIA GPU. So even if you’re rendering the desktop environment on the NVIDIA, you’ll still use the Intel. Again, offloading the NVIDIA GPU is the best setting as your hardware is designed to work this way, and also as GeForce MX150 is not a strong one and you would like to free resources on it for higher demanding graphics. Intel UHD 620 is more than enough to render Plasma very well (trust me).

But anyways, you can switch Plasma to use the discrete graphics on Wayland by creating a file “nvidia-plasma.sh” on /etc/profile.d/

KWIN_DRM_DEVICES=/dev/dri/cardX # Where X is the number of your discrete graphics (probably 1)

Using PRIME doesn’t seems to really affect Wayland on my tests.

You can also disable the Intel UHD Graphics 620 from modprobe. But i think it will not work on your hardware design (the display will most likely not display anything).

/etc/modprobe.d/disable-intel-graphics.conf

blacklist i915

Found a better value. Use this:

KWIN_DRM_DEVICES=/dev/dri/by-path/pci-0000:01:00.0-card

I’ve also forgotten. If you’re blacklisting Intel, do this after:

sudo dracut -f --regenerate-all

I first tried the first option with
KWIN_DRM_DEVICES=/dev/dri/by-path/pci-0000:01:00.0-card and
KWIN_DRM_DEVICES=/dev/dri/cardX (with 1 and 0), but it didn’t change anything.
Then I added Intel to the blacklist, but as you said, the system just stopped displaying anything after the restart, so I had to delete this file through Recovery mode. So no progress so far (although I’m still using your method above to run some programs through NVIDIA, but I’m still wondering if it’s possible to run KDE + Wayland through NVIDIA in my case)

@JabaTheFrog what is you expectation for running the Nvidia GPU, any application can be started to use the Nvidia GPU, some these days will automatically use Prime Render Offload GPU, browsers, terminal applications, LibreOffice etc.

You can probably set up GUC/HUC for your Intel GPU (If not already running) as well.

Disable and uninstall switcheroo-control, it was meant to give Optimus d-bus for applications, since you want to use NVIDIA almost exclusively (you’re still going to need Intel to output graphics for the display) you’ll not need it anymore. And, ¿i guess that’s conflicting with that configuration? Uninstall it and try.

I’ve tried it in my machine. I figured out i forgot the “export” command and to use ‘\’ on ‘:’ to avoid it thinking that’s multiple paths.

export KWIN_DRM_DEVICES=/dev/dri/by-path/pci-0000\:01\:00.0-card

I’ve also tried with card0. Both gives results, the GPU fan speeds up, but it gets stuck in a black screen and i can’t use CTRL to change TTY. No error is log in journal. ¿So it’s working in the half, i guess? lol
It may work in your system, must be a setting (probably power management settings made it break), give it a try.

I tried it, now Wayland session doesn’t work, only X11

The thing is that in the X11 session, KDE already runs on NVIDIA, and only under Wayland it switches to Intel, so I wanted this result under Wayland as well, because gestures and shortcuts don’t work under X11 in my case.

@JabaTheFrog So when on Xorg, is there a configuration file under /etc/X11/ or /etc/X11/xorg.conf.d/?
When running Xorg, what does the output from xrandr --listproviders and xrandr --listmonitors show?

Yes, i have a configuration file under /etc/X11/xorg.conf.d/

ON X11:

xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x1b7; cap: 0x1 (Source Output); crtcs: 0; outputs: 0; associated providers: 1; name: NVIDIA-0
Provider 1: id: 0x1dd; cap: 0xf (Source Output, Sink Output, Source Offload, Sink Offload); crtcs: 3; outputs: 4; associated providers: 1; name: modesetting
    output eDP-1-1
    output HDMI-1-1
    output DP-1-1
    output HDMI-1-2
xrandr --listmonitors
Monitors: 1
 0: +*eDP-1-1 1920/344x1080/194+0+0  eDP-1-1

@JabaTheFrog What configuration file? You using suse-prime?

So, in Xorg, can you show the output from inxi -GSaz and nvidia-smi