Using hardware acceleration in docker

server-docker

#1

I'm trying to use hardware acceleration inside my docker container (using wernight/plex-media-server:autoupdate image) and it fails.

I have a AMD HD6950 and an Intel i7-2700k iGPU. I know that plex will not work on the AMD card, but I'd like to use the iGPU.
Note that my motherboard does not have an output for the iGPU.

Here is the output of sudo lshw -c video on the host and inside the container:

*-display
description: VGA compatible controller
product: Cayman PRO [Radeon HD 6950]
vendor: Advanced Micro Devices, Inc. [AMD/ATI]
physical id: 0
bus info: pci@0000:04:00.0
version: 00
width: 64 bits
clock: 33MHz
capabilities: pm pciexpress msi vga_controller bus_master cap_list rom
configuration: driver=radeon latency=0
resources: irq:50 memory:e0000000-efffffff memory:f7d20000-f7d3ffff ioport:d000(size=256) memory:f7d00000-f7d1ffff
*-display
description: Display controller
product: 2nd Generation Core Processor Family Integrated Graphics Controller
vendor: Intel Corporation
physical id: 2
bus info: pci@0000:00:02.0
version: 09
width: 64 bits
clock: 33MHz
capabilities: msi pm bus_master cap_list
configuration: driver=i915 latency=0
resources: irq:53 memory:f7000000-f73fffff memory:d0000000-dfffffff ioport:f000(size=64)

Here is the output of lsmod | grep i915 on the host:

i915 1232896 0
i2c_algo_bit 16384 2 i915,radeon
drm_kms_helper 155648 2 i915,radeon
drm 364544 5 ttm,i915,drm_kms_helper,radeon
video 40960 2 i915,asus_wmi

Here is the output of lspci | grep VGA on the host and inside the container:

04:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Cayman PRO [Radeon HD 6950]

Inside the container, vainfo gives me the following output:

vainfo

error: XDG_RUNTIME_DIR not set in the environment.
error: can't connect to X server!
libva info: VA-API version 0.39.4
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/gallium_drv_video.so
libva info: va_openDriver() returns -1
vaInitialize failed with error code -1 (unknown libva error),exit

My container has --device=/dev/dri:/dev/dri and I also did a chmod -R 777 /dev/dri (I know it's bad practice, just trying to test things out).

If anyone has any clue, I'd really appreciate some help!

Thanks


#2

I finally managed to make it work by explicitly mapping the correct device, i.e. I mapped the Intel iGPU only (since AMD cards are not supported).

To do so, simply use --device=/dev/dri/card1:/dev/dri/card0 --device /dev/dri/renderD129:/dev/dri/renderD128
Of course, adapt the number avec cardX and renderDXYZ to match your system.


#3

Hi. I’m using plex in a docker with a intel j3455 nas server running openmediavault. I can’t make hardware acceleration working with this configuration. Before i had plex in OMV plugin and it worked with H.A. I’m a plex pass user of course.
Thanks


#4

I just found this in plex articles
Can I use Hardware-Accelerated Streaming inside of Docker?
At this time, we do not formally support hardware acceleration inside of a Docker container. Some users of Docker (on Linux only) have been able to accomplish this by adding platform-specific custom configurations that expose host hardware to the container.

Somebody knows this openmediavault “platform-specific custom configurations that expose host hardware to the container”?


#5

@gravufo I PMed you as well but ill post this here too.

Think you can help me map my Nvidia 1050 to let Plex use HW acceleration? The command you used sudo lshw -c video, you said you ran it inside docker. What command did you use to get into docker? Did you just run sudo lshw -c video in terminal without anything else?

Can you expand on this? “Of course, adapt the number avec cardX and renderDXYZ to match your system.”


#6

Hey there,
I’ll answer here since your questions are of general knowledge and can help anyone.
There are multiple ways to execute commands inside your docker container. You can simply docker exec <container name or ID> 'command' or attach to the container using docker attach <container name or ID> /bin/bash.
I suggest you get familiar with docker and how it works before going into deeper setups. The reference is your friend: https://docs.docker.com/engine/reference/commandline/docker/

As for your second question, if you do ls /dev/dri you’ll see that you can have multiple card*, controlD* and renderD*. You have to select the one that matches the graphics card you want to use. Unfortunately, it’s not that easy to figure out which is which, but you can search on the Internet to figure it out. Of course, if you only have one video device, then you shouldn’t have this issue and you should be able to simply mount /dev/dri inside your container.

Hope this helps!


#7

so docker exec plex ‘sudo lshw -c video’

and I have a video chip for the server and then the 1050. I dont see where in the logs you posted is the controlD or renderD or did you not post that?


#8

I did not post any logs. My post was clear enough. You need to execute ls /dev/dri on your host to figure out which video devices are available on your machine. Then, you need to figure out which one is the one you want to mount inside your docker container. In my case, I had to add the following options in my docker run command: --device=/dev/dri/card1:/dev/dri/card0 --device=/dev/dri/renderD129:/dev/dri/renderD128


#9

I installed the native plugin as well still it doesn’t seem to use hw acceleration. :frowning:

Are there any specific steps you took to fix the issue?