decord icon indicating copy to clipboard operation
decord copied to clipboard

Docker build fails

Open ganessh22 opened this issue 2 years ago • 4 comments

The Dockerfile in master doesn't work.

/decord/src/video/ffmpeg/threaded_decoder.cc: In member function 'void decord::ffmpeg::FFMPEGThreadedDecoder::WorkerThread()':
/decord/src/video/ffmpeg/threaded_decoder.cc:176:26: warning: catching polymorphic type 'struct dmlc::Error' by value [-Wcatch-value=]
  176 |     } catch (dmlc::Error error) {
      |                          ^~~~~
[ 72%] Building CXX object CMakeFiles/decord.dir/src/video/nvcodec/cuda_context.cc.o
[ 75%] Building CXX object CMakeFiles/decord.dir/src/video/nvcodec/cuda_decoder_impl.cc.o
[ 78%] Building CXX object CMakeFiles/decord.dir/src/video/nvcodec/cuda_mapped_frame.cc.o
[ 81%] Building CXX object CMakeFiles/decord.dir/src/video/nvcodec/cuda_parser.cc.o
[ 83%] Building CXX object CMakeFiles/decord.dir/src/video/nvcodec/cuda_stream.cc.o
[ 86%] Building CXX object CMakeFiles/decord.dir/src/video/nvcodec/cuda_texture.cc.o
[ 89%] Building CXX object CMakeFiles/decord.dir/src/video/nvcodec/cuda_threaded_decoder.cc.o
/decord/src/video/nvcodec/cuda_threaded_decoder.cc: In member function 'void decord::cuda::CUThreadedDecoder::LaunchThread()':
/decord/src/video/nvcodec/cuda_threaded_decoder.cc:304:24: warning: catching polymorphic type 'struct dmlc::Error' by value [-Wcatch-value=]
  304 |   } catch (dmlc::Error error) {
      |                        ^~~~~
[ 91%] Building CXX object CMakeFiles/decord.dir/src/runtime/cuda/cuda_device_api.cc.o
[ 94%] Building CXX object CMakeFiles/decord.dir/src/runtime/cuda/cuda_module.cc.o
make[2]: *** No rule to make target '/usr/local/cuda/lib64/libnvcuvid.so', needed by 'libdecord.so'.  Stop.
make[2]: *** Waiting for unfinished jobs....
[ 97%] Building CUDA object CMakeFiles/decord.dir/src/improc/improc.cu.o
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/decord.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
The command '/bin/sh -c cd decord && mkdir build && cd build && cmake .. -DUSE_CUDA=ON -DCMAKE_BUILD_TYPE=Release && make -j2 && cd ../python && python3 setup.py install' returned a non-zero code: 2

Was this not tested?

ganessh22 avatar Nov 29 '22 15:11 ganessh22

Others are facing issues with the Docker as well. https://github.com/dmlc/decord/pull/166#issuecomment-1015189012

ganessh22 avatar Nov 29 '22 15:11 ganessh22

Did you manage to solve this? I managed to get it to go passed this but I did it in a hacky way that caused trouble later down the line.

AntreasAntoniou avatar Mar 21 '23 10:03 AntreasAntoniou

The error is gone if you use DOCKER_BUILDKIT=0 before docker compose up according to stackoverflow. But I only managed to build decord on one of my two servers, another one is still falling with the same error

egorovivannn avatar Mar 22 '23 09:03 egorovivannn

Hello, I have gotten this working @AntreasAntoniou @egorovivannn

The issue was the path to which the libnvcuvid files are copied. ln -s also didn't work for me. I copied and then deleted the files. The Video_Codec_SDK zip I use here has files from here and from my host system. You can find host system files by running

$ ldconfig -p | grep nvcuvid
	libnvcuvid.so.1 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libnvcuvid.so.1
	libnvcuvid.so.1 (libc6) => /usr/lib/i386-linux-gnu/libnvcuvid.so.1
	libnvcuvid.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libnvcuvid.so
	libnvcuvid.so (libc6) => /usr/lib/i386-linux-gnu/libnvcuvid.so

add the x86_64 files to your zip.

FROM nvcr.io/nvidia/cuda:11.6.2-cudnn8-devel-ubuntu20.04 as build

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get -y update && apt-get install -y \
    software-properties-common \
    build-essential \
    checkinstall \
    cmake \
    make \
    pkg-config \
    yasm \
    git \
    vim \
    curl \
    wget \
    zip \
    sudo \
    apt-transport-https \
    libcanberra-gtk-module \
    libcanberra-gtk3-module \
    dbus-x11 \
    iputils-ping \
    python3-dev \
    python3-pip \
    python3-setuptools

# some image/media dependencies
RUN apt-get -y update && apt-get install -y \
    libjpeg8-dev \
    libpng-dev \
    libtiff5-dev \
    libtiff-dev \
    libavcodec-dev \
    libavformat-dev \
    libswscale-dev \
    libdc1394-22-dev \
    libxine2-dev \
    libavfilter-dev  \
    libavutil-dev

RUN apt-get -y update && apt-get install -y ffmpeg  

RUN apt-get clean && rm -rf /tmp/* /var/tmp/* /var/lib/apt/lists/* && apt-get -y autoremove
ENV VIDEO_CODEC_SDK_VERSION="12.0.16"
ENV NVIDIA_DRIVER_CAPABILITIES=all
ADD Video_Codec_SDK_${VIDEO_CODEC_SDK_VERSION}.zip .
RUN unzip /Video_Codec_SDK_${VIDEO_CODEC_SDK_VERSION}.zip \
    && cp /Video_Codec_SDK_${VIDEO_CODEC_SDK_VERSION}/cuviddec.h /usr/local/cuda/targets/x86_64-linux/include \
    && cp /Video_Codec_SDK_${VIDEO_CODEC_SDK_VERSION}/nvcuvid.h /usr/local/cuda/targets/x86_64-linux/include \
    && cp /Video_Codec_SDK_${VIDEO_CODEC_SDK_VERSION}/libnvidia-encode.so /usr/local/cuda/targets/x86_64-linux/lib \
    && cp /Video_Codec_SDK_${VIDEO_CODEC_SDK_VERSION}/libnvcuvid.so /usr/local/cuda/targets/x86_64-linux/lib \
    && cp /Video_Codec_SDK_${VIDEO_CODEC_SDK_VERSION}/libnvcuvid.so.1 /usr/local/cuda/targets/x86_64-linux/lib \
    && ldconfig
RUN git clone --recursive https://github.com/dmlc/decord
RUN cd decord && mkdir build && cd build && cmake .. -DUSE_CUDA=ON -DCMAKE_BUILD_TYPE=Release && make -j24 && cd ../python && python3 setup.py install
RUN rm /usr/local/cuda/targets/x86_64-linux/lib/libnvidia-encode.so \
    && rm /usr/local/cuda/targets/x86_64-linux/lib/libnvcuvid.so.1 \
    && rm /usr/local/cuda/targets/x86_64-linux/lib/libnvcuvid.so

You can make this much smaller probably by doing a two stage build and copy. The second stage will probably only need cuda-runtime image instead of cuda-cudnn-devel image. I haven't tried it out though.

ganessh22 avatar Apr 27 '23 01:04 ganessh22