Last active
February 14, 2022 01:49
-
-
Save TzuHuanTai/52570e3f51ff1c927b81fbf9387228e3 to your computer and use it in GitHub Desktop.
FFmpeg/OpenCV Dockerfile built from nvidiancuda:10.1 cudnn7 devel centos7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM nvidia/cuda:10.1-cudnn7-devel-centos7 | |
ARG PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:$PKG_CONFIG_PATH" | |
ARG LD_LIBRARY_PATH="/usr/local/lib:/usr/local/lib64:$LD_LIBRARY_PATH" | |
### Update to gcc 8 and cmake3 | |
RUN yum install -y install centos-release-scl-rh | |
RUN yum install -y devtoolset-8* | |
RUN echo "source /opt/rh/devtoolset-8/enable" >> /etc/bashrc | |
SHELL ["/bin/bash", "--login", "-c"] | |
# curl -O -L https://github.com/Kitware/CMake/releases/download/v3.21.2/cmake-3.21.2.tar.gz | |
COPY /cmake-3.21.2 /cmake-3.21.2 | |
RUN cd ./cmake-3.21.2 && \ | |
./bootstrap && \ | |
make -j8 && \ | |
make install | |
### Build FFmpeg | |
RUN yum install -y build-essential git autoconf automake libtool bzip2 bzip2-devel freetype-devel zlib-devel | |
COPY /ffmpeg_sources /ffmpeg_sources | |
WORKDIR /ffmpeg_sources | |
# git clone --depth 1 --branch sdk/9.0 https://github.com/FFmpeg/nv-codec-headers.git | |
RUN cd ./nv-codec-headers && \ | |
make && \ | |
make install | |
# curl -O -L https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/nasm-2.15.05.tar.bz2 | |
RUN cd ./nasm-2.15.05 && \ | |
./autogen.sh && \ | |
./configure --prefix="/usr/local" --bindir="/usr/local/bin" && \ | |
make -j8 && \ | |
make install | |
# curl -O -L https://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz | |
RUN cd ./yasm-1.3.0 && \ | |
./configure --prefix="/usr/local" --bindir="/usr/local/bin" && \ | |
make -j8 && \ | |
make install | |
# git clone --branch stable --depth 1 https://code.videolan.org/videolan/x264.git | |
RUN cd ./x264 && \ | |
./configure --prefix="/usr/local" \ | |
--bindir="/usr/local/bin" \ | |
--enable-static --enable-shared && \ | |
make -j8 && \ | |
make install | |
# wget https://ftp.gnu.org/gnu/automake/automake-1.16.tar.gz | |
RUN cd ./automake-1.16 && \ | |
./configure --prefix=/opt/aclocal-1.16 && \ | |
make && \ | |
make install | |
# git clone --depth 1 https://github.com/mstorsjo/fdk-aac | |
RUN ls /bin | grep aclocal | |
RUN cd ./fdk-aac && \ | |
autoreconf -fiv && \ | |
./configure --prefix="/usr/local" && \ | |
make -j8 && \ | |
make install | |
# curl -O -L https://archive.mozilla.org/pub/opus/opus-1.3.1.tar.gz | |
RUN cd ./opus-1.3.1 && \ | |
./configure --prefix="/usr/local" && \ | |
make -j8 && \ | |
make install | |
# git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git | |
RUN cd ./libvpx && \ | |
./configure --prefix="/usr/local" \ | |
--enable-shared \ | |
--enable-static \ | |
--disable-examples \ | |
--disable-unit-tests \ | |
--enable-vp9-highbitdepth \ | |
--as=nasm && \ | |
make -j8 && \ | |
make install | |
# git clone https://gitlab.com/AOMediaCodec/SVT-AV1.git | |
RUN mkdir -p SVT-AV1/build && \ | |
cd ./SVT-AV1/build && \ | |
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="/usr/local" -DCMAKE_BUILD_TYPE=Release .. && \ | |
make -j8 && \ | |
make install | |
# git clone --depth 1 --branch release/4.4 https://github.com/FFmpeg/FFmpeg.git | |
RUN cd ./ffmpeg-4.4 && \ | |
./configure \ | |
--prefix="/usr/local" \ | |
--pkg-config-flags="--static" \ | |
--extra-cflags="-I/usr/local/include" \ | |
--extra-ldflags="-L/usr/local/lib" \ | |
--extra-ldflags="-L/usr/local/lib64" \ | |
--extra-cflags="-I/usr/local/cuda/include/" \ | |
--extra-ldflags=-L/usr/local/cuda/lib64/ \ | |
--enable-cuda-nvcc \ | |
--enable-cuvid \ | |
--extra-libs=-lpthread \ | |
--extra-libs=-lm \ | |
--enable-pic \ | |
--bindir="/usr/local/bin" \ | |
--enable-gpl \ | |
--enable-shared \ | |
--enable-libfdk_aac \ | |
--enable-libfreetype \ | |
--enable-libopus \ | |
--enable-libsvtav1 \ | |
--enable-libx264 \ | |
--enable-libvpx \ | |
--enable-nonfree \ | |
--enable-nvenc && \ | |
make -j8 && \ | |
make install | |
RUN echo -e "/usr/local/lib\n/usr/local/lib64" >> /etc/ld.so.conf.d/ffmpeg.conf | |
RUN ldconfig | |
RUN ffmpeg -version | |
### Build OpenCV | |
# wget -O opencv.zip https://github.com/opencv/opencv/archive/4.5.2.zip | |
# wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/4.5.2.zip | |
WORKDIR / | |
COPY /opencv /opencv | |
COPY /opencv_contrib /opencv_contrib | |
RUN cd ./opencv && \ | |
mkdir build && cd build && \ | |
cmake -D CMAKE_BUILD_TYPE=RELEASE \ | |
-D CMAKE_INSTALL_PREFIX=/usr/local \ | |
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \ | |
-D ENABLE_NEON=OFF \ | |
-D ENABLE_CXX11=ON \ | |
-D WITH_GSTREAMER=ON \ | |
-D WITH_LIBV4L=ON \ | |
-D ENABLE_FAST_MATH=1 \ | |
-D CUDA_FAST_MATH=1 \ | |
-D WITH_CUDA=ON \ | |
-D OPENCV_DNN_CUDA=ON \ | |
-D CUDA_ARCH_BIN=6.1 \ | |
-D BUILD_opencv_python2=OFF \ | |
-D BUILD_opencv_python3=OFF \ | |
-D WITH_FFMPEG=ON \ | |
-D BUILD_TESTS=OFF \ | |
-D OPENCV_ENABLE_NONFREE=ON \ | |
-D BUILD_PERF_TESTS=OFF \ | |
-D INSTALL_PYTHON_EXAMPLES=OFF \ | |
-D INSTALL_C_EXAMPLES=OFF \ | |
-D BUILD_EXAMPLES=OFF \ | |
-DCMAKE_CXX_FLAGS="-std=c++11" .. && \ | |
make -j16 && \ | |
make install | |
RUN opencv_version -v | |
### Install Dotnet Runtime | |
ARG ASPNETCORE_FILE=aspnetcore-runtime-5.0.13-linux-x64.tar.gz | |
ARG DOTNET_FILE=dotnet-runtime-5.0.13-linux-x64.tar.gz | |
ENV DOTNET_ROOT=/opt/dotnet | |
ENV PATH=$PATH:${DOTNET_ROOT} | |
ADD ${ASPNETCORE_FILE} ${DOTNET_ROOT} | |
ADD ${DOTNET_FILE} ${DOTNET_ROOT} | |
RUN dotnet --info | |
### Unlock driver limitation | |
# https://github.com/keylase/nvidia-patch.git | |
COPY /nvidia-patch /nvidia-patch | |
COPY /nvidia-patch/patch.sh /usr/local/bin | |
ENTRYPOINT ["/nvidia-patch/docker-entrypoint.sh"] | |
WORKDIR / | |
RUN rm -rf /cmake-3.12.3 && \ | |
rm -rf /ffmpeg_sources && \ | |
rm -rf /opencv && \ | |
rm -rf /opencv_contrib | |
CMD ["-f","/dev/null"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sudo docker run --runtime=nvidia --name merged_streaming --rm -e NVIDIA_DRIVER_CAPABILITIES=all -p 5080:5000 -v /data:/data -it richard/streaming:0.0.2 /bin/bash