From 6fe4b6ebf0d5f3c666ea724515d89cab38a05a54 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Fri, 26 Sep 2025 00:48:06 +0700 Subject: [PATCH] refactor: update Dockerfile to use development image and enhance FFmpeg build process with NVIDIA support --- Dockerfile.base | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/Dockerfile.base b/Dockerfile.base index 56b4159..8d19778 100644 --- a/Dockerfile.base +++ b/Dockerfile.base @@ -1,5 +1,5 @@ # Base image with complete ML and hardware acceleration stack -FROM pytorch/pytorch:2.8.0-cuda12.6-cudnn9-runtime +FROM pytorch/pytorch:2.8.0-cuda12.6-cudnn9-devel # Install build dependencies and system libraries RUN apt-get update && apt-get install -y \ @@ -12,6 +12,12 @@ RUN apt-get update && apt-get install -y \ unzip \ yasm \ nasm \ + # Additional dependencies for FFmpeg/NVIDIA build + libtool \ + libc6 \ + libc6-dev \ + libnuma1 \ + libnuma-dev \ # System libraries libgl1-mesa-glx \ libglib2.0-0 \ @@ -31,41 +37,45 @@ RUN apt-get update && apt-get install -y \ python3-numpy \ && rm -rf /var/lib/apt/lists/* -# Install prebuilt FFmpeg with CUDA support +# CUDA development tools already available in devel image + # Ensure CUDA paths are available ENV PATH="/usr/local/cuda/bin:${PATH}" ENV LD_LIBRARY_PATH="/usr/local/cuda/lib64:${LD_LIBRARY_PATH}" -# Install NVIDIA Video Codec SDK headers first +# Install NVIDIA Video Codec SDK headers (official method) RUN cd /tmp && \ - wget https://github.com/FFmpeg/nv-codec-headers/archive/refs/tags/n12.1.14.0.zip && \ - unzip n12.1.14.0.zip && \ - cd nv-codec-headers-n12.1.14.0 && \ + git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git && \ + cd nv-codec-headers && \ make install && \ - rm -rf /tmp/* + cd / && rm -rf /tmp/* # Build FFmpeg from source with NVIDIA CUDA support RUN cd /tmp && \ echo "Building FFmpeg with NVIDIA CUDA support..." && \ - # Download FFmpeg source - wget https://ffmpeg.org/releases/ffmpeg-7.1.tar.xz && \ - tar -xf ffmpeg-7.1.tar.xz && \ - cd ffmpeg-7.1 && \ - # Configure with NVIDIA support + # Download FFmpeg source (official method) + git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg/ && \ + cd ffmpeg && \ + # Configure with NVIDIA support (following official NVIDIA documentation) ./configure \ --prefix=/usr/local \ --enable-shared \ - --enable-pic \ - --enable-gpl \ - --enable-version3 \ + --disable-static \ --enable-nonfree \ + --enable-gpl \ --enable-cuda-nvcc \ + --enable-cuda-llvm \ --enable-cuvid \ --enable-nvdec \ --enable-nvenc \ --enable-libnpp \ + --nvcc=/usr/local/cuda/bin/nvcc \ --extra-cflags=-I/usr/local/cuda/include \ --extra-ldflags=-L/usr/local/cuda/lib64 \ + --extra-libs=-lcuda \ + --extra-libs=-lcudart \ + --extra-libs=-lnvcuvid \ + --extra-libs=-lnvidia-encode \ --enable-libx264 \ --enable-libx265 \ --enable-libvpx \