YaLTeR / niri

A scrollable-tiling Wayland compositor.
https://matrix.to/#/#niri:matrix.org
GNU General Public License v3.0
3.29k stars 93 forks source link

How does niri handle multi-gpu display output? #550

Open WasteOfO2 opened 1 month ago

WasteOfO2 commented 1 month ago

Thanks a lot for this amazing project, appreciate this a ton!

I happen to have a hybrid GPU setup on my laptop( i.e. Nvidia+AMD) and I have confirmed that my display output is wired to my Nvidia card. I cannot seem to determine, though, what is the name of my display output for my HDMI port(I think it is HDMI-A-1, but not much help regardless).

Hence I am having some trouble setting up multi-displays. KDE seems to pick this up nicely, but there seems to be no detection from niri. I will be attaching some relevant logs below.

Niri is launched using: niri-session

System Information

Output of wlr-randr (regardless of HDMI being plugged in)

eDP-1 "11_24_6 - 22425 - eDP-1"
  Make: 11_24_6
  Model: 22425
  Serial: (null)
  Physical size: 340x190 mm
  Enabled: yes
  Modes:
    1920x1080 px, 60.056000 Hz (preferred, current)
    1920x1080 px, 40.036999 Hz
    1680x1050 px, 60.056000 Hz
    1280x1024 px, 60.056000 Hz
    1440x900 px, 60.056000 Hz
    1280x800 px, 60.056000 Hz
    1280x720 px, 60.056000 Hz
    1024x768 px, 60.056000 Hz
    800x600 px, 60.056000 Hz
    640x480 px, 60.056000 Hz
  Position: 0,0
  Transform: normal
  Scale: 1.000000
  Adaptive Sync: disabled

Output of ls /sys/class/drm/

card0       card0-eDP-1  card1-HDMI-A-1  renderD129
card0-DP-1  card1        renderD128      version

Note that card1 refers to Nvidia

Please do let me know if further info is needed!

YaLTeR commented 1 month ago

Hey, niri will try to turn on all monitors by default. If you're not seeing it then it couldn't even get to that point. I'm gonna guess it's related to nvidia; have you tried the nvidia suggestions from the getting started wiki page?

WasteOfO2 commented 1 month ago

hello

I am not confident abt this being a driver issue, as i alr have enabled modesetting and as stated in my post, KDE seems to detect my external display just fine when i connect via my HDMI port on the same setup

at best i do notice a slight glow on my monitor, but no signal for my display

here is what i have in my config related to displays

output "eDP-1" {
    mode "1920x1080@60.008"
    // scale 1.00
    transform "normal"
    position x=0 y=0
}

output "HDMI-A-1" {
    mode "1920x1080@60.000"
    transform "normal"
    // ...settings for HDMI-A-1...

}

note that i am not confident abt HDMI-A-1 output matching the refresh rate, so idk if that is the culprit here

After i remove the stuff for HDMI-A-1 from the config, i do get a 50hz signal on my monitor, but it is entirely blank

YaLTeR commented 1 month ago

Can you upload the output of niri (i.e. journalctl -eb /usr/bin/niri) and also niri msg outputs?

WasteOfO2 commented 1 month ago

journalctl -eb /usr/bin/niri

Jul 19 11:27:17 vigu niri[1258]: 2024-07-19T05:57:17.137520Z  INFO niri: starting version 0.1.7 (v0.1.7-46-ge98d1ec)
Jul 19 11:27:17 vigu niri[1258]: 2024-07-19T05:57:17.167634Z DEBUG niri_config: loaded config from "/home/vigu/.config/niri/config.kdl"
Jul 19 11:27:17 vigu niri[1258]: 2024-07-19T05:57:17.310479Z  INFO niri::backend::tty: using as the render node: "/dev/dri/renderD128"
Jul 19 11:27:17 vigu niri[1258]: 2024-07-19T05:57:17.548773Z DEBUG niri::backend::tty: device added: 57857 "/dev/dri/card1"
Jul 19 11:27:17 vigu niri[1258]: 2024-07-19T05:57:17.572620Z  WARN niri::backend::tty: error adding device: Failed to initialize EGL. Err: EGL is not initialized, or could not be initialized, for the specified EGL display connection.
Jul 19 11:27:17 vigu niri[1258]: Caused by:
Jul 19 11:27:17 vigu niri[1258]:     EGL is not initialized, or could not be initialized, for the specified EGL display connection.
Jul 19 11:27:17 vigu niri[1258]: 2024-07-19T05:57:17.572666Z DEBUG niri::backend::tty: device added: 57856 "/dev/dri/card0"
Jul 19 11:27:17 vigu niri[1258]: 2024-07-19T05:57:17.894485Z DEBUG niri::backend::tty: this is the primary node
Jul 19 11:27:17 vigu niri[1258]: 2024-07-19T05:57:17.894514Z DEBUG niri::backend::tty: this is the primary render node
Jul 19 11:27:17 vigu niri[1258]: 2024-07-19T05:57:17.959057Z DEBUG niri::backend::tty: device changed: 57856
Jul 19 11:27:17 vigu niri[1258]: 2024-07-19T05:57:17.985429Z DEBUG niri::backend::tty: connecting connector: eDP-1
Jul 19 11:27:17 vigu niri[1258]: 2024-07-19T05:57:17.985566Z  WARN niri::backend::tty: configured mode 1920x1080@60.008 could not be found, falling back to preferred
Jul 19 11:27:17 vigu niri[1258]: 2024-07-19T05:57:17.985597Z DEBUG niri::backend::tty: picking mode: Mode { name: "1920x1080", clock: 141000, size: (1920, 1080), hsync: (2028, 2076, 2100), vsync: (1090, 1100, 1118), hskew: 0, vscan: 0, vrefresh: 60, mode_type: ModeTypeFlags(PREFERRED | DRIVER) }
Jul 19 11:27:17 vigu niri[1258]: 2024-07-19T05:57:17.985705Z DEBUG niri::backend::tty: set max bpc to 8
Jul 19 11:27:17 vigu niri[1258]: 2024-07-19T05:57:17.998946Z DEBUG niri::niri: putting output eDP-1 at x=0 y=0
Jul 19 11:27:17 vigu niri[1258]: 2024-07-19T05:57:17.999078Z  INFO niri: listening on Wayland socket: wayland-1
Jul 19 11:27:17 vigu niri[1258]: 2024-07-19T05:57:17.999089Z  INFO niri: IPC listening on: /run/user/1000/niri.wayland-1.1258.sock
Jul 19 11:27:23 vigu niri[1258]: 2024-07-19T05:57:23.448155Z DEBUG niri::backend::tty: device changed: 57857
Jul 19 11:27:23 vigu niri[1258]: 2024-07-19T05:57:23.448270Z  WARN niri::backend::tty: no such device
Jul 19 11:27:23 vigu niri[1258]: 2024-07-19T05:57:23.538376Z DEBUG niri::backend::tty: device changed: 57857
Jul 19 11:27:23 vigu niri[1258]: 2024-07-19T05:57:23.538458Z  WARN niri::backend::tty: no such device
Jul 19 11:27:24 vigu niri[1258]: 2024-07-19T05:57:24.074187Z DEBUG niri::backend::tty: device changed: 57857
Jul 19 11:27:24 vigu niri[1258]: 2024-07-19T05:57:24.074268Z  WARN niri::backend::tty: no such device
Jul 19 11:28:21 vigu niri[1258]: 2024-07-19T05:58:21.138698Z DEBUG niri::backend::tty: device changed: 57857
Jul 19 11:28:21 vigu niri[1258]: 2024-07-19T05:58:21.138770Z  WARN niri::backend::tty: no such device
Jul 19 11:28:21 vigu niri[1258]: 2024-07-19T05:58:21.141492Z DEBUG niri::backend::tty: device changed: 57857
Jul 19 11:28:21 vigu niri[1258]: 2024-07-19T05:58:21.141542Z  WARN niri::backend::tty: no such device
Jul 19 11:28:38 vigu niri[1258]: 2024-07-19T05:58:38.649117Z DEBUG niri::backend::tty: device changed: 57857
Jul 19 11:28:38 vigu niri[1258]: 2024-07-19T05:58:38.649194Z  WARN niri::backend::tty: no such device
Jul 19 11:28:38 vigu niri[1258]: 2024-07-19T05:58:38.741719Z DEBUG niri::backend::tty: device changed: 57857
Jul 19 11:28:38 vigu niri[1258]: 2024-07-19T05:58:38.741811Z  WARN niri::backend::tty: no such device
Jul 19 11:28:39 vigu niri[1258]: 2024-07-19T05:58:39.186132Z DEBUG niri::backend::tty: device changed: 57857
Jul 19 11:28:39 vigu niri[1258]: 2024-07-19T05:58:39.186241Z  WARN niri::backend::tty: no such device

niri msg outputs

Output "eDP-1" (11_24_6 - 22425 - eDP-1)
  Current mode: 1920x1080 @ 60.056 Hz (preferred)
  Variable refresh rate: not supported
  Physical size: 340x190 mm
  Logical position: 0, 0
  Logical size: 1920x1080
  Scale: 1
  Transform: normal
  Available modes:
    1920x1080@60.056 (current, preferred)
    1920x1080@40.037
    1680x1050@60.056
    1280x1024@60.056
    1440x900@60.056
    1280x800@60.056
    1280x720@60.056
    1024x768@60.056
    800x600@60.056
    640x480@60.056

I tried a few times by plugging the cable in and out. Hence u see the no such device in journalctl multiple times.

niri msg outputs output was noted while the cable was plugged in

YaLTeR commented 1 month ago

EGL is not initialized, or could not be initialized, for the specified EGL display connection.

Huh, that's an error I haven't seen before. But yeah, niri/smithay fails to communicate with nvidia.

WasteOfO2 commented 1 month ago

EGL is not initialized, or could not be initialized, for the specified EGL display connection.

Huh, that's an error I haven't seen before. But yeah, niri/smithay fails to communicate with nvidia.

Can try using GBM backend instead, afaik Hyprland wiki reccomends this as well for nvidia peeps

YaLTeR commented 1 month ago

GBM is the only thing that Smithay supports

WasteOfO2 commented 1 month ago

GBM is the only thing that Smithay supports

can try forcing nvidia to use GBM backend then, not sure what to add in config to achieve that, though

YaLTeR commented 1 month ago

As in, that's the only way Smithay can communicate with a GPU. You can't configure it, it already does it. So for example if your Nvidia driver was old enough to not support GBM, it just wouldn't work. I'm not sure if this error you're getting indicates that or some other issue

dragonnn commented 1 month ago

What nvidia driver version and what does sudo cat /sys/module/nvidia_drm/parameters/modeset returns? They is no "force nvidia to use GBM option" as far I know, on my system it works out of the box, I only need to add " wait-for-frame-completion-before-queueing" to fix some flickering.

WasteOfO2 commented 1 month ago

sudo cat /sys/module/nvidia_drm/parameters/modeset

Hey,

nvidia-smi returns driver version to be: 555.58.02 sudo cat /sys/module/nvidia_drm/parameters/modeset returns: Y

WasteOfO2 commented 1 month ago

As in, that's the only way Smithay can communicate with a GPU. You can't configure it, it already does it. So for example if your Nvidia driver was old enough to not support GBM, it just wouldn't work. I'm not sure if this error you're getting indicates that or some other issue

I am sure my version of nvidia driver supports GBM, I recall Hyprland supporting Nvidia GPUs by doing smth like this

https://wiki.hyprland.org/Nvidia/#environment-variables

is there an equivalent for this in smithay that i can try or do i just sound stupid :sweat_smile:

dragonnn commented 1 month ago

sudo cat /sys/module/nvidia_drm/parameters/modeset

Hey,

nvidia-smi returns driver version to be: 555.58.02 sudo cat /sys/module/nvidia_drm/parameters/modeset returns: Y

Looks fine, what does nvidia-smi return while running niri?

WasteOfO2 commented 1 month ago

sudo cat /sys/module/nvidia_drm/parameters/modeset

Hey, nvidia-smi returns driver version to be: 555.58.02 sudo cat /sys/module/nvidia_drm/parameters/modeset returns: Y

Looks fine, what does nvidia-smi return while running niri?


Fri Jul 19 12:11:45 2024       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 555.58.02              Driver Version: 555.58.02      CUDA Version: 12.5     |
|-----------------------------------------+------------------------+----------------------+
| 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 GTX 1650        On  |   00000000:01:00.0 Off |                  N/A |
| N/A   48C    P8              1W /   30W |       9MiB /   4096MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+ | Processes: | | GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=========================================================================================| | No running processes found | +-----------------------------------------------------------------------------------------+



nothing particularly interesting, do keep in mind that i am on hybrid graphics. i can switch to dedicated or integrated graphics if that is needed for debugging
dragonnn commented 1 month ago

My laptop is hybrid graphics too and it works fine. I do have a 1660Ti. Could you try adding options nvidia NVreg_EnableGpuFirmware=1 to some modprobe file and try again? I am not sure if your GPU does support the GBM firmware but that could be the issue, I didn't try on mine without it.

WasteOfO2 commented 1 month ago

My laptop is hybrid graphics too and it works fine. I do have a 1660Ti. Could you try adding options nvidia NVreg_EnableGpuFirmware=1 to some modprobe file and try again? I am not sure if your GPU does support the GBM firmware but that could be the issue, I didn't try on mine without it.

Yes, I have added the option in modprobe for nvidia.conf I am pretty sure the drivers for Turing (i.e for RTX 20xx and GTX 16xx) are same, so our setup should be identical

can you upload your config file so that i can contrast the changes between ur setup and mine?

dragonnn commented 1 month ago

They is really nothing special in my config file, the screens worked out of the box without doing any config, only had some glitches with where fixed by wait-for-frame-completion-before-queueing option. In general if you don't see niri in nvidia-smi process output then your issue lays at the startup of niri and it not picking up the dGPU, probaly for the EGL error but I am not sure what is causing it, what distro are you? Using niri from git? I suggest picking up a build from git directly, that is what I am running

WasteOfO2 commented 1 month ago

They is really nothing special in my config file, the screens worked out of the box without doing any config, only had some glitches with where fixed by wait-for-frame-completion-before-queueing option. In general if you don't see niri in nvidia-smi process output then your issue lays at the startup of niri and it not picking up the dGPU, probaly for the EGL error but I am not sure what is causing it, what distro are you? Using niri from git? I suggest picking up a build from git directly, that is what I am running

sorry for the late reply i am using arch linux and using niri-git from AUR

WasteOfO2 commented 1 month ago

after tweaking with envycontrol and having had enabled dedicated gpu mode, the same error keeps popping up

found a little something abt this on smithay docs, i dont understand a lot of it so i am a bit helpless here https://smithay.github.io/smithay/smithay/backend/egl/ @dragonnn can u confirm that u are using EGL and not GBM? just want to sanity check

EssenSea commented 1 month ago

I've used to encounttered the similar problem. But it was relative to optimus-manager. I hope it couldbe helpful (if you use it):

  1. Change "startup_mode=intergrated" in /etc/optimus-manager/optimus-manager.conf from intergrated to nvidia.
  2. reboot computer.

If you use other similar tool(such as bumblebee), check the default configration, and change the similar option maybe helpful.

WasteOfO2 commented 1 month ago

I've used to encounttered the similar problem. But it was relative to optimus-manager. I hope it couldbe helpful (if you use it):

1. Change "startup_mode=intergrated" in /etc/optimus-manager/optimus-manager.conf from intergrated to nvidia.

2. reboot computer.

If you use other similar tool(such as bumblebee), check the default configration, and change the similar option maybe helpful.

Hello, I use envycontrol for this instead and achieves the same thing, for the tests and logs attached above i have used the dedicated GPU and specified where i havent used it

dragonnn commented 1 month ago

@dragonnn can u confirm that u are using EGL and not GBM? just want to sanity check

How can I check for that? I am not sure where to look for that https://pastebin.com/YExtB9ne here is my niri config but I am pretty sure that will not help at all.

ExploitDemon commented 1 month ago

https://github.com/YaLTeR/niri/issues/567

the only way I have got it to work is by using kanshi and even then it's extremely buggy so there needs to be a fix with niri as niri msg output <DISPLAY> on doesn't work and rather errors out as shown in the issue