Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How do I force applications to use AMD GPU over NVIDIA?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
thebigdill97
n00b
n00b


Joined: 20 Apr 2022
Posts: 13

PostPosted: Fri Oct 28, 2022 10:25 pm    Post subject: How do I force applications to use AMD GPU over NVIDIA? Reply with quote

I have two dedicated GPUs in a desktop with no iGPU. One is NVIDIA and one is AMD. I would like to use the AMD card for everything while still having the option of loading the proprietary NVIDIA driver to use for CUDA, or possibly pass through to a VM in the future.

I am currently running sway/wayland as my window manager. I have all required kernel options configured for both GPUs, and have the NVIDIA drivers installed. Kernel version linux-6.0-pf3 (pf-sources). Only the AMD GPU has any displays plugged into it.

When I boot the system (before launching sway) the nvidia kernel module is not loaded. After launching sway, the nvidia kernel module is loaded, despite both being blacklisted and not supported by wayland.

running lsof /dev/nvidia0 gives the output:

Code:

COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
sway      9432 user   13u   CHR  195,0      0t0 1685 /dev/nvidia0
sway      9432 user   14u   CHR  195,0      0t0 1685 /dev/nvidia0
Xwayland  9571 user    9u   CHR  195,0      0t0 1685 /dev/nvidia0
Xwayland  9571 user   10u   CHR  195,0      0t0 1685 /dev/nvidia0
kitty     9657 user   11u   CHR  195,0      0t0 1685 /dev/nvidia0
...


Running glxinfo | grep renderer gives the output:
Code:

direct rendering: Yes
    GLX_MESA_query_renderer, GLX_MESA_swap_control, GLX_NV_float_buffer,
    GLX_MESA_query_renderer, GLX_MESA_swap_control, GLX_OML_swap_method,
Extended renderer info (GLX_MESA_query_renderer):
OpenGL renderer string: AMD Radeon RX 6900 XT (sienna_cichlid, LLVM 14.0.6, DRM 3.48, 6.0.0-pf2)
    GL_ARB_compute_variable_group_size, GL_ARB_conditional_render_inverted,
    GL_IBM_multimode_draw_arrays, GL_INTEL_blackhole_render,
    GL_NV_conditional_render, GL_NV_copy_image, GL_NV_depth_clamp,
    GL_ARB_compute_variable_group_size, GL_ARB_conditional_render_inverted,
    GL_INTEL_blackhole_render, GL_KHR_blend_equation_advanced,
    GL_NV_compute_shader_derivatives, GL_NV_conditional_render,
    GL_EXT_render_snorm, GL_EXT_robustness, GL_EXT_sRGB_write_control,
    GL_INTEL_blackhole_render, GL_KHR_blend_equation_advanced,
    GL_NV_conditional_render, GL_NV_draw_buffers, GL_NV_fbo_color_attachments,
    GL_OES_element_index_uint, GL_OES_fbo_render_mipmap,

I can use the nvidia-smi and radeontop programs to monitor GPU usage for difference applications, and some use the AMD card while others use the NVIDIA card. How can I force all applications to use the AMD card by default and prevent the NVIDIA kernel module from being automatically loaded?
Back to top
View user's profile Send private message
CooSee
Veteran
Veteran


Joined: 20 Nov 2004
Posts: 1441
Location: Earth

PostPosted: Sat Nov 05, 2022 5:10 pm    Post subject: Reply with quote

hello,

https://github.com/swaywm/sway/wiki#i-have-a-multi-gpu-setup-like-intelnvidia-or-intelamd-and-sway-does-not-start

search for WLR_DRM_DEVICES

Code:
# Multi-GPU

export WLR_DRM_DEVICES=/dev/dri/card0


i can't tell or help you more, because i only use one Graphics - i'am not so rich like you :lol:

you can add the varaible in your users .profile or /etc/enviroment (<<< for global use).

this is from my users .profile:

Code:
cat /home/myuser/.profile

export MOZ_ENABLE_WAYLAND=1
export MOZ_WAYLAND_USE_VAAPI=1
export MOZ_DBUS_REMOTE=1
export GDK_BACKEND=wayland
export XDG_CURRENT_DESKTOP=sway
export XDG_SESSION_DESKTOP=sway
export XDG_SESSION_TYPE=wayland
export EDITOR=/usr/bin/geany
export BROWSER=firefox


i hope it'll help you somehow.

8)
_________________
" Die Realität ist eine Illusion, die durch Mangel an ehrlicher Kommunikation entsteht "
---
" Der Mensch ist von Natur aus neugierig, was am Ende übrig bleibt ist die Gier "
Back to top
View user's profile Send private message
thebigdill97
n00b
n00b


Joined: 20 Apr 2022
Posts: 13

PostPosted: Sat Nov 19, 2022 9:48 pm    Post subject: Reply with quote

Thanks for the response. I only see one the nvidia card in /dev/dri. Could it be that the AMD card doesn't show up because the drivers are built into the kernel (instead of as loadable modules)?

One other update is that I was able to force the usage of the AMD card by simply removing the nvidia-drivers package or by overriding the driver to use vfio-pci driver for the nvidia card. Obviously both of these have the side effects that I cannot use the nvidia card at all on my main system.
Back to top
View user's profile Send private message
deno
Guru
Guru


Joined: 13 Sep 2006
Posts: 411

PostPosted: Mon Dec 11, 2023 4:34 pm    Post subject: Reply with quote

Did you actually try using them as module? Somewhere I have seen people having other issues with the built in driver.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum