EC2BimefyModel / Dockerfile
ShawXI's picture
Update Dockerfile
1badd5e verified
# Use the NVIDIA CUDA base image with runtime support
FROM nvidia/cuda:12.2.0-runtime-ubuntu20.04
WORKDIR /app
# Prevent interactive timezone prompt
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Etc/UTC
# Install required libraries and NVIDIA Video Codec SDK dependencies
RUN apt-get update && apt-get install -y \
software-properties-common \
autoconf \
automake \
build-essential \
cmake \
git \
libass-dev \
libfreetype6-dev \
libtool \
libvorbis-dev \
pkg-config \
texinfo \
wget \
yasm \
zlib1g-dev \
libx264-dev \
libx265-dev \
libsm6 \
libxext6 \
libgl1-mesa-glx \
nvidia-utils-535 \
nvidia-cuda-toolkit \
tzdata \
nasm \
python3 \
python3-pip \
&& ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime \
&& dpkg-reconfigure --frontend noninteractive tzdata \
&& rm -rf /var/lib/apt/lists/*
# Install NVIDIA codec headers for FFmpeg (ffnvcodec)
RUN git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git && \
cd nv-codec-headers && \
make -j$(nproc) && \
make install && \
cd .. && \
rm -rf nv-codec-headers
# Download and compile ffmpeg with NVENC support
RUN git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg && \
cd ffmpeg && \
./configure \
--enable-gpl \
--enable-nonfree \
--enable-cuda \
--enable-cuvid \
--enable-nvenc \
--enable-libx264 \
--enable-libx265 \
--extra-cflags=-I/usr/local/cuda/include \
--extra-ldflags=-L/usr/local/cuda/lib64 && \
make -j$(nproc) && \
make install && \
cd .. && \
rm -rf ffmpeg
# Prioritize /usr/local/bin (newly compiled ffmpeg)
ENV PATH="/usr/local/bin:${PATH}"
# Copy project files and install dependencies
COPY . /app
RUN python3 -m pip install --no-cache-dir --upgrade pip
RUN python3 -m pip install --no-cache-dir -r requirements.txt
EXPOSE 7860
CMD ["python3", "app.py"]