HW Acceleration with Hybrid Graphics (AMD-NVIDIA) on Wayland

Hello,

I am trying to use Hardware Acceleration (with Firefox) on my laptop. My desired result would be to be able to use Firefox with hardware acceleration via Nvidia card.

I followed the documentation (Firefox Hardware acceleration - Fedora Project Wiki) and installed as well mesa-va-drivers.
I’m not sure which graphics card is currently in use for hardware acceleration. Is it possible to enable both of em and how do I select one of them to operate for e.g. Firefox?

The output from vainfo indicates to me the default use of the AMD graphics.

Trying display: wayland
libva info: VA-API version 1.21.0
libva info: Trying to open /usr/lib64/dri-nonfree/radeonsi_drv_video.so
libva info: Trying to open /usr/lib64/dri-freeworld/radeonsi_drv_video.so
libva info: Trying to open /usr/lib64/dri/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_1_21
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.21 (libva 2.21.0)
vainfo: Driver version: Mesa Gallium driver 24.1.2 for AMD Radeon Graphics (radeonsi, renoir, LLVM 18.1.6, DRM 3.57, 6.9.7-200.fc40.x86_64)
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc

And LIBVA_DRIVER_NAME=nvidia vainfo outputs:

Trying display: wayland
libva info: VA-API version 1.21.0
libva info: User environment variable requested driver 'nvidia'
libva info: Trying to open /usr/lib64/dri-nonfree/nvidia_drv_video.so
libva info: Trying to open /usr/lib64/dri-freeworld/nvidia_drv_video.so
libva info: Trying to open /usr/lib64/dri/nvidia_drv_video.so
libva info: Found init function __vaDriverInit_1_0
libva error: /usr/lib64/dri/nvidia_drv_video.so init failed
libva info: va_openDriver() returns 1
vaInitialize failed with error code 1 (operation failed),exit

Here is info about my graphics:

Graphics:
  Device-1: NVIDIA GA104M [GeForce RTX 3070 Mobile / Max-Q]
    vendor: Tongfang Hongkong driver: nvidia v: 555.58.02
    alternate: nouveau,nvidia_drm non-free: 550.xx+ 
  Device-2: AMD Cezanne [Radeon Vega Series / Radeon Mobile Series]
    vendor: Tongfang Hongkong driver: amdgpu v: kernel arch: GCN-5 code: Vega
  

Thanks in advance. If you need more information, I’m happy to provide it.
kind regards

When you run nvidia-smi and start Firefox, what do you see ?

Also, what is the results of :

Firefox - about:support Graphics

Should give you some information like this :

Firefox has a screenshot tool built in too if you need it, or You can copy the information here in </> preformatted text.
Also you can try to force start Firefox to use the Nvidia card at launch :

Screenshot from 2024-06-21 16-01-30

1 Like

Install libva-nvidia-driver and swap mesa-va-drivers with mesa-va-drivers-freeworld for more codec support:

sudo dnf install libva-nvidia-driver; sudo dnf swap mesa-va-drivers{,-freeworld}
2 Likes

The Firefox guide is outdated.

Install nvidia-vaapi-driver from RPM Fusion repository non-free. Don’t use Fedora provided libva-vdpau-driver package as it’s old and broken.

This information is incorrect. nvidia-vaapi-driver does not exist. You should install libva-nvidia-driver, which uses NVDEC as a backend (2235392 – libva-nvidia-driver should replace the nvidia-vaapi-driver rpmfusion package) (GitHub - elFarto/nvidia-vaapi-driver: A VA-API implemention using NVIDIA's NVDEC)

Additionally, the setup for Firefox and the required environment variables is incomplete. Follow this guide instead: GitHub - elFarto/nvidia-vaapi-driver: A VA-API implemention using NVIDIA's NVDEC
- media.ffmpeg.vaapi.enabled to true
- media.rdd-ffmpeg.enabled to true
- gfx.x11-egl.force-enabled to true
- environment varibles:
MOZ_DISABLE_RDD_SANDBOX=1 LIBVA_DRIVER_NAME=nvidia

3 Likes

kde hinzugefügt

@yuntaz So the Wiki is outdated ? docs-team

1 Like

Thanks to all of you and for your kind help. I think it’s working :sweat_smile:

So, I did as @yuntaz suggested to follow the guide from github; I checked all of the needed packages (do I need to swap the mesa-freeworld package, no? @ersen ), I checked about:config options and set permanent variables on /etc/environment.

Nvidia-Smi outputs:

|    0   N/A  N/A      6829    C+G   /usr/lib64/firefox/firefox                    672MiB |

nvidia-settings indicates that:

grafik

so, as written in the Github guide that C from nvidia-smi should indiciate that hardware acceleration is up and running? As read in stackoverflow, it means that C+G the graphics and the cpu are involved to run Firefox. Is this as expected?

But why there’s still vainfo returning infos about AMD Radeon Graphics and LIBVA_DRIVER_NAME=nvidia vainfo puts out this? Can I ignore?

libva info: VA-API version 1.21.0
libva info: User environment variable requested driver 'nvidia'
libva info: Trying to open /usr/lib64/dri-nonfree/nvidia_drv_video.so
libva info: Trying to open /usr/lib64/dri-freeworld/nvidia_drv_video.so
libva info: Trying to open /usr/lib64/dri/nvidia_drv_video.so
libva info: Found init function __vaDriverInit_1_0
libva error: /usr/lib64/dri/nvidia_drv_video.so init failed
libva info: va_openDriver() returns 1
vaInitialize failed with error code 1 (operation failed),exit

Thanks for your help!