在 docker 容器中构建 dlib 失败

Posted

技术标签:

【中文标题】在 docker 容器中构建 dlib 失败【英文标题】:Building dlib fails in docker container 【发布时间】:2021-12-02 22:22:30 【问题描述】:

问题

我有一个 docker 映像,可以在我的本地计算机 (Ubuntu 20.04) 上构建良好,但在编译 dlib 时在共享的 Linode 上失败。而且我完全不知道为什么会这样。

有人知道或知道该怎么做吗?我认为它与底层硬件有关,但我知道什么......

更多背景

Docker 和 Docker Compose 版本在两个系统上是相同的 满足构建 dlib 的所有要求(由我成功的本地构建证明) 我有一张基于nvidia/cuda:11.0.3-cudnn8-runtime-ubuntu20.04 的图片 由于我认为 Linode 上缺少的 GPU 与此有关,我尝试使用几种方法在没有 GPU 支持的情况下编译 dlib。没有工作 最后,图像公开了一个 Django API,该 API 执行大量机器学习工作(使用例如 spacy 或人脸识别)。

错误信息

Installing collected packages: dlib
      Running setup.py install for dlib: started
      Running setup.py install for dlib: still running...
      Running setup.py install for dlib: still running...
      Running setup.py install for dlib: still running...
      Running setup.py install for dlib: still running...
      Running setup.py install for dlib: still running...
      Running setup.py install for dlib: still running...
      Running setup.py install for dlib: still running...
      Running setup.py install for dlib: still running...
      Running setup.py install for dlib: still running...
      Running setup.py install for dlib: still running...
      Running setup.py install for dlib: finished with status 'error'
      ERROR: Command errored out with exit status 1:
       command: /home/picwise/.pyenv/versions/3.7.11/bin/python3.7 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-owm_69xz/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-owm_69xz/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-4bup0pba/install-record.txt --single-version-externally-managed --compile --install-headers /home/picwise/.pyenv/versions/3.7.11/include/python3.7m/dlib
           cwd: /tmp/pip-req-build-owm_69xz/
      Complete output (267 lines):
      running install
      running build
      running build_py
      package init file 'tools/python/dlib/__init__.py' not found (or not a regular file)
      running build_ext
      Building extension for Python 3.7.11 (default, Oct  4 2021, 20:45:45)
      Invoking CMake setup: 'cmake /tmp/pip-req-build-owm_69xz/tools/python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/tmp/pip-req-build-owm_69xz/build/lib.linux-x86_64-3.7 -DPYTHON_EXECUTABLE=/home/picwise/.pyenv/versions/3.7.11/bin/python3.7 -DCMAKE_BUILD_TYPE=Release'
      -- The C compiler identification is GNU 9.3.0
      -- The CXX compiler identification is GNU 9.3.0
      -- Check for working C compiler: /usr/bin/cc
      -- Check for working C compiler: /usr/bin/cc -- works
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - done
      -- Detecting C compile features
      -- Detecting C compile features - done
      -- Check for working CXX compiler: /usr/bin/c++
      -- Check for working CXX compiler: /usr/bin/c++ -- works
      -- Detecting CXX compiler ABI info
      -- Detecting CXX compiler ABI info - done
      -- Detecting CXX compile features
      -- Detecting CXX compile features - done
      -- Found PythonInterp: /home/picwise/.pyenv/versions/3.7.11/bin/python3.7 (found version "3.7.11")
      -- Found PythonLibs: /home/picwise/.pyenv/versions/3.7.11/lib/libpython3.7m.a
      -- Performing Test HAS_CPP14_FLAG
      -- Performing Test HAS_CPP14_FLAG - Success
      -- pybind11 v2.2.4
      -- Using CMake version: 3.16.3
      -- Compiling dlib version: 19.22.1
      -- SSE4 instructions can be executed by the host processor.
      -- AVX instructions can be executed by the host processor.
      -- Enabling AVX instructions
      -- Looking for pthread.h
      -- Looking for pthread.h - found
      -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
      -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
      -- Looking for pthread_create in pthreads
      -- Looking for pthread_create in pthreads - not found
      -- Looking for pthread_create in pthread
      -- Looking for pthread_create in pthread - found
      -- Found Threads: TRUE
      -- Could NOT find X11 (missing: X11_X11_INCLUDE_PATH X11_X11_LIB)
       *****************************************************************************
       *** DLIB GUI SUPPORT DISABLED BECAUSE X11 DEVELOPMENT LIBRARIES NOT FOUND ***
       *** Make sure libx11-dev is installed if you want GUI support.            ***
       *** On Ubuntu run: sudo apt-get install libx11-dev                        ***
       *****************************************************************************
      -- Searching for BLAS and LAPACK
      -- Searching for BLAS and LAPACK
      -- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1")
      -- Checking for module 'cblas'
      --   No package 'cblas' found
      -- Checking for module 'lapack'
      --   No package 'lapack' found
      -- Looking for cblas_ddot
      -- Looking for cblas_ddot - not found
      -- Looking for sys/types.h
      -- Looking for sys/types.h - found
      -- Looking for stdint.h
      -- Looking for stdint.h - found
      -- Looking for stddef.h
      -- Looking for stddef.h - found
      -- Check size of void*
      -- Check size of void* - done
       *****************************************************************************
       *** No BLAS library found so using dlib's built in BLAS.  However, if you ***
       *** install an optimized BLAS such as OpenBLAS or the Intel MKL your code ***
       *** will run faster.  On Ubuntu you can install OpenBLAS by executing:    ***
       ***    sudo apt-get install libopenblas-dev liblapack-dev                 ***
       *** Or you can easily install OpenBLAS from source by downloading the     ***
       *** source tar file from http://www.openblas.net, extracting it, and      ***
       *** running:                                                              ***
       ***    make; sudo make install                                            ***
       *****************************************************************************
      CUDA_TOOLKIT_ROOT_DIR not found or specified
      -- Could NOT find CUDA (missing: CUDA_TOOLKIT_ROOT_DIR CUDA_NVCC_EXECUTABLE CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY) (Required is at least version "7.5")
      -- Found CUDA, but CMake was unable to find the cuBLAS libraries that should be part of every basic CUDA install. Your CUDA install is somehow broken or incomplete. Since cuBLAS is required for dlib to use CUDA we won't use CUDA.
      -- DID NOT FIND CUDA
      -- Disabling CUDA support for dlib.  DLIB WILL NOT USE CUDA
      -- C++11 activated.
      -- Configuring done
      -- Generating done
      -- Build files have been written to: /tmp/pip-req-build-owm_69xz/build/temp.linux-x86_64-3.7
      Invoking CMake build: 'cmake --build . --config Release -- -j1'
      Scanning dependencies of target dlib
      [  1%] Building CXX object dlib_build/CMakeFiles/dlib.dir/base64/base64_kernel_1.cpp.o
      [  2%] Building CXX object dlib_build/CMakeFiles/dlib.dir/bigint/bigint_kernel_1.cpp.o
      [  2%] Building CXX object dlib_build/CMakeFiles/dlib.dir/bigint/bigint_kernel_2.cpp.o
      [  3%] Building CXX object dlib_build/CMakeFiles/dlib.dir/bit_stream/bit_stream_kernel_1.cpp.o
      [  4%] Building CXX object dlib_build/CMakeFiles/dlib.dir/entropy_decoder/entropy_decoder_kernel_1.cpp.o
      [  4%] Building CXX object dlib_build/CMakeFiles/dlib.dir/entropy_decoder/entropy_decoder_kernel_2.cpp.o
      [  5%] Building CXX object dlib_build/CMakeFiles/dlib.dir/entropy_encoder/entropy_encoder_kernel_1.cpp.o
      [  5%] Building CXX object dlib_build/CMakeFiles/dlib.dir/entropy_encoder/entropy_encoder_kernel_2.cpp.o
      [  6%] Building CXX object dlib_build/CMakeFiles/dlib.dir/md5/md5_kernel_1.cpp.o
      [  7%] Building CXX object dlib_build/CMakeFiles/dlib.dir/tokenizer/tokenizer_kernel_1.cpp.o
      [  7%] Building CXX object dlib_build/CMakeFiles/dlib.dir/unicode/unicode.cpp.o
      [  8%] Building CXX object dlib_build/CMakeFiles/dlib.dir/test_for_odr_violations.cpp.o
      [  9%] Building CXX object dlib_build/CMakeFiles/dlib.dir/sockets/sockets_kernel_1.cpp.o
      [  9%] Building CXX object dlib_build/CMakeFiles/dlib.dir/bsp/bsp.cpp.o
      [ 10%] Building CXX object dlib_build/CMakeFiles/dlib.dir/dir_nav/dir_nav_kernel_1.cpp.o
      [ 11%] Building CXX object dlib_build/CMakeFiles/dlib.dir/dir_nav/dir_nav_kernel_2.cpp.o
      [ 11%] Building CXX object dlib_build/CMakeFiles/dlib.dir/dir_nav/dir_nav_extensions.cpp.o
      [ 12%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_widgets/fonts.cpp.o
      [ 13%] Building CXX object dlib_build/CMakeFiles/dlib.dir/linker/linker_kernel_1.cpp.o
      [ 13%] Building CXX object dlib_build/CMakeFiles/dlib.dir/logger/extra_logger_headers.cpp.o
      [ 14%] Building CXX object dlib_build/CMakeFiles/dlib.dir/logger/logger_kernel_1.cpp.o
      [ 14%] Building CXX object dlib_build/CMakeFiles/dlib.dir/logger/logger_config_file.cpp.o
      [ 15%] Building CXX object dlib_build/CMakeFiles/dlib.dir/misc_api/misc_api_kernel_1.cpp.o
      [ 16%] Building CXX object dlib_build/CMakeFiles/dlib.dir/misc_api/misc_api_kernel_2.cpp.o
      [ 16%] Building CXX object dlib_build/CMakeFiles/dlib.dir/sockets/sockets_extensions.cpp.o
      [ 17%] Building CXX object dlib_build/CMakeFiles/dlib.dir/sockets/sockets_kernel_2.cpp.o
      [ 18%] Building CXX object dlib_build/CMakeFiles/dlib.dir/sockstreambuf/sockstreambuf.cpp.o
      [ 18%] Building CXX object dlib_build/CMakeFiles/dlib.dir/sockstreambuf/sockstreambuf_unbuffered.cpp.o
      [ 19%] Building CXX object dlib_build/CMakeFiles/dlib.dir/server/server_kernel.cpp.o
      [ 20%] Building CXX object dlib_build/CMakeFiles/dlib.dir/server/server_iostream.cpp.o
      [ 20%] Building CXX object dlib_build/CMakeFiles/dlib.dir/server/server_http.cpp.o
      [ 21%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/multithreaded_object_extension.cpp.o
      [ 22%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/threaded_object_extension.cpp.o
      [ 22%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/threads_kernel_1.cpp.o
      [ 23%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/threads_kernel_2.cpp.o
      [ 24%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/threads_kernel_shared.cpp.o
      [ 24%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/thread_pool_extension.cpp.o
      [ 25%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/async.cpp.o
      [ 25%] Building CXX object dlib_build/CMakeFiles/dlib.dir/timer/timer.cpp.o
      [ 26%] Building CXX object dlib_build/CMakeFiles/dlib.dir/stack_trace.cpp.o
      [ 27%] Building CXX object dlib_build/CMakeFiles/dlib.dir/cuda/cpu_dlib.cpp.o
      [ 27%] Building CXX object dlib_build/CMakeFiles/dlib.dir/cuda/tensor_tools.cpp.o
      [ 28%] Building CXX object dlib_build/CMakeFiles/dlib.dir/data_io/image_dataset_metadata.cpp.o
      [ 29%] Building CXX object dlib_build/CMakeFiles/dlib.dir/data_io/mnist.cpp.o
      [ 29%] Building CXX object dlib_build/CMakeFiles/dlib.dir/data_io/cifar.cpp.o
      [ 30%] Building CXX object dlib_build/CMakeFiles/dlib.dir/global_optimization/global_function_search.cpp.o
      [ 31%] Building CXX object dlib_build/CMakeFiles/dlib.dir/filtering/kalman_filter.cpp.o
      In file included from /tmp/pip-req-build-owm_69xz/dlib/filtering/../matrix.h:11,
                       from /tmp/pip-req-build-owm_69xz/dlib/filtering/kalman_filter.h:7,
                       from /tmp/pip-req-build-owm_69xz/dlib/filtering/kalman_filter.cpp:6:
      /tmp/pip-req-build-owm_69xz/dlib/filtering/../matrix/matrix_la.h: In function ‘long int dlib::svd4(dlib::svd_u_mode, bool, const dlib::matrix_exp<EXP>&, dlib::matrix<typename EXP::type, uM, uN, MM1, L1>&, dlib::matrix<typename EXP::type, qN, qX, MM2, L1>&, dlib::matrix<typename EXP::type, vM, vN, MM3, L1>&) [with EXP = dlib::matrix_op<dlib::op_trans<dlib::matrix_op<dlib::op_trans<dlib::matrix<double, 1, 2, dlib::memory_manager_stateless_kernel_1<char>, dlib::row_major_layout> > > > >; long int qN = 1; long int qX = 1; long int uM = 1; long int uN = 1; long int vM = 2; long int vN = 1; MM1 = dlib::memory_manager_stateless_kernel_1<char>; MM2 = dlib::memory_manager_stateless_kernel_1<char>; MM3 = dlib::memory_manager_stateless_kernel_1<char>; L1 = dlib::row_major_layout]’:
      /tmp/pip-req-build-owm_69xz/dlib/filtering/../matrix/matrix_la.h:225:32: warning: iteration 1 invokes undefined behavior [-Waggressive-loop-optimizations]
        225 |             y = abs(q(i)) + abs(e(i));
            |                             ~~~^~~~~~
      /tmp/pip-req-build-owm_69xz/dlib/filtering/../matrix/matrix_la.h:163:20: note: within this loop
        163 |         for (i=0; i<n; i++)
            |                   ~^~
      [ 31%] Building CXX object dlib_build/CMakeFiles/dlib.dir/svm/auto.cpp.o
      [ 32%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libpng/arm/arm_init.c.o
      [ 33%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libpng/arm/filter_neon_intrinsics.c.o
      [ 33%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libpng/png.c.o
      [ 34%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libpng/pngerror.c.o
      [ 34%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libpng/pngget.c.o
      [ 35%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libpng/pngmem.c.o
      [ 36%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libpng/pngpread.c.o
      [ 36%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libpng/pngread.c.o
      [ 37%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libpng/pngrio.c.o
      [ 38%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libpng/pngrtran.c.o
      [ 38%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libpng/pngrutil.c.o
      [ 39%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libpng/pngset.c.o
      [ 40%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libpng/pngtrans.c.o
      [ 40%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libpng/pngwio.c.o
      [ 41%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libpng/pngwrite.c.o
      [ 42%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libpng/pngwtran.c.o
      [ 42%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libpng/pngwutil.c.o
      [ 43%] Building C object dlib_build/CMakeFiles/dlib.dir/external/zlib/adler32.c.o
      [ 44%] Building C object dlib_build/CMakeFiles/dlib.dir/external/zlib/compress.c.o
      [ 44%] Building C object dlib_build/CMakeFiles/dlib.dir/external/zlib/crc32.c.o
      [ 45%] Building C object dlib_build/CMakeFiles/dlib.dir/external/zlib/deflate.c.o
      [ 45%] Building C object dlib_build/CMakeFiles/dlib.dir/external/zlib/gzclose.c.o
      [ 46%] Building C object dlib_build/CMakeFiles/dlib.dir/external/zlib/gzlib.c.o
      [ 47%] Building C object dlib_build/CMakeFiles/dlib.dir/external/zlib/gzread.c.o
      [ 47%] Building C object dlib_build/CMakeFiles/dlib.dir/external/zlib/gzwrite.c.o
      [ 48%] Building C object dlib_build/CMakeFiles/dlib.dir/external/zlib/infback.c.o
      [ 49%] Building C object dlib_build/CMakeFiles/dlib.dir/external/zlib/inffast.c.o
      [ 49%] Building C object dlib_build/CMakeFiles/dlib.dir/external/zlib/inflate.c.o
      [ 50%] Building C object dlib_build/CMakeFiles/dlib.dir/external/zlib/inftrees.c.o
      [ 51%] Building C object dlib_build/CMakeFiles/dlib.dir/external/zlib/trees.c.o
      [ 51%] Building C object dlib_build/CMakeFiles/dlib.dir/external/zlib/uncompr.c.o
      [ 52%] Building C object dlib_build/CMakeFiles/dlib.dir/external/zlib/zutil.c.o
      [ 53%] Building CXX object dlib_build/CMakeFiles/dlib.dir/image_loader/png_loader.cpp.o
      [ 53%] Building CXX object dlib_build/CMakeFiles/dlib.dir/image_saver/save_png.cpp.o
      [ 54%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jaricom.c.o
      [ 54%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jcapimin.c.o
      [ 55%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jcapistd.c.o
      [ 56%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jcarith.c.o
      [ 56%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jccoefct.c.o
      [ 57%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jccolor.c.o
      [ 58%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jcdctmgr.c.o
      [ 58%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jchuff.c.o
      [ 59%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jcinit.c.o
      [ 60%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jcmainct.c.o
      [ 60%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jcmarker.c.o
      [ 61%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jcmaster.c.o
      [ 62%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jcomapi.c.o
      [ 62%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jcparam.c.o
      [ 63%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jcprepct.c.o
      [ 64%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jcsample.c.o
      [ 64%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jdapimin.c.o
      [ 65%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jdapistd.c.o
      [ 65%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jdarith.c.o
      [ 66%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jdatadst.c.o
      [ 67%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jdatasrc.c.o
      [ 67%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jdcoefct.c.o
      [ 68%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jdcolor.c.o
      [ 69%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jddctmgr.c.o
      [ 69%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jdhuff.c.o
      [ 70%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jdinput.c.o
      [ 71%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jdmainct.c.o
      [ 71%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jdmarker.c.o
      [ 72%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jdmaster.c.o
      [ 73%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jdmerge.c.o
      [ 73%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jdpostct.c.o
      [ 74%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jdsample.c.o
      [ 74%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jerror.c.o
      [ 75%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jfdctflt.c.o
      [ 76%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jfdctfst.c.o
      [ 76%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jfdctint.c.o
      [ 77%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jidctflt.c.o
      [ 78%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jidctfst.c.o
      [ 78%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jidctint.c.o
      [ 79%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jmemmgr.c.o
      [ 80%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jmemnobs.c.o
      [ 80%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jquant1.c.o
      [ 81%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jquant2.c.o
      [ 82%] Building C object dlib_build/CMakeFiles/dlib.dir/external/libjpeg/jutils.c.o
      [ 82%] Building CXX object dlib_build/CMakeFiles/dlib.dir/image_loader/jpeg_loader.cpp.o
      [ 83%] Building CXX object dlib_build/CMakeFiles/dlib.dir/image_saver/save_jpeg.cpp.o
      [ 84%] Linking CXX static library libdlib.a
      [ 84%] Built target dlib
      Scanning dependencies of target _dlib_pybind11
      [ 84%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/dlib.cpp.o
      [ 85%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/matrix.cpp.o
      [ 85%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/vector.cpp.o
      [ 86%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/svm_c_trainer.cpp.o
      c++: fatal error: Killed signal terminated program cc1plus
      compilation terminated.
      make[2]: *** [CMakeFiles/_dlib_pybind11.dir/build.make:102: CMakeFiles/_dlib_pybind11.dir/src/svm_c_trainer.cpp.o] Error 1
      make[1]: *** [CMakeFiles/Makefile2:117: CMakeFiles/_dlib_pybind11.dir/all] Error 2
      make: *** [Makefile:84: all] Error 2
      Traceback (most recent call last):
        File "<string>", line 1, in <module>
        File "/tmp/pip-req-build-owm_69xz/setup.py", line 261, in <module>
          'Topic :: Software Development',
        File "/home/picwise/.pyenv/versions/3.7.11/lib/python3.7/site-packages/setuptools/__init__.py", line 144, in setup
          return distutils.core.setup(**attrs)
        File "/home/picwise/.pyenv/versions/3.7.11/lib/python3.7/distutils/core.py", line 148, in setup
          dist.run_commands()
        File "/home/picwise/.pyenv/versions/3.7.11/lib/python3.7/distutils/dist.py", line 966, in run_commands
          self.run_command(cmd)
        File "/home/picwise/.pyenv/versions/3.7.11/lib/python3.7/distutils/dist.py", line 985, in run_command
          cmd_obj.run()
        File "/home/picwise/.pyenv/versions/3.7.11/lib/python3.7/site-packages/setuptools/command/install.py", line 61, in run
          return orig.install.run(self)
        File "/home/picwise/.pyenv/versions/3.7.11/lib/python3.7/distutils/command/install.py", line 545, in run
          self.run_command('build')
        File "/home/picwise/.pyenv/versions/3.7.11/lib/python3.7/distutils/cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "/home/picwise/.pyenv/versions/3.7.11/lib/python3.7/distutils/dist.py", line 985, in run_command
          cmd_obj.run()
        File "/home/picwise/.pyenv/versions/3.7.11/lib/python3.7/distutils/command/build.py", line 135, in run
          self.run_command(cmd_name)
        File "/home/picwise/.pyenv/versions/3.7.11/lib/python3.7/distutils/cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "/home/picwise/.pyenv/versions/3.7.11/lib/python3.7/distutils/dist.py", line 985, in run_command
          cmd_obj.run()
        File "/tmp/pip-req-build-owm_69xz/setup.py", line 134, in run
          self.build_extension(ext)
        File "/tmp/pip-req-build-owm_69xz/setup.py", line 174, in build_extension
          subprocess.check_call(cmake_build, cwd=build_folder)
        File "/home/picwise/.pyenv/versions/3.7.11/lib/python3.7/subprocess.py", line 363, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--config', 'Release', '--', '-j1']' returned non-zero exit status 2.
      ----------------------------------------
  ERROR: Command errored out with exit status 1: /home/picwise/.pyenv/versions/3.7.11/bin/python3.7 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-owm_69xz/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-owm_69xz/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-4bup0pba/install-record.txt --single-version-externally-managed --compile --install-headers /home/picwise/.pyenv/versions/3.7.11/include/python3.7m/dlib Check the logs for full command output.
  

  at /home.pyenv/versions/3.7.11/lib/python3.7/site-packages/poetry/utils/env.py:1075 in _run
      1071│                 output = subprocess.check_output(
      1072│                     cmd, stderr=subprocess.STDOUT, **kwargs
      1073│                 )
      1074│         except CalledProcessError as e:
    → 1075│             raise EnvCommandError(e, input=input_)
      1076│ 
      1077│         return decode(output)
      1078│ 
      1079│     def execute(self, bin, *args, **kwargs):

The command '/bin/bash -o pipefail -c poetry install     $(test \"$PICWISE_DJANGO_ENVIRONMENT\" == production && echo \"--no-dev\")     --no-interaction     --no-ansi' returned a non-zero code: 1

【问题讨论】:

【参考方案1】:

我通过将我的 Linode 升级到 dedicated CPU plan 解决了这个问题。这样做之后,一切都按预期工作。

对我来说这个问题已经解决了,但我仍然很好奇为什么这在共享系统上不起作用...如果有人知道,请赐教!

【讨论】:

以上是关于在 docker 容器中构建 dlib 失败的主要内容,如果未能解决你的问题,请参考以下文章

Docker 命令在构建期间失败,但在正在运行的容器中执行时成功

面对这个错误文件构建docker镜像dlib

在 Docker 容器上使用 mysql 数据库的 Spring Boot 应用程序的 Maven 安装构建失败

为啥在 `npm install` 时`package-lock.json` 会导致 docker 容器构建失败?

为 Windows 安装 dlib:“dlib 构建轮失败”和“非零退出状态 1”

Ubuntu Python:无法 pip install dlib - dlib 构建轮失败,机器几乎卡住