Images with FFmpeg 7.0 and OpenCV 4.9.0 compiled with NVIDIA GPU support on Ubuntu 22.04 runtime
406
This repository provides a hardware-accelerated container image that includes FFmpeg and OpenCV, optimized for NVIDIA GPUs.
The build process was divided into two stages to keep the final image size minimal:
Builder Stage (nvidia/cuda:12.1.1-devel-ubuntu22.04):
nvcc) and build dependencies.n7.0) from source, enabled with CUDA/NVENC/NVDEC/CUVID and NPP.4.9.0) from source with Python bindings, CUDA, cuDNN, and FFmpeg backends enabled.Runtime Stage (nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04):
LD_LIBRARY_PATH, NVIDIA_DRIVER_CAPABILITIES, etc.) ensures the GPU is readily accessible.12.1.1-cudnn8-runtime-python3.11: Includes Python 3.11 and its corresponding OpenCV cv2 bindings.The image is pre-configured for the following CUDA architectures (supported by CUDA 12.1):
7.5: Turing (e.g., T4, RTX 20xx)8.0: Ampere (e.g., A100)8.6: Ampere (e.g., A10, A40, RTX 30xx)8.9: Ada Lovelace (e.g., L4, L40, RTX 40xx)9.0: Hopper (e.g., H100)Note: Check your GPU's compute capability here
To run the container interactively with access to all available GPUs, compute, and video transcoding capabilities:
docker run -it --rm --gpus all sazonovanton/ffmpeg-opencv-cuda:12.1.1-cudnn8-runtime
Inside the container, you can verify that OpenCV has been compiled with CUDA support using Python:
python3 -c "import cv2; print(cv2.cuda.getCudaEnabledDeviceCount())"
# Should output > 0 if GPUs are properly exposed to the container
You can check if FFmpeg recognizes the NVIDIA encoders by running:
ffmpeg -encoders | grep nvenc
You can easily use this image as a base image for your applications:
FROM sazonovanton/ffmpeg-opencv-cuda:12.1.1-cudnn8-runtime
# Install your app dependencies
RUN pip3 install --no-cache-dir my-python-package
COPY my_script.py /workspace/
CMD ["python3", "my_script.py"]
Content type
Image
Digest
sha256:1adacfb96…
Size
2.4 GB
Last updated
6 months ago
docker pull sazonovanton/ffmpeg-opencv-cuda:12.1.1-cudnn8-runtime-python3.11