docker / buildx

Docker CLI plugin for extended build capabilities with BuildKit
Apache License 2.0
3.54k stars 479 forks source link

Segmentation Fault - cmake (qemu) #365

Closed herbyme closed 4 years ago

herbyme commented 4 years ago

Command: docker buildx build --push -t docker.io/blah --platform=linux/arm64 . -f ./Dockerfile OS Info: Mac OS X Catalina with qemu (v5.1.0) and docker installed (19.03.12) python (v3.6.5) Compiling for Target: Nvidia Jetson Nano (LT4-Base)

This works for other packages. When compiling (using cmake in Dockerfile) for opencv-python getting the following error:

#11 5981.   Building wheel for opencv-python (PEP 517): started
#11 5985.   Building wheel for opencv-python (PEP 517): finished with status 'error'
#11 5985.   ERROR: Command errored out with exit status 1:
#11 5985.    command: /usr/bin/python3 /usr/local/lib/python3.6/dist-packages/pip/_vendor/pep517/_in_process.py build_wheel /tmp/tmpeq59r_jg
#11 5985.        cwd: /tmp/pip-install-pdwkvbfj/opencv-python
#11 5985.   Complete output (10 lines):
#11 5985.   qemu: uncaught target signal 11 (Segmentation fault) - core dumped
#11 5985.     File "/tmp/pip-build-env-e1wkf5p0/overlay/lib/python3.6/site-packages/skbuild/setuptools_wrap.py", line 560, in setup
#11 5985.       cmkr = cmaker.CMaker(cmake_executable)
#11 5985.     File "/tmp/pip-build-env-e1wkf5p0/overlay/lib/python3.6/site-packages/skbuild/cmaker.py", line 95, in __init__
#11 5985.       self.cmake_version = get_cmake_version(self.cmake_executable)
#11 5985.     File "/tmp/pip-build-env-e1wkf5p0/overlay/lib/python3.6/site-packages/skbuild/cmaker.py", line 82, in get_cmake_version
#11 5985.       "Problem with the CMake installation, aborting build. CMake executable is %s" % cmake_executable)
#11 5985.   Traceback (most recent call last):
#11 5985.
#11 5985.   Problem with the CMake installation, aborting build. CMake executable is cmake
#11 5985.   ----------------------------------------
#11 5985.   ERROR: Failed building wheel for opencv-python
#11 5985. Successfully built numpy
#11 5985. Failed to build opencv-python
#11 5985. ERROR: Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly

Dockerfile:

ARG JETPACK_VERSION=r32.4.3
ARG OPENCV_GPU_ARCH=5.3
ARG OPENCV_VER=4.4.0
FROM nvcr.io/nvidia/l4t-base:${JETPACK_VERSION}

RUN apt-get update && DEBIAN_FRONTEND=noninteractive \
  && apt-get -y install --no-install-recommends tzdata \
  && apt-get -y install wget git bzip2 locales curl \
        build-essential \
        cmake \
        git \
        gfortran \
        libatlas-base-dev \
        libavcodec-dev \
        libavformat-dev \
        libavresample-dev \
        libcanberra-gtk3-module \
        libdc1394-22-dev \
        libeigen3-dev \
        libglew-dev \
        libgstreamer-plugins-base1.0-dev \
        libgstreamer-plugins-good1.0-dev \
        libgstreamer1.0-dev \
        libgtk-3-dev \
        libjpeg-dev \
        libjpeg8-dev \
        libjpeg-turbo8-dev \
        liblapack-dev \
        liblapacke-dev \
        libopenblas-dev \
        libpng-dev \
        libpostproc-dev \
        libswscale-dev \
        libtbb-dev \
        libtbb2 \
        libtesseract-dev \
        libtiff-dev \
        libv4l-dev \
        libxine2-dev \
        libxvidcore-dev \
        libx264-dev \
        pkg-config \
        python-dev \
        python-numpy \
        python3-dev \
        python3-numpy \
        python3-pip \
        python3-matplotlib \
        qv4l2 \
        v4l-utils \
        v4l2ucp \
        zlib1g-dev \
  && rm -rf /var/lib/apt/lists/*

RUN python3 -m pip install --upgrade pip
RUN pip3 install --upgrade pip setuptools wheel

RUN curl -L https://github.com/opencv/opencv/archive/${OPENCV_VER}.zip -o opencv-${OPENCV_VER}zip
RUN curl -L https://github.com/opencv/opencv_contrib/archive/${OPENCV_VER}.zip -o opencv_contrib-${OPENCV_VER}.zip
RUN unzip opencv-${OPENCV_VER}.zip
RUN unzip opencv_contrib-${OPENCV_VER}.zip
RUN cd opencv-${OPENCV_VER}/

RUN cmake -D CMAKE_BUILD_TYPE=Release \
  #-D PYTHON3_EXECUTABLE=/usr/bin/python3 \
  -D OPENCV_GENERATE_PKGCONFIG=ON \
  -D WITH_CUDA=ON \
  -D WITH_CUDNN=ON \
  -D CUDA_ARCH_BIN=${OPENCV_GPU_ARCH} \
  -D CUDA_ARCH_PTX="" \
  -D OPENCV_EXTRA_MODULES_PATH=/tmp/opencv/opencv_contrib-${OPENCV_VER}/modules/  /tmp/opencv/opencv-${OPENCV_VER}/ \
  -D WITH_FFMPEG=ON \
  -D WITH_GSTREAMER=ON \
  -D WITH_GSTREAMER_0_10=OFF \
  -D WITH_LIBV4L=ON \
  -D WITH_OPENGL=ON \
  -D BUILD_opencv_python=OFF \
  -D BUILD_opencv_python2=ON \
  -D BUILD_opencv_python3=ON \
  -D BUILD_TESTS=OFF \
  -D BUILD_PERF_TESTS=OFF \
  -D BUILD_EXAMPLES=OFF \
  -D CMAKE_BUILD_TYPE=RELEASE \
  -D ENABLE_FAST_MATH=ON \
  -D CUDA_FAST_MATH=ON \
  -D WITH_CUBLAS=ON \
  -D CUDNN_VERSION="8.0" \
  -D ENABLE_NEON=ON \
  -D OPENCV_DNN_CUDA=ON \
  -D BUILD_PNG=OFF \
  -D BUILD_TIFF=OFF \
  -D BUILD_TBB=OFF \
  -D BUILD_JPEG=OFF \
  -D BUILD_JASPER=OFF \
  -D BUILD_ZLIB=OFF \
  -D BUILD_JAVA=OFF \
  -D BUILD_opencv_nonfree=OFF \
  -D ENABLE_PRECOMPILED_HEADERS=OFF \
  -D WITH_OPENCL=OFF \
  -D WITH_OPENMP=OFF \
  -D CMAKE_INSTALL_PREFIX=/usr/local ..

RUN make -j5
herbyme commented 4 years ago

Looks like the issue pertains to the nvidia docker image I'm using: FROM nvcr.io/nvidia/l4t-base:r32.4.3

Note if you use another base image this does not exhibit the same issue e.g. https://hub.docker.com/r/mdegans/tegra-opencv/tags