microsoft / microsoft/WSL

VA-API does not work in Ubuntu 24.04

Open
#11,838 12 comments 4 reactions 0 assignees View on GitHub
GPU
Dominant language
C++
Stars
33.7k
Forks
1.8k
Avg merge
3d 17h
Merged PRs (30d)
116

Description

### 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?

- [X] 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](https://github.com/microsoft/WSL/issues/11837) 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](https://devblogs.microsoft.com/commandline/d3d12-gpu-video-acceleration-in-the-windows-subsystem-for-linux-now-available/), 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](https://github.com/microsoft/WSL/issues/9662).

# Workaround
In order for me to workaround this issue, I took inspiration from the other [issue ](https://github.com/microsoft/WSL/issues/9662) 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_

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the listed VA-API setup on Ubuntu 24.04 with the WSL 2 kernel and the GStreamer command from the issue, then compare the `vainfo --display drm` output for Mesa 24.0.9 and 23.2.1. Done means the example works with the Ubuntu 24.04 packages without adding Jammy repositories or downgrading Mesa.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, ubuntu
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.