Sign inSign up

sazonovanton/ffmpeg-opencv-cuda

By sazonovanton

•Updated 6 months ago

Images with FFmpeg 7.0 and OpenCV 4.9.0 compiled with NVIDIA GPU support on Ubuntu 22.04 runtime

Image
Machine learning & AI
0

406

sazonovanton/ffmpeg-opencv-cuda repository overview

⁠FFMPEG-OpenCV-CUDA

This repository provides a hardware-accelerated container image that includes FFmpeg and OpenCV, optimized for NVIDIA GPUs.


⁠Image Details

The build process was divided into two stages to keep the final image size minimal:

  1. Builder Stage (nvidia/cuda:12.1.1-devel-ubuntu22.04):

    • Contains necessary compilers (like nvcc) and build dependencies.
    • Compiles FFmpeg (branch n7.0) from source, enabled with CUDA/NVENC/NVDEC/CUVID and NPP.
    • Compiles OpenCV (version 4.9.0) from source with Python bindings, CUDA, cuDNN, and FFmpeg backends enabled.
  2. Runtime Stage (nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04):

    • A slim runtime environment containing only the necessary runtime libraries and dependencies.
    • Automatically imports the compiled binaries and libraries from the builder stage.
    • Pre-configured environment variables (LD_LIBRARY_PATH, NVIDIA_DRIVER_CAPABILITIES, etc.) ensures the GPU is readily accessible.

⁠Available Tags
  • 12.1.1-cudnn8-runtime-python3.11: Includes Python 3.11 and its corresponding OpenCV cv2 bindings.

⁠Supported GPU Architectures

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⁠


⁠Running the Container

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
⁠Checking OpenCV CUDA Support

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
⁠Checking FFmpeg NVENC Support

You can check if FFmpeg recognizes the NVIDIA encoders by running:

ffmpeg -encoders | grep nvenc

⁠Usage in derived images

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"]

Tag summary

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