# Hardware Transcoding support in docker container isnt working

**URL:** <https://forums.plex.tv/t/hardware-transcoding-support-in-docker-container-isnt-working/804230>\
**Category:** Plex Media Server\
**Tags:** server-linux, server-docker\
**Created:** [August 12, 2022, 6:51pm UTC](https://forums.plex.tv/t/hardware-transcoding-support-in-docker-container-isnt-working/804230 "2022-08-12T18:51:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![numark1](https://avatars.discourse-cdn.com/v4/letter/n/49beb7/32.png) [@numark1](https://forums.plex.tv/u/numark1)\
**Post date:** [August 12, 2022, 6:51pm UTC](https://forums.plex.tv/t/hardware-transcoding-support-in-docker-container-isnt-working/804230/1 "2022-08-12T18:51:53Z")

</div>

Hi all,

I have the following setup and try to enable hw encoding.

\*\*System: Lenovo P330 Tiny with 8G RAM + i5-8500, Quadro P400 and 256GB \*\*  
**OS: Fresh installation of Ubuntu 22.04.1 LTS**  
**GPU Driver: Ubuntu proposed the installation of the nvidia-515.65.01 driver which I checked**

After clean installation and a full apt update / upgrade run followed by fwupdmgr, I installed docker engine and docker compose. nvidia-smi looks good for me on the host system.

```auto
root@pve2:/home/numark1# nvidia-smi
Fri Aug 12 12:21:17 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 515.65.01 Driver Version: 515.65.01 CUDA Version: 11.7 |
|-------------------------------+----------------------+----------------------+
| 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 **Quadro P400** Off | 00000000:01:00.0 Off | N/A |
| 54% 51C P0 N/A / N/A | 0MiB / 2048MiB | 2% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+

```

After that I installed the nvidia-toolkit and veryfied it with the nvidia dummy container:

```auto
root@pve2:/home/numark1# docker run --rm --gpus all nvidia/cuda:11.0.3-base-ubuntu20.04 nvidia-smi
Unable to find image 'nvidia/cuda:11.0.3-base-ubuntu20.04' locally
11.0.3-base-ubuntu20.04: Pulling from nvidia/cuda
d7bfe07ed847: Pull complete
75eccf561042: Pull complete
191419884744: Pull complete
a17a942db7e1: Pull complete
16156c70987f: Pull complete
Digest: sha256:57455121f3393b7ed9e5a0bc2b046f57ee7187ea9ec562a7d17bf8c97174040d
Status: Downloaded newer image for nvidia/cuda:11.0.3-base-ubuntu20.04
Fri Aug 12 13:06:07 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 515.65.01 Driver Version: 515.65.01 CUDA Version: 11.7 |
|-------------------------------+----------------------+----------------------+
| 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 Quadro P400 Off | 00000000:01:00.0 Off | N/A |
| 47% 49C P0 N/A / N/A | 0MiB / 2048MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+

```

I thenk installed the [linuxserver.io](http://linuxserver.io) container, enabled nvidia runtime and set up the env variables for thge hardware.

```auto
version: "3.9"
services:
  plex:
    image: lscr.io/linuxserver/plex:latest
    container_name: plex
    network_mode: host
    runtime: nvidia
    environment:
      - PUID=1000
      - PGID=1000
      - VERSION=docker
      - PLEX_CLAIM=claim-XYZ
      - NVIDIA_VISIBLE_DEVICES=GPU-00000000-aaaa-bbbb-cccc-000000000000
    volumes:
      - /home/numark1/docker/data_plex/config:/config
      - /home/numark1/docker/data_plex/tv:/tv
      - /home/numark1/docker/data_plex/movies:/movies
    restart: unless-stopped

```

Additionally I executed nvidia-smi inside the container which was sucessfull.

 ![image](https://global.discourse-cdn.com/plex/original/4X/4/6/5/465aa7413eccd210afa0a34abff6e5eb0452981f.png)

I have a Plex Pass Lifetime and the hw transcode option is enabled in the plex settings.

Whenever something needs transcoding CPU usage spikes to 90% and the stream is stuttering, this hardware setup was running before without the docker part. At the moment I dont know what I missed or what can check ?

BR Daniel

Server Version#:  
Player Version#:

---

<div class="post-metadata">

**Author:** ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)\
**Post date:** [August 12, 2022, 7:05pm UTC](https://forums.plex.tv/t/hardware-transcoding-support-in-docker-container-isnt-working/804230/2 "2022-08-12T19:05:32Z")

</div>

Is the Plex user a member of the group which owns /dev/dri ?  
(This is a common oversight)

---

<div class="post-metadata">

**Author:** ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)\
**Post date:** [August 12, 2022, 9:49pm UTC](https://forums.plex.tv/t/hardware-transcoding-support-in-docker-container-isnt-working/804230/3 "2022-08-12T21:49:36Z")

</div>

FWIW:

1. PMS looks for the `renderD128` node.
2. With the Nvidia drivers installed, the P2200 is visible in /dev/dri
3. I grant device-level access in the container:

```auto
sudo docker stop plex
sudo docker rm plex

# Remove old image if exists
Image="$(sudo docker images | grep -i plex | awk '{print $3}')"

if ["$Image" != ""]; then

  sudo docker stop plex
  sudo docker stop plex
  sudo docker rm plex
  sudo docker rmi -f $Image
fi

sudo docker run \
-d \
--name plex \
--network=host \
-e TZ="EST" \
-e LANG="en_US.UTF-8" \
-e PLEX_UID=1000 \
-e PLEX_GID=1000 \
-e PUID=1000 \
-e PGID=1000 \
-h dockerplex \
-v /sata/dockerplex:/config \
-v /sata/dockerplex/tmp:/tmp \
-v /sata/dockerplex/transcode:/transcode \
-v /vie:/data \
--device=/dev/dri:/dev/dri \
plexinc/pms-docker:plexpass

#docker start plex
#docker update --restart=unless-stopped plex

```

---

<div class="post-metadata">

**Author:** ![numark1](https://avatars.discourse-cdn.com/v4/letter/n/49beb7/32.png) [@numark1](https://forums.plex.tv/u/numark1)\
**Post date:** [August 13, 2022, 10:37am UTC](https://forums.plex.tv/t/hardware-transcoding-support-in-docker-container-isnt-working/804230/4 "2022-08-13T10:37:13Z")

</div>

So I added the user plex is running (ID=1000) to the root group but that didnt changed something.

Regarding the device assignment, I was pretty sure that the /dev/dri is only used with integrated graphics and if you have the nvidia-toolkit installed they expose everything via the nvidia runtime into the container so you dont have to add the device variable into your compose file. But I tried it also with the following setup:

```auto
version: "3.9"
services:
  plex:
    image: lscr.io/linuxserver/plex:latest
    container_name: plex
    network_mode: host
    runtime: nvidia
    environment:
      - PUID=1000
      - PGID=1000
      - VERSION=docker
      - NVIDIA_VISIBLE_DEVICES=all
    volumes:
      - /home/numark1/docker/data_plex/config:/config
      - /home/numark1/docker/data_plex/series:/tv
      - /home/numark1/docker/data_plex/movies:/movies
    devices:
      - /dev/dri:/dev/dri
    restart: unless-stopped

```

But this also didnt worked, a bit frustrating. Do you know for what I can search in the logs what need to be triggered or what I need to have a look on ?

---

<div class="post-metadata">

**Author:** ![numark1](https://avatars.discourse-cdn.com/v4/letter/n/49beb7/32.png) [@numark1](https://forums.plex.tv/u/numark1)\
**Post date:** [August 13, 2022, 11:22am UTC](https://forums.plex.tv/t/hardware-transcoding-support-in-docker-container-isnt-working/804230/5 "2022-08-13T11:22:31Z")

</div>

I had a look at the logs and found the following lines which tell me that nvenc is report that the different codes arent available for transcoding.

```auto
Aug 13, 2022 10:53:28.154 [0x7f9360470b38] DEBUG - [Req#13c/Transcode] Codecs: testing h264_nvenc (encoder)
Aug 13, 2022 10:53:28.154 [0x7f9360470b38] DEBUG - [Req#13c/Transcode] Codecs: hardware transcoding: testing API nvenc
Aug 13, 2022 10:53:28.456 [0x7f9360470b38] ERROR - [Req#13c/Transcode] [FFMPEG] - The minimum required Nvidia driver for nvenc is 418.30 or newer
Aug 13, 2022 10:53:28.456 [0x7f9360470b38] WARN - [Req#13c/Transcode] Codecs: avcodec_open2 returned -1 for encoder 'h264_nvenc'
Aug 13, 2022 10:53:28.540 [0x7f9360470b38] DEBUG - [Req#13c/Transcode] Codecs: testing h264_nvenc (encoder)
Aug 13, 2022 10:53:28.540 [0x7f9360470b38] DEBUG - [Req#13c/Transcode] Codecs: hardware transcoding: testing API nvenc
Aug 13, 2022 10:53:28.581 [0x7f9360470b38] ERROR - [Req#13c/Transcode] [FFMPEG] - The minimum required Nvidia driver for nvenc is 418.30 or newer
Aug 13, 2022 10:53:28.581 [0x7f9360470b38] WARN - [Req#13c/Transcode] Codecs: avcodec_open2 returned -1 for encoder 'h264_nvenc'
Aug 13, 2022 10:53:48.550 [0x7f9366e25b38] DEBUG - [Req#230/Transcode] Codecs: testing h264_nvenc (encoder)
Aug 13, 2022 10:53:48.550 [0x7f9366e25b38] DEBUG - [Req#230/Transcode] Codecs: hardware transcoding: testing API nvenc
Aug 13, 2022 10:53:48.623 [0x7f9366e25b38] ERROR - [Req#230/Transcode] [FFMPEG] - The minimum required Nvidia driver for nvenc is 418.30 or newer
Aug 13, 2022 10:53:48.623 [0x7f9366e25b38] WARN - [Req#230/Transcode] Codecs: avcodec_open2 returned -1 for encoder 'h264_nvenc'
Aug 13, 2022 10:53:48.754 [0x7f9366e25b38] DEBUG - [Req#230/Transcode] Codecs: testing h264_nvenc (encoder)
Aug 13, 2022 10:53:48.754 [0x7f9366e25b38] DEBUG - [Req#230/Transcode] Codecs: hardware transcoding: testing API nvenc
Aug 13, 2022 10:53:48.803 [0x7f9366e25b38] ERROR - [Req#230/Transcode] [FFMPEG] - The minimum required Nvidia driver for nvenc is 418.30 or newer
Aug 13, 2022 10:53:48.803 [0x7f9366e25b38] WARN - [Req#230/Transcode] Codecs: avcodec_open2 returned -1 for encoder 'h264_nvenc'
Aug 13, 2022 10:53:48.897 [0x7f9366e25b38] DEBUG - [Req#230/Transcode] Codecs: testing h264_nvenc (encoder)
Aug 13, 2022 10:53:48.897 [0x7f9366e25b38] DEBUG - [Req#230/Transcode] Codecs: hardware transcoding: testing API nvenc
Aug 13, 2022 10:53:48.959 [0x7f9366e25b38] ERROR - [Req#230/Transcode] [FFMPEG] - The minimum required Nvidia driver for nvenc is 418.30 or newer
Aug 13, 2022 10:53:48.959 [0x7f9366e25b38] WARN - [Req#230/Transcode] Codecs: avcodec_open2 returned -1 for encoder 'h264_nvenc'
Aug 13, 2022 10:53:49.068 [0x7f9366e25b38] DEBUG - [Req#230/Transcode] Codecs: testing h264_nvenc (encoder)
Aug 13, 2022 10:53:49.069 [0x7f9366e25b38] DEBUG - [Req#230/Transcode] Codecs: hardware transcoding: testing API nvenc
Aug 13, 2022 10:53:49.135 [0x7f9366e25b38] ERROR - [Req#230/Transcode] [FFMPEG] - The minimum required Nvidia driver for nvenc is 418.30 or newer
Aug 13, 2022 10:53:49.135 [0x7f9366e25b38] WARN - [Req#230/Transcode] Codecs: avcodec_open2 returned -1 for encoder 'h264_nvenc'
Aug 13, 2022 10:53:49.254 [0x7f9366e25b38] DEBUG - [Req#230/Transcode] Codecs: testing h264_nvenc (encoder)
Aug 13, 2022 10:53:49.254 [0x7f9366e25b38] DEBUG - [Req#230/Transcode] Codecs: hardware transcoding: testing API nvenc
Aug 13, 2022 10:53:49.300 [0x7f9366e25b38] ERROR - [Req#230/Transcode] [FFMPEG] - The minimum required Nvidia driver for nvenc is 418.30 or newer
Aug 13, 2022 10:53:49.300 [0x7f9366e25b38] WARN - [Req#230/Transcode] Codecs: avcodec_open2 returned -1 for encoder 'h264_nvenc'
Aug 13, 2022 10:53:49.396 [0x7f9366e25b38] DEBUG - [Req#230/Transcode] Codecs: testing h264_nvenc (encoder)
Aug 13, 2022 10:53:49.396 [0x7f9366e25b38] DEBUG - [Req#230/Transcode] Codecs: hardware transcoding: testing API nvenc
Aug 13, 2022 10:53:49.462 [0x7f9366e25b38] ERROR - [Req#230/Transcode] [FFMPEG] - The minimum required Nvidia driver for nvenc is 418.30 or newer
Aug 13, 2022 10:53:49.462 [0x7f9366e25b38] WARN - [Req#230/Transcode] Codecs: avcodec_open2 returned -1 for encoder 'h264_nvenc'

```

This looks like the same error mentioned here: [running ffmpeg with nvenc inside nvidia docker - Stack Overflow](https://stackoverflow.com/questions/52062888/running-ffmpeg-with-nvenc-inside-nvidia-docker) and my assumption is that not all codecs are available inside the container.

I added the following lines to the env variables and remove the image to have a image from scratch but its still not working.

```
  - NVIDIA_VISIBLE_DEVICES=all
  - NVIDIA_DRIVER_CAPABILITIES=all

```

---

<div class="post-metadata">

**Author:** ![numark1](https://avatars.discourse-cdn.com/v4/letter/n/49beb7/32.png) [@numark1](https://forums.plex.tv/u/numark1)\
**Post date:** [August 14, 2022, 1:12pm UTC](https://forums.plex.tv/t/hardware-transcoding-support-in-docker-container-isnt-working/804230/6 "2022-08-14T13:12:14Z")

</div>

> [@numark1](#):
>
> ```auto
> Aug 13, 2022 10:53:48.897 [0x7f9366e25b38] DEBUG - [Req#230/Transcode] Codecs: testing h264_nvenc (encoder)
> 
> ```

What a ride, finally it is working.

So the next problem was that after reading some rumors about the fact that the nvidia-driver-515-server is not exposing all the necessary codes into the container, I tried to update the driver to the plain nvidia-driver-515 which ended up in a boot loop and “out-of-memory” grub error. Looks like a known issue with nvidia driver and 22.04 because the module dependencies creating a too big initramfs which cannot be loaded by grub. I solved that problem with a config change in the /etc/initramfs-tools/initramfs.conf changing modules to “dep” and compression to bzip2.

With the nvidia-driver-515 everything works as expected, you dont even have to mention the /dev/dri device or add the user to the group.

Because of documentation purposes I also created a blogpost about the whole installation process here [Running Plex in Docker with hw transcoding - digital-creations (digcre.io)](https://digcre.io/2022/08/14/running-plex-in-docker-with-hw-transcoding/)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [November 12, 2022, 1:13pm UTC](https://forums.plex.tv/t/hardware-transcoding-support-in-docker-container-isnt-working/804230/7 "2022-11-12T13:13:09Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
