Ask Your Question

Revision history [back]

Build fails in nvidia docker; cuda:9.2-cudnn7-devel-ubuntu16.04

got following error when install opencv in nvidia docker; nvidia/cuda:9.2-cudnn7-devel-ubuntu16.04

> [ 30%] Building NVCC (Device) object modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_normalize.cu.o
cd /root/opencv/build/modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda && /usr/bin/cmake -E make_directory /root/opencv/build/modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda/.
cd /root/opencv/build/modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda && /usr/bin/cmake -D verbose:BOOL=1 -D build_configuration:STRING=RELEASE -D generated_file:STRING=/root/opencv/build/modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_normalize.cu.o -D generated_cubin_file:STRING=/root/opencv/build/modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_normalize.cu.o.cubin.txt -P /root/opencv/build/modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_normalize.cu.o.cmake
-- Removing /root/opencv/build/modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_normalize.cu.o
/usr/bin/cmake -E remove /root/opencv/build/modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_normalize.cu.o
-- Generating dependency file: /root/opencv/build/modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_normalize.cu.o.NVCC-depend
/usr/local/cuda/bin/nvcc -M -D__CUDACC__ /root/opencv/modules/dnn/src/cuda/normalize.cu -o /root/opencv/build/modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_normalize.cu.o.NVCC-depend -ccbin /usr/bin/gcc-5 -m64 -D__OPENCV_BUILD=1 -D_USE_MATH_DEFINES -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS -DCV_OCL4DNN=1 -DCV_CUDA4DNN=1 -DHAVE_PROTOBUF=1 -Xcompiler ,\"-fsigned-char\",\"-ffast-math\",\"-W\",\"-Wall\",\"-Werror=return-type\",\"-Werror=non-virtual-dtor\",\"-Werror=address\",\"-Werror=sequence-point\",\"-Wformat\",\"-Werror=format-security\",\"-Winit-self\",\"-Wpointer-arith\",\"-Wuninitialized\",\"-Winit-self\",\"-Wno-comment\",\"-fdiagnostics-show-option\",\"-Wno-long-long\",\"-pthread\",\"-fomit-frame-pointer\",\"-ffunction-sections\",\"-fdata-sections\",\"-msse\",\"-msse2\",\"-msse3\",\"-fvisibility=hidden\",\"-Wno-deprecated\",\"-Wno-missing-declarations\",\"-Wno-shadow\",\"-Wno-unused-parameter\",\"-Wno-sign-compare\",\"-Wno-undef\",\"-Wno-invalid-offsetof\",\"-Wno-unused-but-set-variable\",\"-O3\",\"-DNDEBUG\",\"-DNDEBUG\" -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -D_FORCE_INLINES --use_fast_math -Xcompiler -DCVAPI_EXPORTS -Xcompiler -fPIC --std=c++11 -DNVCC -I/usr/local/cuda/include -I/root/opencv/build/3rdparty/ippicv/ippicv_lnx/icv/include -I/root/opencv/build/3rdparty/ippicv/ippicv_lnx/iw/include -I/root/opencv/build -I/usr/include/gdal -I/usr/include/eigen3 -I/root/opencv/modules/dnn/include -I/root/opencv/build/modules/dnn -I/root/opencv_contrib/modules/cudev/include -I/root/opencv/modules/core/include -I/root/opencv/modules/imgproc/include -I/root/opencv/modules/dnn/misc/caffe -I/root/opencv/modules/dnn/misc/tensorflow -I/root/opencv/modules/dnn/misc/onnx -I/root/opencv/3rdparty/include/opencl/1.2 -I/usr/local/cuda/include -I/usr/include
-- Generating temporary cmake readable file: /root/opencv/build/modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_normalize.cu.o.depend.tmp
/usr/bin/cmake -D input_file:FILEPATH=/root/opencv/build/modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_normalize.cu.o.NVCC-depend -D output_file:FILEPATH=/root/opencv/build/modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_normalize.cu.o.depend.tmp -P /root/opencv/cmake/FindCUDA/make2cmake.cmake
-- Copy if different /root/opencv/build/modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_normalize.cu.o.depend.tmp to /root/opencv/build/modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_normalize.cu.o.depend
/usr/bin/cmake -E copy_if_different /root/opencv/build/modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_normalize.cu.o.depend.tmp /root/opencv/build/modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_normalize.cu.o.depend
-- Removing /root/opencv/build/modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_normalize.cu.o.depend.tmp and /root/opencv/build/modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_normalize.cu.o.NVCC-depend
/usr/bin/cmake -E remove /root/opencv/build/modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_normalize.cu.o.depend.tmp /root/opencv/build/modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_normalize.cu.o.NVCC-depend
-- Generating /root/opencv/build/modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_normalize.cu.o
/usr/local/cuda/bin/nvcc /root/opencv/modules/dnn/src/cuda/normalize.cu -c -o /root/opencv/build/modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_normalize.cu.o -ccbin /usr/bin/gcc-5 -m64 -D__OPENCV_BUILD=1 -D_USE_MATH_DEFINES -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS -DCV_OCL4DNN=1 -DCV_CUDA4DNN=1 -DHAVE_PROTOBUF=1 -Xcompiler ,\"-fsigned-char\",\"-ffast-math\",\"-W\",\"-Wall\",\"-Werror=return-type\",\"-Werror=non-virtual-dtor\",\"-Werror=address\",\"-Werror=sequence-point\",\"-Wformat\",\"-Werror=format-security\",\"-Winit-self\",\"-Wpointer-arith\",\"-Wuninitialized\",\"-Winit-self\",\"-Wno-comment\",\"-fdiagnostics-show-option\",\"-Wno-long-long\",\"-pthread\",\"-fomit-frame-pointer\",\"-ffunction-sections\",\"-fdata-sections\",\"-msse\",\"-msse2\",\"-msse3\",\"-fvisibility=hidden\",\"-Wno-deprecated\",\"-Wno-missing-declarations\",\"-Wno-shadow\",\"-Wno-unused-parameter\",\"-Wno-sign-compare\",\"-Wno-undef\",\"-Wno-invalid-offsetof\",\"-Wno-unused-but-set-variable\",\"-O3\",\"-DNDEBUG\",\"-DNDEBUG\" -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -D_FORCE_INLINES --use_fast_math -Xcompiler -DCVAPI_EXPORTS -Xcompiler -fPIC --std=c++11 -DNVCC -I/usr/local/cuda/include -I/root/opencv/build/3rdparty/ippicv/ippicv_lnx/icv/include -I/root/opencv/build/3rdparty/ippicv/ippicv_lnx/iw/include -I/root/opencv/build -I/usr/include/gdal -I/usr/include/eigen3 -I/root/opencv/modules/dnn/include -I/root/opencv/build/modules/dnn -I/root/opencv_contrib/modules/cudev/include -I/root/opencv/modules/core/include -I/root/opencv/modules/imgproc/include -I/root/opencv/modules/dnn/misc/caffe -I/root/opencv/modules/dnn/misc/tensorflow -I/root/opencv/modules/dnn/misc/onnx -I/root/opencv/3rdparty/include/opencl/1.2 -I/usr/local/cuda/include -I/usr/include
/root/opencv/modules/dnn/src/cuda/normalize.cu(38): error: no instance of overloaded function "atomicAdd" matches the argument list
            argument types are: (half *, __half)
          detected during:
            instantiation of "void cv::dnn::cuda4dnn::kernels::raw::reduce_sum_abs(cv::dnn::cuda4dnn::csl::Span<T>, cv::dnn::cuda4dnn::csl::View<T>, cv::dnn::cuda4dnn::csl::device::size_type, cv::dnn::cuda4dnn::csl::device::size_type) [with T=__half]" 
(96): here
            instantiation of "void cv::dnn::cuda4dnn::kernels::normalize(const cv::dnn::cuda4dnn::csl::Stream &, cv::dnn::cuda4dnn::csl::Span<T>, cv::dnn::cuda4dnn::csl::View<T>, std::size_t, std::size_t, std::size_t, std::size_t, T, cv::dnn::cuda4dnn::csl::Span<T>) [with T=__half]" 
(119): here
/root/opencv/modules/dnn/src/cuda/normalize.cu(55): error: no instance of overloaded function "atomicAdd" matches the argument list
            argument types are: (half *, __half)
          detected during:
            instantiation of "void cv::dnn::cuda4dnn::kernels::raw::reduce_sum_squared(cv::dnn::cuda4dnn::csl::Span<T>, cv::dnn::cuda4dnn::csl::View<T>, cv::dnn::cuda4dnn::csl::device::size_type, cv::dnn::cuda4dnn::csl::device::size_type) [with T=__half]" 
(104): here
            instantiation of "void cv::dnn::cuda4dnn::kernels::normalize(const cv::dnn::cuda4dnn::csl::Stream &, cv::dnn::cuda4dnn::csl::Span<T>, cv::dnn::cuda4dnn::csl::View<T>, std::size_t, std::size_t, std::size_t, std::size_t, T, cv::dnn::cuda4dnn::csl::Span<T>) [with T=__half]" 
(119): here
2 errors detected in the compilation of "/tmp/tmpxft_00005435_00000000-13_normalize.compute_70.cpp1.ii".
-- Removing /root/opencv/build/modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_normalize.cu.o
/usr/bin/cmake -E remove /root/opencv/build/modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_normalize.cu.o
CMake Error at cuda_compile_generated_normalize.cu.o.cmake:266 (message):
  Error generating file
  /root/opencv/build/modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_normalize.cu.o
modules/dnn/CMakeFiles/opencv_dnn.dir/build.make:119: recipe for target 'modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_normalize.cu.o' failed
make[2]: *** [modules/dnn/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_normalize.cu.o] Error 1
make[2]: Leaving directory '/root/opencv/build'
CMakeFiles/Makefile2:5880: recipe for target 'modules/dnn/CMakeFiles/opencv_dnn.dir/all' failed
make[1]: *** [modules/dnn/CMakeFiles/opencv_dnn.dir/all] Error 2
make[1]: Leaving directory '/root/opencv/build'
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2

build image using below Dockerfile

#!/usr/bin/env bash

FROM nvidia/cuda:9.2-cudnn7-devel-ubuntu16.04

RUN apt-get update && apt-get install -y --no-install-recommends \
        rsync \
        htop \
        openssh-server \
        build-essential \
        cmake \
        git \
        curl \
        vim \
        ca-certificates \
        libjpeg-dev \
        libpng-dev \
        software-properties-common \
    libatlas-base-dev \
    libpng-dev \
    libjpeg-dev \
    swig && \
        rm -rf /var/lib/apt/lists/*

# Open-cv related
RUN apt-get update && apt-get install -y \
        python-opencv \
        libavcodec-dev \
        libavformat-dev \
        libav-tools \
        libavresample-dev \
        libdc1394-22-dev \
        libgdal-dev \
        libgphoto2-dev \
        libgtk2.0-dev \
        libjasper-dev \
        libopencore-amrnb-dev \
        libopencore-amrwb-dev \
        libopencv-dev \
        libopenexr-dev \
        libswscale-dev \
        libtbb2 \
        libtbb-dev \
        libtheora-dev \
        libv4l-dev \
        libvorbis-dev \
        libvtk6-dev \
        libx264-dev \
        libxine2-dev \
        libxvidcore-dev \
        qt5-default \
        && \
    apt-get clean && \
    apt-get autoremove && \
    rm -rf /var/lib/apt/lists/*

# install python2.7 & python3.5
RUN add-apt-repository ppa:deadsnakes/ppa && apt-get update
RUN apt-get install -y python-pip python3-pip zsh

# dotfiles and personal terminal config
## bash aliases
RUN echo '#!/bin/bash \nalias python=python3\nalias pip=pip3' >> ~/.bash_aliases && \
        chmod -x ~/.bash_aliases

RUN rm -rf /usr/bin/python && ln -s /usr/bin/python3.5 /usr/bin/python

# Open-cv
RUN cd ~/ &&\
    git clone https://github.com/Itseez/opencv.git &&\
    git clone https://github.com/Itseez/opencv_contrib.git &&\
    cd opencv && \
    mkdir build && \
    cd build && \
    cmake -D CMAKE_BUILD_TYPE=RELEASE \
        -DWITH_QT=ON \
        -DWITH_OPENGL=ON \
        -D WITH_CUDA=ON \
        -D ENABLE_FAST_MATH=1 \
        -D CUDA_FAST_MATH=1 \
        -D WITH_CUBLAS=1 \
        -DFORCE_VTK=ON \
        -DWITH_TBB=ON \
        -DWITH_GDAL=ON \
        -DWITH_XINE=ON \
        -DBUILD_EXAMPLES=ON \
        -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
        -D WITH_FFMPEG=1 \
        -D WITH_LIBV4L=1 \
        .. && \
    make VERBOSE=1 && \
    #make -j"$(nproc)" && \
    make install && \
    ldconfig && \
 # Remove the opencv folders to reduce image size
    rm -rf ~/opencv* && \
    echo 'ln /dev/null /dev/raw1394' >> ~/.bashrc

# CMD
CMD /bin/bash