ehough / docker-kodi

Dockerized Kodi with audio and video
https://hub.docker.com/r/erichough/kodi/
GNU General Public License v3.0
237 stars 58 forks source link

No VAAPI Intel GPU Acceleration #17

Closed DocMAX closed 3 years ago

DocMAX commented 5 years ago

I don't get gpu acceleration working. I have an Intel GPU which supports x264 hardware decoding. Is there maybe another package missing for this?

I see an error after start:

Failed to open VDPAU backend libvdpau_va_gl.so: cannot open shared object file: No such file or directory

DocMAX commented 5 years ago

Next: I installed apt install libvdpau_va_gl1 package. Getting this now:

---> starting Kodi with command: kodi-standalone
Failure: Module initialization failed
libva info: VA-API version 1.1.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: va_openDriver() returns -1
libva info: VA-API version 1.1.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: va_openDriver() returns -1
Segmentation fault (core dumped)
ehough commented 5 years ago

Post a list of packages installed on your host to pastebin? i.e.g dpkg -l

I'll compare it to packages installed on my system, which also has an Intel GPU, to see if I can see anything missing.

ehough commented 5 years ago

@DocMAX were you able to make any progress on this? Just checking in to see if there's anything I can do from my end to help.

mviereck commented 5 years ago

Maybe try to run with --privileged to check if it makes a difference. Not recommended as a solution, though.


x11docker   --xorg                                 \
            --vt 7                                 \
            --pulseaudio                           \
            --wm=none                              \                
            --gpu                                  \
            --homedir /host/path/to/kodi/home      \
            -- \
            -v /host/path/to/media:/media:ro    \
            --privileged      \ 
            -- \
            erichough/kodi
ehough commented 5 years ago

In addition to @mviereck's idea, you might also want to make sure that you have the i965-va-driver package installed on the host.

Closing this issue for inactivity but feel free to re-open or continue the discussion!

begicj commented 5 years ago

I had the same problems with hardware acceleration on Intel N3050. All drivers are installed on the host (debian 9) and the hardware acceleration of the applications on the host is working normally. Here is log:

.............erichough-kodi-88b82c/share/stderr <== libva info: VA-API version 1.1.0 libva info: VA-API version 1.1.0 libva info: va_getDriverName() returns 0 libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so libva info: va_getDriverName() returns 0 libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so libva info: va_openDriver() returns -1 libva info: va_openDriver() returns -1 Failed to open VDPAU backend libvdpau_i965.so: cannot open shared object file: No such file or directory Failed to open VDPAU backend libvdpau_i965.so: cannot open shared object file: No such file or directory

The issue was fixed by adding:

apt-get upgrade -y && \ apt-get install -y i965-va-driver mesa-utils mesa-utils-extra libxv1 && \

to Dockerfile and building a new docker image with the included drivers.

ehough commented 5 years ago

@begicj Thank you for the report. Could you let us know which version of x11docker you're using? I'd like to try to reproduce this issue locally and investigate further.

begicj commented 5 years ago

x11docker version 5.5.2

mviereck commented 5 years ago

@begicj Thank you for reporting this!

@ehough I had a look at these packages. I'd recommend to install va-driver-all instead of i965-va-driver to get the drivers for AMD and Nvidia, too.

I have updated the x11docker image dependency list accordingly: https://github.com/mviereck/x11docker/wiki/Dependencies#dependencies-in-image

ehough commented 5 years ago

I had a look at these packages. I'd recommend to install va-driver-all instead of i965-va-driver to get the drivers for AMD and Nvidia, too.

I have updated the x11docker image dependency list accordingly: https://github.com/mviereck/x11docker/wiki/Dependencies#dependencies-in-image

I've been hesitant to add those packages to the image because of some recent testing. What's weird is that in my personal HTPC, which uses Intel graphics, I get normal hardware-accelerated video without the va-driver-all or i965-va-driver packages. In other words, the current version of erichough/kodi works fine and the error messages (reported above) appear to be harmless.

I'm going to do some more testing tonight and will report back. Stand by!

mviereck commented 5 years ago

From what I understand, these drivers help to decode videos with the GPU. Displaying the video is already accelerated with the help of the MESA drivers.

wsw70 commented 5 years ago

Adding --priviledged fixed the issue

maps2002 commented 4 years ago

Hi, I also have this error. I was able to clear it after creating a new image that installs va-driver-all and libxv1. Thank you.

lulol commented 4 years ago

@ehough With Linux Mint 20 using Intel graphics, I only get SW decoded x264 video as reported by kodi in the latest version of erichough/kodi and x11docker --version 6.6.2

Although have been planning to migrate my HTPC to CentOS don't know if that would make any difference.

Since the --privileged flag didn't help, as a test attempted to update the packages i965-va-driver mesa-utils mesa-utils-extra libxv1 mentioned by @begicj , from within the container with:

$ docker -it x11docker_X101_erichough-kodi_71114237194 /bin/bash
# apt-get install i965-va-driver
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package i965-va-driver is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'i965-va-driver' has no installation candidate

same with va-driver-all and the rest of packages.

So the only solution for now to get HW decoded video for my setup is to recreate the container adding these packages?

I've very little experience with docker and I'm not sure if that would mean recreating it manually with each update or to get stuck with an old image.

Thank you.

-- Edit: The not available packages error was due to not running an apt-get upgrade command since the Dockerfile removes all the packages lists.

lulol commented 4 years ago

have you seen the --gpu option as well, aside --priviledged

@gsantner I used this with and without the --privileged (spelling!) flag as shown in the @mviereck example and have added the --name option. (Must use sudo because otherwise fails to start for non console users)

sudo x11docker  --name kodi \
            --xorg     \
            --vt 8 \
            --wm=none \
            --pulseaudio                           \
            --gpu                                  \
            --home=/home/lulol/docker/kodi      \
            -- \
              -v /home/lulol/docker/kodimedia:/media:ro \
              --privileged \
            -- \
            erichough/kodi

But after the x11docker WARNINGs I get some -apparently unrelated- errors before the VDPAU one that can't figure what are about (#24 because LM20 uses pulseaudio and the analog audio output I use, seems to work).

(snip)
x11docker WARNING: Sharing device file: /dev/snd

---> starting Kodi with command: kodi-standalone
Connection failure: Connection refused
pa_context_connect() failed: Connection refused
libva info: VA-API version 1.1.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: va_openDriver() returns -1
Failed to open VDPAU backend libvdpau_va_gl.so: cannot open shared object file: No such file or directory

Anyway even if it worked, using --privileged seems scary enough in a container for kodi.

bachulator commented 4 years ago

Hi, struggling with the same issue. Any chance the issue would be resolved?

lulol commented 4 years ago

@bachulator :

So far I've not encountered any issue enabling the hardware-accelerated video since I'm using kodi with these packages included.

bachulator commented 4 years ago

Hi @lulol.

Thanks for the tip. I think I have succeeded to modify the Dockerfile and build modified image. But to be frank I am not entirely sure that worked out as expected. Load seems to be the same and under codec info for multiple sources I still see SW as rendering method. As addition I don't see any VAAPI options under Settings>Player. Do you see similar things in your case or did I miss something. Could you please share the X11docker command you are using to launch your newly built image?

Thanks in advance.

lulol commented 4 years ago

@bachulator I see the VAAPI options under Settings>Player in kodi just fine, and the video decoder uses the hardware acceleration. 2 screenshot001

Did you use the --gpu option with X11docker as well as pointed out by gsantner?

I'm using this with Intel graphics. If that is not your case you may need to use the package va-driver-all instead of i965-va-driver to get the drivers for AMD and Nvidia as mviereck suggested.

The X11docker command I use is a few comments above this, (without the --privileged and with mykodi instead).

bachulator commented 4 years ago

@lulol

Hmm. I obviously missing something here.

Ok. I have intel video since with bare-metal installation I have VAAPI option and decoding is HW based with i965-va-driver .

My DockerFile looks like original except last part ... apt-get update && \ apt-get install -y --no-install-recommends $packages && \ apt-get upgrade -y && \ apt-get install -y va-driver-all mesa-utils mesa-utils-extra libxv1 && \ apt-get -y --purge autoremove && \ rm -rf /var/lib/apt/lists/* ...

I start building and tagging process: build --tag bachkodi . > build

Build process finishes successfully and from the logs I do see va drivers installation.
Preparing to unpack .../6-va-driver-all_2.1.0-3_amd64.deb ... Unpacking va-driver-all:amd64 (2.1.0-3) ... Setting up i965-va-driver:amd64 (2.1.0-0ubuntu1) ... Setting up mesa-va-drivers:amd64 (20.0.8-0ubuntu1~18.04.1) ... Setting up libgles2:amd64 (1.0.0-2ubuntu2.3) ... Setting up libwayland-egl1:amd64 (1.16.0-1ubuntu1.1~18.04.3) ... Setting up mesa-utils-extra (8.4.0-1) ... Setting up va-driver-all:amd64 (2.1.0-3) .

I am X11 user so my kodi start script looks like this: /usr/bin/x11docker --name="Kodi" --pulseaudio --hostnet --gpu --homedir /home/bach/ bachkodi:latest

But I still don't see any HW decoding options below are kodi log docker vs bare-metal both isntances are running from the same config basis: Docker: 020-09-07 05:27:46.493 T:139681163245696 NOTICE: Checking resolution 16 2020-09-07 05:27:46.528 T:139681163245696 NOTICE: Using visual 0x21 2020-09-07 05:27:46.572 T:139681163245696 NOTICE: Previous line repeats 1 times. 2020-09-07 05:27:46.572 T:139681163245696 NOTICE: VDPAU::CreateContext - creating decoder context 2020-09-07 05:27:46.573 T:139681163245696 NOTICE: vdp_device = 0x00000000 vdp_st = 0x00000001 2020-09-07 05:27:46.573 T:139681163245696 ERROR: (VDPAU) unable to init VDPAU - vdp_st = 0x1. Falling back. 2020-09-07 05:27:46.574 T:139681163245696 NOTICE: GL_VENDOR = Intel Open Source Technology Center 2020-09-07 05:27:46.574 T:139681163245696 NOTICE: GL_RENDERER = Mesa DRI Intel(R) Iris(R) Plus Graphics 650 (Kaby Lake GT3e) (KBL GT3) 2020-09-07 05:27:46.574 T:139681163245696 NOTICE: GL_VERSION = 3.0 Mesa 20.0.8 2020-09-07 05:27:46.574 T:139681163245696 NOTICE: GL_SHADING_LANGUAGE_VERSION = 1.30 vs Bare-metal

2020-09-07 08:34:53.561 T:139670312399744 NOTICE: VAAPI::Close - closing decoder context 2020-09-07 08:34:53.564 T:139670312399744 NOTICE: GL_VENDOR = Intel 2020-09-07 08:34:53.564 T:139670312399744 NOTICE: GL_RENDERER = Mesa Intel(R) Iris(R) Plus Graphics 650 (Kaby Lake GT3e) (KBL GT3) 2020-09-07 08:34:53.564 T:139670312399744 NOTICE: GL_VERSION = 4.6 (Core Profile) Mesa 20.0.8 2020-09-07 08:34:53.564 T:139670312399744 NOTICE: GL_SHADING_LANGUAGE_VERSION = 4.60

lulol commented 4 years ago

Did you change to the Expert options in kodi to show the VAAPI options? But anyway by default all should be enabled so that won't limit the hardware decoding.

You may try the --xorg and/or --desktop options in x11docker, but really I've no clue.

Other than that, I'm sorry that don't know why fails to init the vdp_device in the container since it seems to work in your system. May be others have any idea?

bachulator commented 4 years ago

@lulol

I did changed to Expert, and still no options available.

Will try the --desktop option, to see if that helps, --xorg is not working for me since I am starting the script from running X11 session.

Thanks for support @lulol , hopefully will find the root cause for the issue.

bachulator commented 4 years ago

To whoever it concerns. I have managed to solve the issue by rebuilding the docker image to the same OS version as host by changing to FROM ubuntu:focal you will need to change/remove some packages from the Dockerfile sine they might not be available for your OS version.

I suspect the issue was related to different VAAPI version in focal and bionic (1.7.X vs 1.1) having them on the same version seems to solve the issue.

Cheers, bachulator

mviereck commented 4 years ago

I suspect the issue was related to different VAAPI version in focal and bionic (1.7.X vs 1.1) having them on the same version seems to solve the issue.

Thank you for pointing that out! A hint is added to x11docker wiki.

ehough commented 3 years ago

Version 3 of this image is now available. In addition to running on Ubuntu Focal, it also includes the va-driver-all package, so everyone (Intel, Nvidia, etc.) should now have out-of-the-box hardware-accelerated video.

Closing this issue, but please feel free to open up a new issue or post in the discussion forum if you're still having any trouble.

RobertusIT commented 2 years ago

I have a very weird issue:

gpu accelleration, works only few seconds, 8 seconds, then stopped working and cpu come up.

Why?

How can i fix it ? from intel_gpu_top i can see render in use and video, but few seconds. Need a video or this issue is know and there is a fix ?

mviereck commented 2 years ago

x11docker recently got some fixes for VA-API and VDPAU video decoding support. Compare https://github.com/mviereck/x11docker/issues/443#issuecomment-1144800334 It turned out that different VA-API versions of host and container seem not to matter. Instead, x11docker has to set some environment variables so the container uses the correct driver files.

Tests reports are appreciated! The fix needs to be tested on several different GPU setups.

This might improve docker-kodi a lot and fix some issues mentioned above.

Version 3 of this image is now available. In addition to running on Ubuntu Focal, it also includes the va-driver-all package, so everyone (Intel, Nvidia, etc.) should now have out-of-the-box hardware-accelerated video.

It might make sense to add vdpau-driver-all, too. VDPAU has the same goal as VA-API, originally they were developed for different GPUs. I am not sure if kodi uses one or the other or might need support of both depending on the GPU.