简体   繁体   English

从 Dockerfile 构建 docker 镜像失败,但不是手动构建

[英]Building docker image is failing from Dockerfile but not by hand

I have a Dockerfile where one of the step is compiling opencv.我有一个 Dockerfile,其中一个步骤是编译 opencv。 The process fails if executed within a docker build, but it works if I execute each step by hand interactively.如果在 docker build 中执行,该过程会失败,但如果我以交互方式手动执行每个步骤,则它会起作用。

Do you have any suggestions?你有什么建议吗?

This is the docker file:这是泊坞窗文件:

FROM nvcr.io/nvidia/l4t-base:r32.4.4
RUN apt-get update; apt-get -y upgrade
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential pkg-config  libtbb2 libtbb-dev  libavcodec-dev libavformat-dev libswscale-dev libxvidcore-dev libavresample-dev libtiff-dev libjpeg-dev libpng-dev python-tk libgtk-3-dev libcanberra-gtk-module libcanberra-gtk3-module libv4l-dev libdc1394-22-dev cmake python3-dev python-dev python-numpy python3-numpy ccache
RUN mkdir /src; wget -O /src/opencv-3.4.0.tar.gz https://github.com/opencv/opencv/archive/3.4.0.tar.gz; wget -O /src/opencv_contrib-3.4.0.tar.gz https://github.com/opencv/opencv_contrib/archive/3.4.0.tar.gz; cd /src/; tar xzf opencv-3.4.0.tar.gz; tar xzf opencv_contrib-3.4.0.tar.gz; rm -f /src/*gz
RUN cd /src/opencv-3.4.0; mkdir build; cd build; LD_LIBRARY_PATH=/usr/local/cuda/lib64:/usr/local/cuda-10.2/targets/aarch64-linux/lib; PATH=/usr/local/cuda-10.2/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX:PATH=/opt/opencv/3.4.0 -D WITH_CUDA=ON -D CUDA_ARCH_PTX="" -D CUDA_ARCH_BIN="5.3,6.2,7.2" -D WITH_CUBLAS=ON -D WITH_LIBV4L=ON -D BUILD_opencv_python3=ON -D BUILD_opencv_python2=ON -D BUILD_opencv_java=OFF -D WITH_GSTREAMER=ON -D WITH_GTK=ON -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF -D OPENCV_ENABLE_NONFREE=ON -DCUDA_CUDA_LIBRARY=/usr/local/cuda-10.2/targets/aarch64-linux/lib/stubs/libcuda.so -D OPENCV_EXTRA_MODULES_PATH=/src/opencv_contrib-3.4.0/modules ..
RUN cd /src/opencv-3.4.0/build; make -j4

And this is the error:这是错误:

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CUDA_cublas_LIBRARY (ADVANCED)
    linked by target "opencv_cudev" in directory /src/opencv-3.4.0/modules/cudev
    linked by target "opencv_core" in directory /src/opencv-3.4.0/modules/core
    linked by target "opencv_cudaarithm" in directory /src/opencv-3.4.0/modules/cudaarithm

(the output is too long and the website doesn't allow me to paste the full one) (输出太长,网站不允许我粘贴完整的)

Once again the same steps run interactively into the container are working well.以交互方式运行到容器中的相同步骤再次运行良好。

Thanks谢谢

So I found the answer here , thanks to the hint in the comments of my initial post.所以我在这里找到了答案,这要感谢我最初帖子的评论中的提示。

This is how my daemon.json looks like now:这就是我的 daemon.json 现在的样子:

{
    "runtimes": {
        "nvidia": {
            "path": "nvidia-container-runtime",
            "runtimeArgs": []
        }
    },
        "default-runtime": "nvidia" 
}

The important section is the default runtime, which was missing before.重要的部分是默认运行时,之前缺少它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM