You are not logged in.

#1 2022-02-25 15:33:33

kflak
Member
Registered: 2017-09-23
Posts: 52

Can't make NVIDIA primary renderer in Xorg with hybrid gpu

I have a laptop running a hybrid gpu: internal gpu with amdgpu driver, discrete gpu with proprietary nvidia driver. I am trying to configure xorg to only use the nvidia gpu for everything. So far I have only been successful in getting nvidia to run single applications through

prime-run application

but that's about it. When running a homemade openFrameworks application that requires two external monitors, one through HDMI, one through DP, Nvidia seems to only be aware of the DP one. I am also occasionally getting amd-related crashes in the app. nvidia-settings shows the DP monitor, but nothing else. It also shows activity in the GPU when I run the app through prime. However, radeontop also displays a lot of activity at the same time. So it seems that there is a lot of work happening on the amdgpu side that I would really like to move over  to nvidia. I have tried following the wiki for a similar scenario with hybrid intel/nvidia (https://wiki.archlinux.org/title/NVIDIA … phics_only), replacing intel with amdgpu like so:

10-device.conf

Section "OutputClass"
    Identifier "amdgpu"
    MatchDriver "amdgpu"
    Driver "modesetting"
EndSection

Section "OutputClass"
    Identifier "nvidia"
    MatchDriver "nvidia-drm"
    Driver "nvidia"
    Option "AllowEmptyInitialConfiguration"
    Option "PrimaryGPU" "yes"
    ModulePath "/usr/lib/nvidia/xorg"
    ModulePath "/usr/lib/xorg/modules"
EndSection

But this seems to have no effect. The output of

❯ glxinfo | grep "OpenGL renderer"
OpenGL renderer string: AMD RENOIR (DRM 3.40.0, 5.10.83.58.realtime1-1-rt-lts, LLVM 13.0.0)

and

❯ prime-run glxinfo | grep "OpenGL renderer"
OpenGL renderer string: NVIDIA GeForce GTX 1650 Ti/PCIe/SSE2

remains.

I have tried to use nvidia-xconf to generate a configuration file with nvidia-xconf --prime, resulting in this xorg.conf:

# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig:  version 510.47.03

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0"
    Inactive       "InactiveDevice1"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
EndSection

Section "Files"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BusID          "PCI:1:0:0"
EndSection

Section "Device"
    Identifier     "InactiveDevice1"
    Driver         "modesetting"
    VendorName     "Unknown"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "AllowEmptyInitialConfiguration" "True"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

Using this and moving the other xorg config files away leads to xorg not being able to start with a segfault. Full log of that crash here: https://pastebin.com/h8cWJWES

I also tried using this approach, with the same result:

/etc/X11/xorg.conf.d/05-device.conf

Section "ServerLayout"
    Identifier "layout"
    Screen 0 "nvidia"
    Inactive "amdgpu"
EndSection

Section "Device"
    Identifier "nvidia"
    Driver "nvidia"
    BusID "PCI:01:0:0"
    Option "monitor-eDP-1"
    Option "monitor-HDMI-1"
    Option "monitor-DP-0"
EndSection

Section "Screen"
    Identifier "nvidia"
    Device "nvidia"
EndSection

Section "Device"
    Identifier  "amdgpu"
    Driver      "amdgpu"
    BusID       "PCI:05:0:0"
EndSection

Section "Screen"
    Identifier "amdgpu"
    Device "amdgpu"
EndSection

Output of lspci -v:

...

01:00.0 VGA compatible controller: NVIDIA Corporation TU117M [GeForce GTX 1650 Ti Mobile] (rev a1) (prog-if 00 [VGA controller])
	Subsystem: ASUSTeK Computer Inc. Device 16df
	Flags: bus master, fast devsel, latency 0, IRQ 78, IOMMU group 9
	Memory at fb000000 (32-bit, non-prefetchable) [size=16M]
	Memory at b0000000 (64-bit, prefetchable) [size=256M]
	Memory at c0000000 (64-bit, prefetchable) [size=32M]
	I/O ports at f000 [size=128]
	Expansion ROM at fc000000 [virtual] [disabled] [size=512K]
	Capabilities: <access denied>
	Kernel driver in use: nvidia
	Kernel modules: nouveau, nvidia_drm, nvidia

...

05:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Renoir (rev c6) (prog-if 00 [VGA controller])
	Subsystem: ASUSTeK Computer Inc. Device 16df
	Flags: bus master, fast devsel, latency 0, IRQ 66, IOMMU group 6
	Memory at d0000000 (64-bit, prefetchable) [size=256M]
	Memory at e0000000 (64-bit, prefetchable) [size=2M]
	I/O ports at c000 [size=256]
	Memory at fc500000 (32-bit, non-prefetchable) [size=512K]
	Capabilities: <access denied>
	Kernel driver in use: amdgpu
	Kernel modules: amdgpu

My xorg config looks like this at the moment:

/etc/X11/xorg.conf.d/00-keyboard.conf

Section "InputClass"
    Identifier "system-keyboard"
    MatchIsKeyboard "on"
    Option "XkbOptions" "ctrl:nocaps"
    Option "XkbVariant" "altgr-intl"
EndSection

---

/etc/X11/xorg.conf.d/10-monitor.conf

Section "Monitor"
    Identifier  "eDP-1"
    Option      "Primary" "true"
EndSection

Section "Monitor"
    Identifier  "HDMI-1"
    Option      "Above" "eDP-1-0"
EndSection

Section "Monitor"
    Identifier  "DP-1-0"
    Option      "RightOf" "HDMI-1-0"
EndSection

---

/etc/X11/xorg.conf.d/10-nvidia-drm-outputclass.conf

Section "OutputClass"
    Identifier "amdgpu"
    MatchDriver "amdgpu"
    Driver "modesetting"
EndSection

Section "OutputClass"
    Identifier "nvidia"
    MatchDriver "nvidia-drm"
    Driver "nvidia"
    Option "AllowEmptyInitialConfiguration"
    Option "PrimaryGPU" "yes"
    ModulePath "/usr/lib/nvidia/xorg"
    ModulePath "/usr/lib/xorg/modules"
EndSection

---

/etc/X11/xorg.conf.d/20-nvidia.conf

Section "Device"
  Identifier "iGPU"
  Driver "modesetting"
  BusID "PCI:5:0:0"
EndSection

Section "Screen"
  Identifier "iGPU"
  Device "iGPU"
EndSection

Section "Device"
    Identifier "dGPU"
    Driver "nvidia"
    BusID "PCI:1:0:0"
    Option "monitor-HDMI-1"
    Option "monitor-DP-1-0"
EndSection

---

/etc/X11/xorg.conf.d/30-touchpad.conf

Section "InputClass"
    Identifier "Elan Touchpad"
    Driver "libinput"
    Option "NaturalScrolling" "true"
EndSection

My .xinitrc looks like this:

#!/bin/sh

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap

if [[ $(hostname) == a15 ]]; then
    3mon.sh
fi

exec bspwm

referring to this script:

#!/bin/bash

xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto

xrandr --output DP-1-0 --auto
xrandr --output DP-1-0 --mode 1920x1080 --rate 60.00
xrandr --output HDMI-1 --auto
xrandr --output HDMI-1 --right-of DP-1-0
xrandr --output HDMI-1 --mode 1920x1080 --rate 60.00
xrandr --output eDP-1 --auto 
xrandr --output eDP-1 --below DP-1-0 
xrandr --output eDP-1 --primary

I would be really, really grateful for any pointers on what I am doing wrong here. xorg and hybrid graphics is a whole new jungle for me, and I can't seem to get it working.

Offline

#2 2022-02-25 15:47:38

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,285

Re: Can't make NVIDIA primary renderer in Xorg with hybrid gpu

This "should" work if you drop all the other attempts at configuring the video outputs/drivers/whatever that aren't 10-nvidia-drm-outputclass.conf and do the monitor setup just with the xrandr invocations. and double check xrandr --listproviders that the amdgpu outputsource is really modesetting and NVIDIA-0 respectively.

Offline

#3 2022-02-25 15:49:53

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,734

Re: Can't make NVIDIA primary renderer in Xorg with hybrid gpu

5.10.83.58.realtime1-1-rt-lts

What about the main kernel?

And please post an xorg log for your present (working) configuration as well.

Offline

#4 2022-02-25 18:14:05

kflak
Member
Registered: 2017-09-23
Posts: 52

Re: Can't make NVIDIA primary renderer in Xorg with hybrid gpu

Thanks for looking into this!

V1del wrote:

This "should" work if you drop all the other attempts at configuring the video outputs/drivers/whatever that aren't 10-nvidia-drm-outputclass.conf and do the monitor setup just with the xrandr invocations. and double check xrandr --listproviders that the amdgpu outputsource is really modesetting and NVIDIA-0 respectively.

Tried removing everything but 10-nvidia-drm-outputclass.conf, but this led to xorg not starting.

Output of xrandr --listproviders:

❯ xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x44 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 4 outputs: 2 associated providers: 1 name:modesetting
Provider 1: id: 0x28b cap: 0x2, Sink Output crtcs: 4 outputs: 2 associated providers: 1 name:NVIDIA-G0

I don't know how to interpret this...

seth wrote:

What about the main kernel?

And please post an xorg log for your present (working) configuration as well.

Same same on the main kernel.

Log of working xorg here: https://pastebin.com/UuCKLdz0

Offline

#5 2022-02-25 21:20:54

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,734

Re: Can't make NVIDIA primary renderer in Xorg with hybrid gpu

Going back to the original situation: the log ends in the nvidid driver frenetically polling

[  4279.623] (--) NVIDIA(GPU-0): DFP-0: disconnected
[  4279.623] (--) NVIDIA(GPU-0): DFP-0: Internal DisplayPort
[  4279.623] (--) NVIDIA(GPU-0): DFP-0: 2660.0 MHz maximum pixel clock
[  4279.623] (--) NVIDIA(GPU-0): 
[  4279.623] (--) NVIDIA(GPU-0): DFP-1: disconnected
[  4279.623] (--) NVIDIA(GPU-0): DFP-1: Internal TMDS
[  4279.623] (--) NVIDIA(GPU-0): DFP-1: 165.0 MHz maximum pixel clock

before the server crashes.

Is that w/ the "3mon.sh" script being called? Skip that. What happens?
(sidebar: your xinitrc is broken - link below)

Moving even one more step back in time:

When running a homemade openFrameworks application that requires two external monitors, one through HDMI, one through DP, Nvidia seems to only be aware of the DP one. I am also occasionally getting amd-related crashes in the app. nvidia-settings shows the DP monitor, but nothing else. It also shows activity in the GPU when I run the app through prime. However, radeontop also displays a lot of activity at the same time. So it seems that there is a lot of work happening on the amdgpu side

So, it's common and unavoidable that if you have outputs wired to both chips, both chips will be active - one to render and output, the other as mere crtc proxy. You get to chose the roles, but they'll both be active no matter what.
nvidia-settings will only show the DP output because it's (likely) the only output wired to the nvidia chip
But I'm not sure how that relates to the "homemade openFrameworks application".
Is it some sort of frontend for nvidia-settings? What's the output of "prime-run xrandr -q" in the presently working (regular-ass-prime) configuration?

Offline

#6 2022-02-27 19:55:49

ableto
Member
Registered: 2022-02-27
Posts: 5

Re: Can't make NVIDIA primary renderer in Xorg with hybrid gpu

I recommend optimus-manager and it's GUI optional dependency optimus-manager-qt from the AUR. I'm using sddm and I did not have to configure anything, I use bbswitch as switching method. https://github.com/Askannz/optimus-manager

Offline

#7 2022-02-27 21:25:04

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,285

Re: Can't make NVIDIA primary renderer in Xorg with hybrid gpu

Optimus-manager doesn't do anything these approaches here wouldn't already do, if they don't work optimus-manager will generally not work either.

FWIW based on tha listproviders your xrandr invocation should be

xrandr --setprovideroutputsource modesetting NVIDIA-G0

Offline

#8 2022-03-14 19:04:25

onlymash
Member
Registered: 2019-12-09
Posts: 5

Re: Can't make NVIDIA primary renderer in Xorg with hybrid gpu

Offline

Board footer

Powered by FluxBB