Plex Logo

Plex transcoding with Docker – NVIDIA GPU



To use Plex transcoding with Docker we need to passtrough the NVIDIA GPU to the Docker container. Plex has the ability to fully use the NVIDIA GPU for video transcoding like a bare metal install. In this post I will explain the needed steps to get Plex transcoding to work. In this example we will use Ubuntu 22.04

Nvidia driver

First we need to install the NVIDIA driver. On Ubuntu 22.04 we can install the drivers from apt. As this is a server without a GUI we will go for the headless drivers. After installing the NVIDIA driver we also need to install the package libnvidia-encode for the video transcoding.

# Search apt for NVIDIA drivers.
sudo apt search nvidia-driver
# At the time of writing the latest driver is 510.

# Install the headless drivers.
sudo apt install nvidia-headless-driver-510

# Search apt for libnvidia-encode.
sudo apt search nvidia-encode

# Install the libnvidia-encode package.
sudo apt install libnvidia-encode-510

# Install nvidia-utils package for nvidia-smi command.
sudo apt install nvidia-utils-510

After installing all the packages reboot your server and check if everything works correctly with the nvidia-smi command.


# Output
| NVIDIA-SMI 510.73.05    Driver Version: 510.73.05    CUDA Version: 11.6     |
| 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 P2000        Off  | 00000000:0B:00.0 Off |                  N/A |
| 44%   31C    P8     5W /  75W |      2MiB /  5120MiB |      0%      Default |
|                               |                      |                  N/A |
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|  No running processes found                                                 |

NVIDIA container toolkit

After installing the drivers we need to install the NVIDIA container toolkit. More information about the NVIDIA container toolkit can be found on the NVIDIA docs site.

Setting up the package repository

distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
      && curl -fsSL | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
      && curl -s -L$distribution/libnvidia-container.list | \
            sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
            sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list

Installing the NVIDIA container toolkit

# Update apt.
sudo apt-get update

# Install the nvidia-docker2 package.
sudo apt-get install -y nvidia-docker2

# Restart Docker.
sudo systemctl restart docker

# Test the GPU with a base CUDA container.
sudo docker run --rm --gpus all nvidia/cuda:11.0.3-base-ubuntu20.04 nvidia-smi

Docker compose options

After all the local packages we need to configure our Docker compose file to use the NVIDIA GPU inside the Plex container. I will assume you have the latest version of Docker installed with the new Docker compose version. Below is an example of my Docker compose file for Plex transcoding with Docker.

version: "3.8"
    container_name: plex
    network_mode: host
            - capabilities: [gpu]
      - PUID=1001
      - PGID=1001
      - VERSION=docker
      - NVIDIA_DRIVER_CAPABILITIES=compute,video,utility
      - /home/tizu/plex/appdata/config:/config
      - /mnt/media/TV Shows:/tv
      - /mnt/media/Movies:/movies
      - /mnt/media/Music:/music
    restart: unless-stopped

Next spin up the Docker stack and test the transcoding. In Plex you need to make sure it says Transcode (hw) when transcoding a video. For example:

Transcode (hw)


It took me quite a while to get this setup working correctly. The most important thing I was missing was the libnvidia-encode package. I hope this post helps you out getting the NVIDIA transcoding working in Plex. If you have any questions leave them in the comments!

Leave a Reply

Your email address will not be published.