ESXi -> Ubuntu 20.04 -> Docker Container: Nvidia HW Transcoding Guide

Disclaimer: My steps may or may not work for you. This is what currently works for me. Good luck. Get familiar with docker-compose if you’re not already. It can save a lot of time when deploying services. Also: keeping all of your container configurations in a file than manually setting it up is a pro. Unfortunately, I don’t believe Plex supports HW transcoding in containers, meaning that you’re on your own. Take what you can get from others and find your solution. Bottom line is that you can get it working.
I don’t know if the legacy Nvidia runtime is required anymore. Mine is set up but I am no longer using the runtime under any containers. You can set it up if you want. I’ll leave the link in the notes for directions.

My Setup:

Host Hardware: Dell Poweredge r720xd
Host Hypervisor: VMware ESXi 7.0.0 (Build 16324942) + vSphere Enterprise 7\vCenter Standard 7

GPU: PCI Passthrough → Quadro M2000
DVB: PCI Passthrough → WinTV QuadHD (Binding /dev/dvb to the container does the trick)
VM VMware: Ubuntu Server 20.04.3 LTS (GNU/Linux 5.13.14-xanmod1 x86_64)

Docker: version 20.10.8
Docker Compose: version 1.29.2, build 5becea4c
Docker image: plexinc/pms-docker:plexpass

My steps for getting Nvidia HW transcoding working.

  1. Install nvidia-driver-XXX (In my case 470)

  2. Verify lshw -C Display (Verify driver is nvidia for your gpu)

  3. Verify nvidia-smi (Verify the command runs. No library mismatches etc)
    (After removing and installing the proper version, a reboot may be required to fix library mismatch errors.)

  4. Verify you have the latest version of docker. (Follow Docker wiki)
    Docker Install docs

  5. Verify you have the latest version of docker-compose. (Version on the repo is outdated?) Follow docker wiki to manually link the latest binary. (This is to support the latest version of compose files. Which has better gpu handling → “Docker Compose v1.28.0+ allows to define GPU reservations using the device structure defined in the Compose Specification.”) Docker Docs (GPU Handling)

  6. You’re going to have to have to modify the Plex image. Modify the dockerfile and have it install libnvidia-encode-XXX-server or modify your current container and manually do it through terminal and build a new image based off of that container. Google this. (Make sure the libnvidia version matches the version of your host nvidia drivers)

  7. Build Plex container with docker-compose.
    Create docker-compose.yaml inside of a directory
    Navigate to the directory and run “docker-compose up-d”

My configuration for example. Not to be copied but to be referred to.

version: “3.4”
services:
PlexMediaServer:
container_name: PlexMediaServer
environment:
- PLEX_UID=0
- PLEX_GID=0
- ALLOWED_NETWORKS=192.168.1.0/24
- PLEX_CLAIM=YOURCLAIM
- TZ=America/Los_Angeles
network_mode: host
image: your_modified_image
restart: always
volumes:
- /path/to/your/config:/config
- /your/media/volumes/etc/:/media
- /your/transcode/tmp/path/:/transcode
devices:
- “/dev/dvb:/dev/dvb”
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]

Notes:

Libnvidia-encode.so.1 - Plex Debug Log- Cannot Load (The minimum required driver for nvenc is …)
https://forums.plex.tv/t/libnvidia-encode-so-1-missing-from-docker-image/734602
Workaround:
Compile plex image with libnvidia-encode-XXX-server (Make sure the version matches your host’s nvidia driver version. Else you’ll get mismatches.)

Legacy Nvidia Docker runtimes
https://docs.docker.com/config/containers/resource_constraints/#gpu

Running nvidia-smi gives mismatch errors
Fix: Just start over, use “apt remove” to remove all of the nvidia-drivers you have installed. If you install libnvidia-encode, remove it. Install the nvidia-driver version you want and then restart the host.

Other driver issues
Try: disabling nouveau. Google some directions for your build.

Compose syntax issues
Fix: Verify that you have the latest docker-compose installed. As I said: you may have to manually set it up. I don’t think the repo’s have the latest. Package from 2019 I think. (Else you jacked up the actual yaml syntax)

Other issues (Plex)
Use the Plex Debug Logs to troubleshoot your issue.

nvidia-smi not showing sessions on the container
Info: From my experience, I’ve noticed that nvidia-smi shows the transcode sessions on the host but doesn’t show the sessions on nvidia-smi on the container.

2 Likes

Hi,

is this the only way now? or the command line docker run like this :
sudo docker run --name plex --restart=always --runtime=nvidia --device=/dev/dri/card0:/dev/dri/card0 --device=/dev/dri/renderD128:/dev/dri/renderD128 -e NVIDIA_VISIBLE_DEVICES=GPU-c087a6b2-c490-80e9-5e1c-142efc3e1a10 -e NVIDIA_DRIVER_CAPABILITIES=compute,video,utility ... etc etc
does still work ?
Because as for now there is a problem with
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: Running hook #1:: error running hook: exit status 1, stdout: , stderr: nvidia-container-cli: initialization error: cuda error: unknown error: unknown.

which is apparently appearing on other platforms too:

and yes i have the libnvidia encore:

 ls -l /usr/lib/x86_64-linux-gnu/libnvidia-encode.so.1
lrwxrwxrwx 1 root root 29 Nov  9 07:36 /usr/lib/x86_64-linux-gnu/libnvidia-encode.so.1 -> libnvidia-encode.so.470.82.00

did you buy it refursbished or new? and if refurbished where?

I wish I thought about changing the dockerfile earlier. Was so bent on trying to get it to work with the linuxserver plex docker image because it looked like everyone else had success with it.

Had a hard time trying to get my Quadro P400 working with a plex docker container for the past few hours and one step in this guide solved my issue. The only thing I didn’t do was clone the plex image from github and add ONE line to the dockerfile.

Only took me a few minutes to clone the repo and add apt install libnvidia-encode-460-server to the dockerfile, changed my docker-compose file to use the dockerfile and boom. My plex instance is now using my P400 to decode and encode.

Honestly not sure why the linuxserver plex docker image doesn’t work even though they advertise that it’s supposed to work. I’ve installed the headless cuda drivers, nvidia tools, and nvidia docker 2 just like everyone else and nothing worked. Kinda frustrated that I wasted a few hours and just adding 1 line to a dockerfile fixes the problem

My Setup
Just in case someone else sees this post from google. Here are the config files I’m using. I also use an unraid server to store all my files and use a different beefier server for plex/game servers/etc. If you don’t use a shared network folder, you can remove the volumes section at the bottom of the config.

Docker Compose
This docker compose file doesn’t require you update docker-compose like in the guide above. I might switch to a newer docker compose version soon so I can have better control over how much cpu/ram the plex server can use. If it works, out, I’ll add the other revision here.

docker-compose.yml file
version: "2.3"

services:
  plex:
    build: ./custom-docker-plex
    network_mode: host
    environment:
      - PUID=1000 # It doesn't need to be 1000
      - PGID=1000 # It doesn't need to be 1000
      - VERSION=latest
    volumes:
      - ./config:/config
      - ./transcode:/transcode
      - unraid-media:/media
    devices:
      - /dev/dri:/dev/dri
    privileged: true
    ports:
      - 443:443
      - 32400:32400
      - 1900:1900/udp
      - 5353:5353
      - 8324:8324
      - 32469:32469
      - 32410:32410/udp
      - 32412:32412/udp
      - 32413:32413/udp
      - 32414:32414/udp

volumes:
  unraid-media:
    driver_opts:
      type: cifs
      o: "username=<username>,password=<password>"
      devices: "\\<ipaddress/hostname>/<folder>"

Dockerfile changes
Here are the changes I made to the docker compose file from the linuxserver plex github repo

Dockerfile file
 apt-get install -y \
        beignet-opencl-icd \
        jq \
        ocl-icd-libopencl1 \
        udev \
        unrar \
        wget && \

to

  apt-get install -y \
        beignet-opencl-icd \
        jq \
        ocl-icd-libopencl1 \
        udev \
        unrar \
        wget \
        libnvidia-encode-460-server && \

If you think I shouldn’t be piggy back riding the original post. I’ll remove this post and just create a new thread. Just wanted to share my experience here since this is what helped me fix the issue.

Keywords (ignore this. Just trying to get google's attention)

plex docker nvidia
plex docker cuda
plex docker nvidia fix
plex docker nvidia broken
plex docker hardware acceleration not working
plex docker-compose nvidia not working
plex docker-compose cuda not working
linuxserver plex nvidia not working
linuxserver plex cuda not working
linuxserver plex hardware acceleration not working

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