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

VA-API does not work in Ubuntu 24.04 #11838

Open
1 of 2 tasks
sikhness opened this issue Jul 25, 2024 · 9 comments
Open
1 of 2 tasks

VA-API does not work in Ubuntu 24.04 #11838

sikhness opened this issue Jul 25, 2024 · 9 comments
Labels

Comments

@sikhness
Copy link

sikhness commented Jul 25, 2024

Windows Version

Microsoft Windows [Version 10.0.20348.2582] (Windows Server 2022)

WSL Version

2.2.4.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

6.6.36.3-microsoft-standard-WSL2

Distro Version

Ubuntu 24.04

Other Software

No response

Repro Steps

  1. Follow the workaround as per this issue to get /dev/dri to show up in Ubuntu 24.04 (when using the new 6.6 Kernel)
  2. Run sudo apt install vainfo mesa-va-drivers ffmpeg gstreamer1.0-plugins-bad gstreamer1.0-tools gstreamer1.0-vaapi
  3. Run export LIBVA_DRIVER_NAME=d3d12
  4. Run the first example from this blog, which is gst-launch-1.0 -v videotestsrc num-buffers=250 ! video/x-raw,width=1920,height=1200 ! vaapipostproc ! vaapih264enc ! filesink location=~/wsl_test.h264

Expected Behavior

You should see an increasing progress indicator at the bottom of a sample video file being generated using the GPU through VA-API.

Actual Behavior

What actually happens is the EXACT same issue as what is reported here.

Workaround

In order for me to workaround this issue, I took inspiration from the other issue that posted the same error.

I realized that Ubuntu 24.04 by default has Mesa at 24.0.9 as shown by the output of vainfo --display drm:

libva info: VA-API version 1.20.0
Xlib:  extension "DRI2" missing on display ":0".
libva info: User environment variable requested driver 'd3d12'
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/d3d12_drv_video.so
libva info: Found init function __vaDriverInit_1_20
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.20 (libva 2.12.0)
vainfo: Driver version: Mesa Gallium driver 24.0.9-0ubuntu0.1 for D3D12 (AMD Radeon RX 780 Graphics)
vainfo: Supported profile and entrypoints
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointEncSlice
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD
      VAProfileAV1Profile0            : VAEntrypointVLD
      VAProfileAV1Profile0            : VAEntrypointEncSlice
      VAProfileNone                   : VAEntrypointVideoProc

I then proceeded to add all of Ubuntu Jammy (22.04) older repositories into my Ubuntu 24.04:

sudo apt-add-repository "deb http://archive.ubuntu.com/ubuntu/ jammy main restricted universe multiverse"
sudo apt-add-repository "deb http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted universe multiverse"
sudo apt-add-repository "deb http://archive.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse"
sudo apt-add-repository "deb http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse"

Then I downgraded mesa-va-driver to version 23.2.1 which is the default one available for Ubuntu 22.04 using sudo apt install mesa-va-drivers=23.2.1-1ubuntu3.1~22.04.2, as shown in the new output of vainfo --display drm:

libva info: VA-API version 1.20.0
libva info: User environment variable requested driver 'd3d12'
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/d3d12_drv_video.so
libva info: Found init function __vaDriverInit_1_14
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.20 (libva 2.12.0)
vainfo: Driver version: Mesa Gallium driver 23.2.1-1ubuntu3.1~22.04.2 for D3D12 (AMD Radeon RX 780 Graphics)
vainfo: Supported profile and entrypoints
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointEncSlice
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD
      VAProfileAV1Profile0            : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc

After this change, the same example I initially ran started to work again! It seems like there is a problem with the way WSL2 interacts with the new Mesa version that is default in Ubuntu 24.04.

Diagnostic Logs

No response

Copy link

Logs are required for review from WSL team

If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'.
Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

How to collect WSL logs

Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1

The script will output the path of the log file once done.

If this is a networking issue, please use collect-networking-logs.ps1, following the instructions here

Once completed please upload the output files to this Github issue.

Click here for more info on logging
If you choose to email these logs instead of attaching to the bug, please send them to wsl-gh-logs@microsoft.com with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with '/emailed-logs'.

View similar issues

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@sikhness
Copy link
Author

Copy link

Diagnostic information
.wslconfig found
	Custom kernel found: 'C:\Users\Administrator\kernel\bzImage'
Detected appx version: 2.2.4.0

@elsaco
Copy link

elsaco commented Jul 26, 2024

@sikhness latest WSL releases support kernel modules, however vgem is not automatically loaded. Run sudo modprobe vgem to load the Virtual GEM provider and you'll notice [drm] Initialized vgem 1.0.0 20120112 for vgem on minor 0 in the dmesg output.

elsaco@toto:~$ LIBVA_DRIVER_NAME=d3d12 vainfo --display drm
libva info: VA-API version 1.20.0
libva info: User environment variable requested driver 'd3d12'
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/d3d12_drv_video.so
libva info: Found init function __vaDriverInit_1_20
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.20 (libva 2.12.0)
vainfo: Driver version: Mesa Gallium driver 24.0.9-0ubuntu0.1 for D3D12 (NVIDIA RTX A4000)
vainfo: Supported profile and entrypoints
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointEncSlice
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD
      VAProfileAV1Profile0            : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc

Host info:

elsaco@toto:~$ hostnamectl
 Static hostname: toto
       Icon name: computer-container
         Chassis: container
      Machine ID: 494d2cccd1fa4b159c1887257a896535
         Boot ID: bf92a5c45b214cbc8515c8811cf1abc6
  Virtualization: wsl
Operating System: Ubuntu 24.04 LTS
          Kernel: Linux 6.6.36.3-microsoft-standard-WSL2
    Architecture: x86-64

@sikhness
Copy link
Author

sikhness commented Jul 26, 2024

Hi @elsaco, thanks for your comment! I think you meant to reply with your comment in my other issue however, which is specific around the VGEM module. My point there was just that VGEM might want to be turned on automatically for WSL2 without having to manually load it everytime for VA-API use cases.

For this issue however, I'm referring to the fact that in Ubuntu 24.04 with VGEM already loaded, the default mesa drivers (24.0.9), don't seem to work with WSL2 and D3D12 and throw those weird errors as mentioned in the ticket above. If I manually downgrade the mesa drivers to 23.2.1 (the default one from Ubuntu 22.04), it all starts working again.

So there seems to be a bug either in the mesa drivers or something within WSL2 that needs to be fixed for the latest drivers to work. Basically Ubuntu 24.04 will not work with WSL2 VA-API by default otherwise it seems.

@sivileri
Copy link

sivileri commented Aug 7, 2024

Hi @sikhness, I was able to repro this issue on the latest mesa/main source, the problem is that PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE was removed as supported by VAAPI on d3d12 which produced gstreamer to fail negotiating the pipeline caps when asking for support for that profile.

This mesa pull request fixes that and now the gstreamer command line works again. Please let me know if you still see the issue after applying the patch.

temeraire-cx pushed a commit to chaotic-cx/mesa-mirror that referenced this issue Aug 7, 2024
…ELINE as not supported"

This reverts commit d6bb4dd.
Fixes: d6bb4dd ("d3d12: Video Encode - Remove PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE as not supported")

PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE is necessary for some scenarios like the example below
described in microsoft/WSL#11838

gst-launch-1.0 -v videotestsrc num-buffers=250 !
    video/x-raw,width=1920,height=1200 !
    vaapipostproc !
    vaapih264enc !
    filesink location=~/wsl_test.h264

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30548>
temeraire-cx pushed a commit to chaotic-cx/mesa-mirror that referenced this issue Aug 14, 2024
…ELINE as not supported"

This reverts commit d6bb4dd.
Fixes: d6bb4dd ("d3d12: Video Encode - Remove PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE as not supported")

PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE is necessary for some scenarios like the example below
described in microsoft/WSL#11838

gst-launch-1.0 -v videotestsrc num-buffers=250 !
    video/x-raw,width=1920,height=1200 !
    vaapipostproc !
    vaapih264enc !
    filesink location=~/wsl_test.h264

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30548>
(cherry picked from commit a0f1a70)
temeraire-cx pushed a commit to chaotic-cx/mesa-mirror that referenced this issue Aug 14, 2024
…ELINE as not supported"

This reverts commit d6bb4dd.
Fixes: d6bb4dd ("d3d12: Video Encode - Remove PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE as not supported")

PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE is necessary for some scenarios like the example below
described in microsoft/WSL#11838

gst-launch-1.0 -v videotestsrc num-buffers=250 !
    video/x-raw,width=1920,height=1200 !
    vaapipostproc !
    vaapih264enc !
    filesink location=~/wsl_test.h264

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30548>
(cherry picked from commit a0f1a70)
@sunflower-knight
Copy link

sunflower-knight commented Aug 19, 2024

Use mesa 24.2 update on 2024 08 14

I have try the new version mesa24.2 in ubuntu22.04;
Now I can use st-launch-1.0 -v videotestsrc num-buffers=250 ! video/x-raw,width=1920,height=1200 ! vaapipostproc ! vaapih264enc ! filesink location=~/wsl_test.h264 ;

But Notice : use the ppa below

sudo add-apt-repository ppa:kisak/kisak-mesa
sudo apt update

some people use oibaf ppa to use the newest version of mesa , but actualy newest version is mesa24.3 , this version don't accept the fixed patch ; And kisak-mesa support mesa24.2 , update on 2024 08 14 , it accept the patch ;

sudo add-apt-repository ppa:oibaf/graphics-drivers
sudo apt update

I try the new version becaues some application need opengl4.3 4.4 4.5 . But ubuntu22.04 's initial mesa version support opengl4.3 ...

@sanctimon
Copy link

Actually, even if mesa dozen drivers work, vainfo --display drm --device /dev/dri/renderD128 still does not work no matter what.

vainfo
libva info: VA-API version 1.20.0
libva error: vaGetDriverNames() failed with unknown libva error
vaInitialize failed with error code -1 (unknown libva error),exit
vainfo --display drm --device /dev/dri/renderD128
Failed to open the given device!

@MasterCATZ
Copy link

MasterCATZ commented Mar 22, 2025

how did you get VA-API version 1.20.0 ?

aio@aio:~$ vainfo
Trying display: wayland
Trying display: x11
libva info: VA-API version 1.16.0
libva info: Trying to open /opt/amdgpu/lib/x86_64-linux-gnu/dri/radeonsi_drv_video.so
libva info: va_openDriver() returns -1
vaInitialize failed with error code -1 (unknown libva error),exit
aio@aio:~$ 
AMD Radeon RX 6800 XT (radeonsi, navi21, LLVM 19.1.1, DRM 3.59, 6.12.3-061203-generic)
  4.6 (Compatibility Profile) Mesa 25.0~git2503210600.a801a4~oibaf~o (git-a801a4a 2025-03-21 oracular

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

No branches or pull requests

7 participants