You are not logged in.

#1 2024-02-22 04:54:56

Aurelio3351
Member
From: Argentina
Registered: 2024-02-19
Posts: 23

[ABANDONED] Force Wayland to use NVIDIA Graphics in Hybrid GPU Laptop

Hi.

I have an MSI Creator Z16 Laptop that has the NVIDIA Optimus/Hybrid graphics technology.

When i first installed Arch, i didn't wanted to play games or do anything that needs the NVIDIA Graphics, i have a Good PC with Windows for that, so i just followed the wiki to fully power down the NVIDIA graphics card with udev rules (https://wiki.archlinux.org/title/Hybrid … screte_GPU), and it worked well.

With the time i started to need the NVIDIA Graphics card for some things so i returned to the wiki, removed the udev rules, installed the NVIDIA propietary driver (With the Kernel parameter and Early KMS), and followed to guide to use the NVIDIA graphics only (https://wiki.archlinux.org/title/NVIDIA … phics_only). The wiki says that you run "glxinfo | grep NVIDIA", and if there is some output, it means the graphic card is working. So i login into my Plasma-Wayland session (I use Wayland because X11 in >60Hz screens is unbearably slow) and ran the command, only to get no output. I suspected it could be related to Wayland, so i login into Plasma but using X11, ran the command, and indeed, i got output.

I searched and i didn't find any way to force Wayland to use the NVIDIA Graphics, and i really don't want to use optimus-manager or another hybrid graphics applications, or even worse, switch to X11, so does anyone know a solution?

Thanks in advance.

Last edited by Aurelio3351 (2024-02-24 00:13:42)


My life was going well until I started using Arch Linux.

Offline

#2 2024-02-22 10:08:00

seth
Member
Registered: 2012-09-03
Posts: 51,655

Re: [ABANDONED] Force Wayland to use NVIDIA Graphics in Hybrid GPU Laptop

I use Wayland because X11 in >60Hz screens is unbearably slow

?
Sounds more like a prime-sync issue, do you have an xorg log?

https://wiki.archlinux.org/title/PRIME# … figuration
https://wiki.archlinux.org/title/NVIDIA … de_setting is absolutely required for wayland support
What does "glxinfo -B" on wayland actually report?

From recent posts you might want to try kde-unstable for KDE on wayland.

Offline

#3 2024-02-22 14:43:41

~tfa
Member
From: Germany
Registered: 2021-11-03
Posts: 14
Website

Re: [ABANDONED] Force Wayland to use NVIDIA Graphics in Hybrid GPU Laptop

glxinfo | grep NVIDIA

gives no output on my hybrid laptop as well, cause I have RTD3 cold suspend properly configured, the dGPU stays offline and the command wont poll it. So glxinfo will only give you information from the iGPU in that case.
To see if the nvidia is there try the tool 'nvtop' or type in the console:

nvidia-smi

With nvidia it is most often a configuration issue on hybrid laptops. You can basically use the laptop with the iGPU and have the dGPU powered down, there is no need to disable it at all. The new RTD3 cold suspend does the trick.

To get that working properly, on a fresh arch install, I use the automated setup for nvidia: https://github.com/Frogging-Family/nvidia-all
And afterwards install the tool optimus-manager. There you only have to set in the nvidia tab Dynamic power management to Fine and that's it.

If you want to launch an application specifically on the nvidia dGPU here is the documentation of fine-grained control: https://download.nvidia.com/XFree86/Lin … fload.html
It is so most often not necessary, the nvidia driver, will know in 99% of the cases when it is needed.

Last edited by ~tfa (2024-02-22 14:47:55)

Offline

#4 2024-02-22 14:50:27

Aurelio3351
Member
From: Argentina
Registered: 2024-02-19
Posts: 23

Re: [ABANDONED] Force Wayland to use NVIDIA Graphics in Hybrid GPU Laptop

I use Wayland because X11 in >60Hz screens is unbearably slow

At least for me, it has always been like that. In every screen >60Hz + NVIDIA Graphics (open-source/propietary) + X11 has always been very slow for me, but i may be wrong and that shouldn't happen. When i moved to Wayland, i saw that everything was so fast, that i couldn't return to X11 ever.
If this is my error and X11 can be smooth with this, i may return to X11.

https://wiki.archlinux.org/title/NVIDIA … de_setting is absolutely required for wayland support

I had already enabled it. And also Early KMS, with the pacman hook and everything. You can trust me that the error is not in this.

What does "glxinfo -B" on wayland actually report?

glxinfo  -B output on Wayland:

[aurelio3351@Z16Aurelio ~]$ glxinfo -B
name of display: :1
display: :1  screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: Intel (0x8086)
    Device: Mesa Intel(R) UHD Graphics (TGL GT1) (0x9a60)
    Version: 24.0.1
    Accelerated: yes
    Video memory: 15696MB
    Unified memory: yes
    Preferred profile: core (0x1)
    Max core profile version: 4.6
    Max compat profile version: 4.6
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.2
OpenGL vendor string: Intel
OpenGL renderer string: Mesa Intel(R) UHD Graphics (TGL GT1)
OpenGL core profile version string: 4.6 (Core Profile) Mesa 24.0.1-arch1.1
OpenGL core profile shading language version string: 4.60
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 4.6 (Compatibility Profile) Mesa 24.0.1-arch1.1
OpenGL shading language version string: 4.60
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile

OpenGL ES profile version string: OpenGL ES 3.2 Mesa 24.0.1-arch1.1
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20

Sounds more like a prime-sync issue, do you have an xorg log?

My Xorg log: https://pastebin.com/b5NQSL8S

I suppose i have to set this as an environment variable:

DRI_PRIME=pci-0000_01_00_0 __VK_LAYER_NV_optimus=NVIDIA_only __GLX_VENDOR_LIBRARY_NAME=nvidia glxinfo | grep 'OpenGL renderer string'

How can i do that?


My life was going well until I started using Arch Linux.

Offline

#5 2024-02-22 15:00:04

Aurelio3351
Member
From: Argentina
Registered: 2024-02-19
Posts: 23

Re: [ABANDONED] Force Wayland to use NVIDIA Graphics in Hybrid GPU Laptop

To see if the nvidia is there try the tool 'nvtop' or type in the console: nvidia-smi

I already ran this command and it recognizes the NVIDIA Graphics card but it says it's only being used by Xorg, and if i run a game on X11 session the NVIDIA Graphics start using, but in Wayland session, the game uses the Intel Graphics, because the NVIDIA Graphics usage is at 0%.

nvidia-smi output (on Wayland):

[aurelio3351@Z16Aurelio ~]$ nvidia-smi
Thu Feb 22 11:53:47 2024       
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 545.29.06              Driver Version: 545.29.06    CUDA Version: 12.3     |
|-----------------------------------------+----------------------+----------------------+
| 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 3060 ...    Off | 00000000:01:00.0 Off |                  N/A |
| N/A   43C    P8               6W /  60W |     45MiB /  6144MiB |      0%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+
                                                                                         
+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|    0   N/A  N/A       722      G   /usr/lib/Xorg                                40MiB |
+---------------------------------------------------------------------------------------+

My life was going well until I started using Arch Linux.

Offline

#6 2024-02-22 15:04:21

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,771

Re: [ABANDONED] Force Wayland to use NVIDIA Graphics in Hybrid GPU Laptop

DRI_PRIME=pci-0000_01_00_0 __VK_LAYER_NV_optimus=NVIDIA_only __GLX_VENDOR_LIBRARY_NAME=nvidia glxinfo | grep 'OpenGL renderer string'

run that literal command as you pasted it here.

Also generally speaking that's what the prime-run script in the nvidia-prime package is for and is generally what you should be using to invoke this.

If your end goal is to run the entire wayland session on the nvidia GPU try setting export KWIN_DRM_DEVICES=/dev/dri/card1:/dev/dri/card0" somewhere early in the environment e.g. /etc/profile or so.

Last edited by V1del (2024-02-22 15:06:46)

Offline

#7 2024-02-22 15:15:18

Aurelio3351
Member
From: Argentina
Registered: 2024-02-19
Posts: 23

Re: [ABANDONED] Force Wayland to use NVIDIA Graphics in Hybrid GPU Laptop

run that literal command as you pasted it here.

Only got this output and nothing happened:

[aurelio3351@Z16Aurelio ~]$ DRI_PRIME=pci-0000_01_00_0 __VK_LAYER_NV_optimus=NVIDIA_only __GLX_VENDOR_LIBRARY_NAME=nvidia glxinfo | grep 'OpenGL renderer string'
OpenGL renderer string: NVIDIA GeForce RTX 3060 Laptop GPU/PCIe/SSE2

If your end goal is to run the entire wayland session on the nvidia GPU try setting export KWIN_DRM_DEVICES=/dev/dri/card1:/dev/dri/card0" somewhere early in the environment e.g. /etc/profile or so.

That's my only goal.
Just added literally this to /etc/profile:

export KWIN_DRM_DEVICES=/dev/dri/card1:/dev/dri/card0

Gonna try rebooting.


My life was going well until I started using Arch Linux.

Offline

#8 2024-02-22 15:16:15

~tfa
Member
From: Germany
Registered: 2021-11-03
Posts: 14
Website

Re: [ABANDONED] Force Wayland to use NVIDIA Graphics in Hybrid GPU Laptop

In steam startup options of the game you can force the use of the nvidia for instance

__NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=NVIDIA_only %command%

in the launch options of the game.
The one instance of Xorg in nvidia-smi is normal, it is always there. On Plasma there is still an Xorg server within the Wayland session. I have it too being on Wayland.

Thu Feb 22 16:29:45 2024       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 550.40.07              Driver Version: 550.40.07      CUDA Version: 12.4     |
|-----------------------------------------+------------------------+----------------------+
| 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 4060 ...    On  |   00000000:01:00.0 Off |                  N/A |
| N/A   38C    P0             N/A /   55W |       7MiB /   8188MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
                                                                                         
+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|    0   N/A  N/A      1580      G   /usr/lib/Xorg                                   4MiB |
+-----------------------------------------------------------------------------------------+

If the nvidia driver tho is properly installed and configured, it does that on its own. I can only advise you to use the tool in my above coment, in its install script you can see all the steps necessary and fixes and patches applied.

Last edited by ~tfa (2024-02-22 15:30:22)

Offline

#9 2024-02-22 15:20:36

Aurelio3351
Member
From: Argentina
Registered: 2024-02-19
Posts: 23

Re: [ABANDONED] Force Wayland to use NVIDIA Graphics in Hybrid GPU Laptop

In steam you can force the use of the nvidia for instance

I want Wayland to completely and exclusively use the NVIDIA Graphics, that's the problem here.


My life was going well until I started using Arch Linux.

Offline

#10 2024-02-22 15:23:10

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,771

Re: [ABANDONED] Force Wayland to use NVIDIA Graphics in Hybrid GPU Laptop

The thing is that goal is usually not really useful in terms of both performance and power consumption. For light tasks that the integrated card is good enough you're wasting a bunch of CPU cycles copying the buffer to the integrated GPU for display and back and forth. These systems are designed to be used in the manner that the two GPUs work in tandem for a given task. The absolute best way to guarantee what you want is if you have a physical or UEFI firmware level switch to disable the integrated GPU.

Offline

#11 2024-02-22 15:23:21

~tfa
Member
From: Germany
Registered: 2021-11-03
Posts: 14
Website

Re: [ABANDONED] Force Wayland to use NVIDIA Graphics in Hybrid GPU Laptop

If you use the tool 'optimus-manager' you can switch the whole session to only be running on integrated, hybrid or the nvidia. If you want to do it manually, it should be a matter of the xorg configuration.

Offline

#12 2024-02-22 15:33:15

Aurelio3351
Member
From: Argentina
Registered: 2024-02-19
Posts: 23

Re: [ABANDONED] Force Wayland to use NVIDIA Graphics in Hybrid GPU Laptop

If you use the tool 'optimus-manager

optimus-manager is only compatible with X11...

The absolute best way to guarantee what you want is if you have a physical or UEFI firmware level switch to disable the integrated GPU.

Unfortunately, i don't have one, this model doesn't even has an option to disable the NVIDIA GPU.

The thing is that goal is usually not really useful in terms of both performance and power consumption.

Then what the fuck do i do? Just not using Wayland? Then they tell that Wayland is the future and blah blah blah, but you can't correctly use your Hybrid Graphics.


My life was going well until I started using Arch Linux.

Offline

#13 2024-02-22 18:05:23

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,771

Re: [ABANDONED] Force Wayland to use NVIDIA Graphics in Hybrid GPU Laptop

I gave you an option to try and force KWin to a specific render device, this has inherently nothing to do with Wayland and your approach is just as inefficient on xorg. But the redirect needs to happen over/via the compositor and the majority of them will default to initalize on the actual GPU attached to an actual display. Which is also what Windows does and for which usecase this technology was primarily developed for.

Also note that especially on KDE a bunch of improvements to multi GPU support have been made in plasma 6 so that would be a potential test as well.

@~tfa- optimus-manager will do exactly nothing at all on Wayland and on Xorg will do the functional equivalent of what has already been achieved by following the corresponding Optimus article from the wiki.

Correctly using hybrid graphics is using nvidia-prime to run actual games and clients that need it via the discrete GPU, does that not work? the glxinfo invocation seems to have worked?

Last edited by V1del (2024-02-22 18:10:47)

Offline

#14 2024-02-22 18:26:18

seth
Member
Registered: 2012-09-03
Posts: 51,655

Re: [ABANDONED] Force Wayland to use NVIDIA Graphics in Hybrid GPU Laptop

Fwwi, you're running the X11 server on the nvidia GPU, but the output is wired to the intel IGP and that's likely causing the slowdown (and possibly will too, if you setup wayland this way)
There's no explicit config for that, the GPU order is just wrong.
Try /etc/X11/xorg.conf.d/10-gpu.conf

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

Section "Screen"
    Identifier "intel"
    Device "intel"
EndSection

and report back with results and an updated xorg log.

In that light I'd not be too hopeful for running wayland on the nvidia GPU making things any better and run either display server in the regular PRIME fashion on the intel chip, invoking the nvidia one for heavy tasks.
For X11 you could also try https://wiki.archlinux.org/title/PRIME# … ronization but without strong reason to run on nvidia all the time, that's inferior.
If this is truely what you want, and as V1del suggested, see whether you can disable the IGP in the firmware.

Offline

#15 2024-02-22 18:26:48

~tfa
Member
From: Germany
Registered: 2021-11-03
Posts: 14
Website

Re: [ABANDONED] Force Wayland to use NVIDIA Graphics in Hybrid GPU Laptop

Ah ok, I am pretty new to Wayland (like a week) and didn't know that yet.

After installing the nvidia driver with the nvidia-all script, I have only created one file in:

/etc/modprobe.d/nvidia.conf

options nvidia NVreg_DynamicPowerManagement=0x02

and that made a perfect hybrid laptop in Wayland.

Offline

#16 2024-02-22 18:29:03

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,598

Re: [ABANDONED] Force Wayland to use NVIDIA Graphics in Hybrid GPU Laptop

Ug, nvidia-all. Good luck with that clusterfuck.

Offline

#17 2024-02-22 18:30:02

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,771

Re: [ABANDONED] Force Wayland to use NVIDIA Graphics in Hybrid GPU Laptop

I'd also assume that to be generally sufficient, but for reasons not yet stated the OP seems bent on rendering everything on the nvidia GPU, aside from the actual demanding stuff.

Offline

#18 2024-02-22 18:31:31

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,598

Re: [ABANDONED] Force Wayland to use NVIDIA Graphics in Hybrid GPU Laptop

That's not what nvidia-all is, though. https://github.com/Frogging-Family/nvid … r/PKGBUILD

Offline

#19 2024-02-22 19:07:07

seth
Member
Registered: 2012-09-03
Posts: 51,655

Re: [ABANDONED] Force Wayland to use NVIDIA Graphics in Hybrid GPU Laptop

V1del probably replied to ~tfa wrt the NVreg_DynamicPowerManagement=0x02 option - or to me.
The OP is however Aurelio3351

Offline

#20 2024-02-22 20:38:08

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,771

Re: [ABANDONED] Force Wayland to use NVIDIA Graphics in Hybrid GPU Laptop

Yes everything in my response was to ~tfa, while I also feel people gravitate to nvidia-all for often not quite the right reasons it's unlikely to be relevant here, in general or to Aurelio's goals.

Offline

#21 2024-02-24 00:02:45

Aurelio3351
Member
From: Argentina
Registered: 2024-02-19
Posts: 23

Re: [ABANDONED] Force Wayland to use NVIDIA Graphics in Hybrid GPU Laptop

Hi, sorry for my very late response, i've been out of my home the hole day.
As Seth said:

Fwwi, you're running the X11 server on the nvidia GPU, but the output is wired to the intel IGP and that's likely causing the slowdown (and possibly will too, if you setup wayland this way)

The reason of X11 slowness was really caused by forcing it to use the NVIDIA GPU, because it is wired to the NVIDIA GPU and that makes the output slow at the end.
So, the best way i found to do what i wanted to do, is passing to X11 and using optimus-manager in hybrid mode. It is not perfect, but it's ok. And i even found it a little more smooth than Wayland using only the Intel GPU.
Unfortunately, as i think everyone here knows, optimus-manager doesn't works in Wayland, but as long as X11 is not so slow as it was for me, i can use X11.
I really don't know if mark this as solved, because the topic original goal was to force Wayland to only use the NVIDIA GPU, goal that, reading your posts, i don't think it is possible (at least working well). So i think i'm marking this as abandonned, except you have a way to make Wayland only use the NVIDIA Graphics.
Thanks for the help anyway.


My life was going well until I started using Arch Linux.

Offline

#22 2024-02-24 02:13:01

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,771

Re: [ABANDONED] Force Wayland to use NVIDIA Graphics in Hybrid GPU Laptop

There's no point to optimus-manager on a remotely modern system. What you're actually running by switching to "hybrid" is what's already going on by default and general setup and config options for that are described in: https://wiki.archlinux.org/title/PRIME# … er_offload -- which ultimately is the approach seth and I suggested, since that is how that constellation is intended by the hardware manufacturer.

People vastly overestimate what optimus-manager does exactly. It's a glorified xorg config and module blacklister you can do all that it can do with xorg and modprobe configs respectively and if you have a sufficiently new (Turing and up so 20xx and newer GPU) you can completely power off the nvidia card if nothing's running on it - thus obsoleting the "integrated only" usecases in terms of power management. It has no control over hardware support or compatibility beyond that.

Offline

#23 2024-02-28 01:06:13

andyturfer
Member
Registered: 2021-01-08
Posts: 72

Re: [ABANDONED] Force Wayland to use NVIDIA Graphics in Hybrid GPU Laptop

Envy Control is an alternative to Optimus Manager, and it works with Wayland.

Have you tried looking at GPU options in your BIOS? I don't know about the MSI Creator Z16, but on both of my Legion laptops there's a "Discrete GPU" BIOS option (which disables the iGPU completely).

Offline

#24 2024-02-28 01:26:16

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,771

Re: [ABANDONED] Force Wayland to use NVIDIA Graphics in Hybrid GPU Laptop

And it does help nothing at all to the relevant end goal. All of these tools do the same thing in essence, to that effect optimus-manager "works" on wayland as well, but there's simply no standardized protocol that you can tell a compositor to just render everything on a different GPU (which as has been found out is also normally not the goal...)

You either have a hardware switch in the BIOS, which would be best, or you should use the nvidia gpu on an as needed basis with the prime-run script.

Offline

Board footer

Powered by FluxBB