Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRM device recognition error on dual GPU devices #311

Open
acdcbyl opened this issue Jul 18, 2024 · 7 comments
Open

DRM device recognition error on dual GPU devices #311

acdcbyl opened this issue Jul 18, 2024 · 7 comments

Comments

@acdcbyl
Copy link

acdcbyl commented Jul 18, 2024

Thank you all for your efforts! My laptop consists of AMD integrated graphics and NVIDIA discrete graphics, and I need NVIDIA's dGPU to hard decode for my firefox, so I'm trying to use vainfo to check that the vaapi is working, and I think I'm running into a problem.
Here are the details:

  • System Information
Linux: Arch linux
Kernel: Linux 6.9.9-arch1-1
Desktop: Hyprland 
Cpu: AMD Ryzen 7 4800H (16) @ 2.90 GHz
iGpu: AMD Radeon Vega Series / Radeon Vega Mobile Series [Integrated]
dGpu: NVIDIA GeForce RTX 2060 Mobile [Discrete]
Nvidia Driver : nvidia 
Driver Version: 555.58.02
  • Execute nvidia-smi
+-----------------------------------------------------------------------------------------+
| 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 RTX 2060        Off |   00000000:01:00.0 Off |                  N/A |
| N/A   52C    P8              4W /   90W |       9MiB /   6144MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
                                                                                         
+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|    0   N/A  N/A    261741      G   /usr/lib/Xorg                                   4MiB |
|    0   N/A  N/A    261815      G   Hyprland                                        1MiB |
+-----------------------------------------------------------------------------------------+
  • Execute vainfo
Trying display: wayland
libva error: /usr/lib/dri/nvidia_drv_video.so init failed
vaInitialize failed with error code 1 (operation failed),exit
  • Add variable NVD_LOG=1 to execute vainfo to view the information
Trying display: wayland
      5452.351155764 [555255-555255] ../nvidia-vaapi-driver-0.0.12/src/vabackend.c:2188       __vaDriverInit_1_0 Initialising NVIDIA VA-API Driver: 40
      5452.351167125 [555255-555255] ../nvidia-vaapi-driver-0.0.12/src/vabackend.c:2197       __vaDriverInit_1_0 Now have 0 (0 max) instances
      5452.351169590 [555255-555255] ../nvidia-vaapi-driver-0.0.12/src/vabackend.c:2223       __vaDriverInit_1_0 Selecting Direct backend
      5452.359507038 [555255-555255] ../nvidia-vaapi-driver-0.0.12/src/backend-common.c:  31            isNvidiaDrmFd Invalid driver for DRM device: amdgpu
      5452.359519021 [555255-555255] ../nvidia-vaapi-driver-0.0.12/src/vabackend.c:2248       __vaDriverInit_1_0 Exporter failed
libva error: /usr/lib/dri/nvidia_drv_video.so init failed
vaInitialize failed with error code 1 (operation failed),exit

I'm not quite sure the reason for this, it seems amd's iGpu is recognised as a DRM device. It's a bit mind boggling.

  • Execute vainfo for the specified DRM device
    vainfo --display drm --device /dev/dri/renderD128
Trying display: drm
vainfo: VA-API version: 1.21 (libva 2.22.0)
vainfo: Driver version: VA-API NVDEC driver [direct backend]
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileHEVCMain               :	VAEntrypointVLD
      VAProfileVP8Version0_3          :	VAEntrypointVLD
      VAProfileVP9Profile0            :	VAEntrypointVLD
      VAProfileHEVCMain10             :	VAEntrypointVLD
      VAProfileHEVCMain12             :	VAEntrypointVLD
      VAProfileVP9Profile2            :	VAEntrypointVLD
      VAProfileHEVCMain444            :	VAEntrypointVLD
      VAProfileHEVCMain444_10         :	VAEntrypointVLD
      VAProfileHEVCMain444_12         :	VAEntrypointVLD

Obviously, it worked. Now the big question becomes how to set the DRM device to /dev/dri/renderD128.
This seems like a strange issue, it seems that /dev/dri/renderD128 can be set as the default DRM device via an environment variable. But I failed, I tried WLR_DRM_DEVICES (which caused Hyprland to crash), MOZ_DRM_DEVICE (which didn't seem to have any effect,Firefox still doesn't try to hard-decode, even though I've set it up.).

@duncanyoyo1
Copy link

I am noticing a similar issue, but I only have one GPU in my system.

vainfo
Trying display: wayland
Trying display: x11
libva error: vaGetDriverNames() failed with unknown libva error
vainfo: VA-API version: 1.21 (libva 2.22.0)
vainfo: Driver version: VA-API NVDEC driver [direct backend]
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain12             : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD
      VAProfileHEVCMain444            : VAEntrypointVLD
      VAProfileHEVCMain444_10         : VAEntrypointVLD
      VAProfileHEVCMain444_12         : VAEntrypointVLD

with NVD_LOG=1

libva error: vaGetDriverNames() failed with unknown libva error
      2395.728171647 [39265-39265] ../src/vabackend.c:2187       __vaDriverInit_1_0 Initialising NVIDIA VA-API Driver: 10
      2395.728183019 [39265-39265] ../src/vabackend.c:2196       __vaDriverInit_1_0 Now have 0 (0 max) instances
      2395.728185774 [39265-39265] ../src/vabackend.c:2222       __vaDriverInit_1_0 Selecting Direct backend
      2395.738263002 [39265-39265] ../src/direct/direct-export-buf.c:  68      direct_initExporter Searching for GPU: 0 0 128
      2395.738286817 [39265-39265] ../src/direct/direct-export-buf.c:  90      direct_initExporter Found NVIDIA GPU 0 at /dev/dri/renderD128
      2395.738289693 [39265-39265] ../src/direct/nv-driver.c: 267            init_nvdriver Initing nvdriver...
      2395.738315362 [39265-39265] ../src/direct/nv-driver.c: 285            init_nvdriver NVIDIA kernel driver version: 555.58.02, major version: 555, minor version: 58
      2395.738319249 [39265-39265] ../src/direct/nv-driver.c: 292            init_nvdriver Got dev info: 4200 1 2 6

with vainfo --display drm --device /dev/dri/renderD128

vainfo: VA-API version: 1.21 (libva 2.22.0)
vainfo: Driver version: VA-API NVDEC driver [direct backend]
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain12             : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD
      VAProfileHEVCMain444            : VAEntrypointVLD
      VAProfileHEVCMain444_10         : VAEntrypointVLD
      VAProfileHEVCMain444_12         : VAEntrypointVLD

@caniko
Copy link

caniko commented Aug 11, 2024

I have this issue too:

❯  NVD_LOG=1 LIBVA_DRIVER_NAME=nvidia NVD_BACKEND=direct vainfo
Trying display: wayland
libva info: VA-API version 1.22.0
libva info: User environment variable requested driver 'nvidia'
libva info: Trying to open /run/opengl-driver/lib/dri/nvidia_drv_video.so
libva info: Found init function __vaDriverInit_1_0
       957.721601938 [19427-19427] ../src/vabackend.c:2188       __vaDriverInit_1_0 Initialising NVIDIA VA-API Driver: 40
       957.721607989 [19427-19427] ../src/vabackend.c:2197       __vaDriverInit_1_0 Now have 0 (0 max) instances
       957.721610895 [19427-19427] ../src/vabackend.c:2223       __vaDriverInit_1_0 Selecting Direct backend
       957.732369563 [19427-19427] ../src/backend-common.c:  31            isNvidiaDrmFd Invalid driver for DRM device: amdgpu
       957.732378340 [19427-19427] ../src/vabackend.c:2248       __vaDriverInit_1_0 Exporter failed
libva error: /run/opengl-driver/lib/dri/nvidia_drv_video.so init failed
libva info: va_openDriver() returns 1
vaInitialize failed with error code 1 (operation failed),exit

Fixed when: NVD_LOG=1 vainfo --display drm --device /dev/dri/by-path/pci-0000:01:00.0-render

Trying display: drm
libva info: VA-API version 1.22.0
libva info: User environment variable requested driver 'nvidia'
libva info: Trying to open /run/opengl-driver/lib/dri/nvidia_drv_video.so
libva info: Found init function __vaDriverInit_1_0
      4232.998322754 [42848-42848] ../src/vabackend.c:2188       __vaDriverInit_1_0 Initialising NVIDIA VA-API Driver: 31
      4232.998327463 [42848-42848] ../src/vabackend.c:2197       __vaDriverInit_1_0 Now have 0 (0 max) instances
      4232.998330238 [42848-42848] ../src/vabackend.c:2223       __vaDriverInit_1_0 Selecting Direct backend
      4233.005616676 [42848-42848] ../src/direct/nv-driver.c: 267            init_nvdriver Initing nvdriver...
      4233.005647463 [42848-42848] ../src/direct/nv-driver.c: 285            init_nvdriver NVIDIA kernel driver version: 555.58.02, major version: 555, minor version: 58
      4233.005651551 [42848-42848] ../src/direct/nv-driver.c: 292            init_nvdriver Got dev info: 100 1 2 6
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.22 (libva 2.22.0)
vainfo: Driver version: VA-API NVDEC driver [direct backend]
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileAV1Profile0            : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain12             : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD
      VAProfileHEVCMain444            : VAEntrypointVLD
      VAProfileHEVCMain444_10         : VAEntrypointVLD
      VAProfileHEVCMain444_12         : VAEntrypointVLD
      4233.247716911 [42848-42848] ../src/vabackend.c:2098              nvTerminate Terminating 0x84a8e0
      4233.248419924 [42848-42848] ../src/vabackend.c:2112              nvTerminate Now have 0 (0 max) instances

@elFarto
Copy link
Owner

elFarto commented Sep 9, 2024

Unfortunately multiple GPUs can pose a problem. Firefox seems to only want to run on the default device, and if that device isn't the NVIDIA one, then even if you set the correct NVD_GPU settings, Firefox won't be able to import the frames that the driver exports.

@caniko
Copy link

caniko commented Sep 9, 2024

I actually got it to work.

It was very hard, but I did it:

__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia VDPAU_DRIVER=nvidia LIBVA_DRIVER_NAME=nvidia VAAPI_DEVICE=/dev/dri/by-path/pci-0000:01:00.0-render MOZ_DISABLE_RDD_SANDBOX=1 NVD_BACKEND=direct floorp

I use floorp, firefox fork

@acdcbyl
Copy link
Author

acdcbyl commented Oct 1, 2024

It's working for me, too.

I actually got it to work.

It was very hard, but I did it:

__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia VDPAU_DRIVER=nvidia LIBVA_DRIVER_NAME=nvidia VAAPI_DEVICE=/dev/dri/by-path/pci-0000:01:00.0-render MOZ_DISABLE_RDD_SANDBOX=1 NVD_BACKEND=direct floorp

I use floorp, firefox fork

@AmmoniumX
Copy link

I actually got it to work.

It was very hard, but I did it:

__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia VDPAU_DRIVER=nvidia LIBVA_DRIVER_NAME=nvidia VAAPI_DEVICE=/dev/dri/by-path/pci-0000:01:00.0-render MOZ_DISABLE_RDD_SANDBOX=1 NVD_BACKEND=direct floorp

I use floorp, firefox fork

It doesn't work for me, sadly, it still tries to use my other DRM device:

❯ __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia VDPAU_DRIVER=nvidia LIBVA_DRIVER_NAME=nvidia VAAPI_DEVICE=/dev/dri/by-path/pci-0000:01:00.0-render MOZ_DISABLE_RDD_SANDBOX=1 NVD_BACKEND=direct NVD_LOG=1 vainfo
Trying display: wayland
       544.630667499 [2759-2759] ../nvidia-vaapi-driver-0.0.12/src/vabackend.c:2188       __vaDriverInit_1_0 Initialising NVIDIA VA-API Driver: 40
       544.630683051 [2759-2759] ../nvidia-vaapi-driver-0.0.12/src/vabackend.c:2197       __vaDriverInit_1_0 Now have 0 (0 max) instances
       544.630710245 [2759-2759] ../nvidia-vaapi-driver-0.0.12/src/vabackend.c:2223       __vaDriverInit_1_0 Selecting Direct backend
       544.695960162 [2759-2759] ../nvidia-vaapi-driver-0.0.12/src/backend-common.c:  31            isNvidiaDrmFd Invalid driver for DRM device: i915
       544.695993021 [2759-2759] ../nvidia-vaapi-driver-0.0.12/src/vabackend.c:2248       __vaDriverInit_1_0 Exporter failed
libva error: /usr/lib/dri/nvidia_drv_video.so init failed
vaInitialize failed with error code 1 (operation failed),exit

@acdcbyl
Copy link
Author

acdcbyl commented Oct 4, 2024

I actually got it to work.
It was very hard, but I did it:

__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia VDPAU_DRIVER=nvidia LIBVA_DRIVER_NAME=nvidia VAAPI_DEVICE=/dev/dri/by-path/pci-0000:01:00.0-render MOZ_DISABLE_RDD_SANDBOX=1 NVD_BACKEND=direct floorp

I use floorp, firefox fork

It doesn't work for me, sadly, it still tries to use my other DRM device:

❯ __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia VDPAU_DRIVER=nvidia LIBVA_DRIVER_NAME=nvidia VAAPI_DEVICE=/dev/dri/by-path/pci-0000:01:00.0-render MOZ_DISABLE_RDD_SANDBOX=1 NVD_BACKEND=direct NVD_LOG=1 vainfo
Trying display: wayland
       544.630667499 [2759-2759] ../nvidia-vaapi-driver-0.0.12/src/vabackend.c:2188       __vaDriverInit_1_0 Initialising NVIDIA VA-API Driver: 40
       544.630683051 [2759-2759] ../nvidia-vaapi-driver-0.0.12/src/vabackend.c:2197       __vaDriverInit_1_0 Now have 0 (0 max) instances
       544.630710245 [2759-2759] ../nvidia-vaapi-driver-0.0.12/src/vabackend.c:2223       __vaDriverInit_1_0 Selecting Direct backend
       544.695960162 [2759-2759] ../nvidia-vaapi-driver-0.0.12/src/backend-common.c:  31            isNvidiaDrmFd Invalid driver for DRM device: i915
       544.695993021 [2759-2759] ../nvidia-vaapi-driver-0.0.12/src/vabackend.c:2248       __vaDriverInit_1_0 Exporter failed
libva error: /usr/lib/dri/nvidia_drv_video.so init failed
vaInitialize failed with error code 1 (operation failed),exit

Here's the thing, vainfo still shows the wrong drm device, but firefox can hardware accelerate after adding the MOZ_DRM_DEVICE and __NV_PRIME_RENDER_OFFLOAD environment variables. This is my method, you can try it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants