0

There is a project already works separately machines. Now I try to build Dockerfile to automize installation.

The project use openvino and opencv. Opencv is not from openvino. I use opencv from source 4.3.0.

Firstly, I run Dockerfile completely. When I run my python project, I got the error:

 layerOutputs = self.net.forward(self.ln) cv2.error: OpenCV(4.3.0-openvino) /opt/intel/openvino_2020.3.194/opencv/modules/dnn/src/dnn.cpp:1138: error: (-213:The function/feature is not implemented) Unknown backend identifier in function 'wrapMat'

I note the error. It says there is no backend identifier.

I decide make installation steps manually by comment the opencv, openvino installation lines in Dockerfile. I connect the docker container interactively. I run installation commands by hand. And my project is working.

After that, I just comment opencv installation lines. Just install openvino, and by hand I install opencv. And it again works. So I decide search opencv build files.

Now let's think two containers. First container is build completely by Dockerfile. It has a error. Second container is build by Dockerfile until opencv installation. Opencv installation was made by hand.

I check /home/foo/opencv/build folder size in each them.

In first container, the size of folder is 535652. In second container, the size of folder is 542172.

I see the difference. And I search deeply.

In each container, I list all subdirectories of build folder with sizes. After that I copy them separate txt files, and I run diff commands for them. I see the folder are different:

diff first-container.txt second-container.txt
1007c1007
< 92956   opencv/build/lib
---
> 94008   opencv/build/lib
1129c1129
< 28660   opencv/build/bin
---
> 28676   opencv/build/bin
1151c1151
< 960     opencv/build/CMakeFiles
---
> 968     opencv/build/CMakeFiles
1184c1184
< 8       opencv/build/modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/ie
---
> 528     opencv/build/modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/ie
1189c1189
< 3964    opencv/build/modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends
---
> 4484    opencv/build/modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends
1193c1193
< 8508    opencv/build/modules/gapi/CMakeFiles/opencv_gapi.dir/src
---
> 9028    opencv/build/modules/gapi/CMakeFiles/opencv_gapi.dir/src
1196,1198c1196,1198
< 10188   opencv/build/modules/gapi/CMakeFiles/opencv_gapi.dir
< 20828   opencv/build/modules/gapi/CMakeFiles
< 20972   opencv/build/modules/gapi
---
> 10740   opencv/build/modules/gapi/CMakeFiles/opencv_gapi.dir
> 21380   opencv/build/modules/gapi/CMakeFiles
> 21524   opencv/build/modules/gapi
1282c1282
< 12868   opencv/build/modules/python3
---
> 12872   opencv/build/modules/python3
1362c1362
< 152     opencv/build/modules/dnn_objdetect
---
> 156     opencv/build/modules/dnn_objdetect
1368c1368
< 540     opencv/build/modules/dnn_superres
---
> 544     opencv/build/modules/dnn_superres
1405c1405
< 3228    opencv/build/modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers
---
> 5520    opencv/build/modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers
1418c1418
< 6956    opencv/build/modules/dnn/CMakeFiles/opencv_dnn.dir/src
---
> 10704   opencv/build/modules/dnn/CMakeFiles/opencv_dnn.dir/src
1424,1428c1424,1428
< 12784   opencv/build/modules/dnn/CMakeFiles/opencv_dnn.dir
< 1112    opencv/build/modules/dnn/CMakeFiles/opencv_perf_dnn.dir/perf
< 1240    opencv/build/modules/dnn/CMakeFiles/opencv_perf_dnn.dir
< 14036   opencv/build/modules/dnn/CMakeFiles
< 14428   opencv/build/modules/dnn
---
> 19096   opencv/build/modules/dnn/CMakeFiles/opencv_dnn.dir
> 1132    opencv/build/modules/dnn/CMakeFiles/opencv_perf_dnn.dir/perf
> 1260    opencv/build/modules/dnn/CMakeFiles/opencv_perf_dnn.dir
> 20368   opencv/build/modules/dnn/CMakeFiles
> 20760   opencv/build/modules/dnn
1670,1671c1670,1671
< 204432  opencv/build/modules
< 534344  opencv/build
---
> 211328  opencv/build/modules
> 542320  opencv/build
2074,2076c2074,2076

I notice that backends/ie folder are different. The error that when I run the python project is related.

I don't wait it from docker. What is the difference by manually or Dockerfile?

my dockerfile:

FROM ubuntu:18.04

ARG DOWNLOAD_LINK=http://registrationcenter-download.intel.com/akdlm/irc_nas/16612/l_openvino_toolkit_p_2020.2.120.tgz

ENV INSTALLDIR /opt/intel/openvino

# openvino download
RUN curl -LOJ "${DOWNLOAD_LINK}"

# opencv download
RUN wget -O opencv.zip https://github.com/opencv/opencv/archive/4.3.0.zip && \
    wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/4.3.0.zip

RUN apt-get -y install sudo

# openvino installation
RUN tar -xvzf ./*.tgz && \
    cd l_openvino_toolkit_p_2020.2.120 && \
    sed -i 's/decline/accept/g' silent.cfg && \
    ./install.sh -s silent.cfg && \
    # rm -rf /tmp/* && \
    sudo -E $INSTALLDIR/install_dependencies/install_openvino_dependencies.sh

WORKDIR /home/sa

RUN /bin/bash -c "source /opt/intel/openvino/bin/setupvars.sh" && \
    echo "source /opt/intel/openvino/bin/setupvars.sh" >> /home/sa/.bashrc && \
    echo "source /opt/intel/openvino/bin/setupvars.sh" >> ~/.bashrc && \
    $INSTALLDIR/deployment_tools/model_optimizer/install_prerequisites/install_prerequisites.sh && \
    $INSTALLDIR/deployment_tools/demo/demo_squeezenet_download_convert_run.sh

RUN bash

# opencv installation

RUN unzip opencv.zip && \
    unzip opencv_contrib.zip && \
    # rm opencv.zip opencv_contrib.zip && \
    mv opencv-4.3.0 opencv && \
    mv opencv_contrib-4.3.0 opencv_contrib && \
    cd ./opencv && \
    mkdir build && \
    cd build && \
    cmake -D CMAKE_BUILD_TYPE=RELEASE -D WITH_INF_ENGINE=ON -D ENABLE_CXX11=ON -D CMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_PYTHON_EXAMPLES=OFF -D INSTALL_C_EXAMPLES=OFF -D ENABLE_PRECOMPILED_HEADERS=OFF -D OPENCV_ENABLE_NONFREE=ON -D OPENCV_EXTRA_MODULES_PATH=/home/sa/opencv_contrib/modules -D PYTHON_EXECUTABLE=/usr/bin/python3 -D WIDTH_GTK=ON -D BUILD_TESTS=OFF -D BUILD_DOCS=OFF -D WITH_GSTREAMER=OFF -D WITH_FFMPEG=ON -D BUILD_EXAMPLES=OFF .. && \
    make && \
    make install && \
    ldconfig
yellowpisagor
  • 146
  • 3
  • 13
  • Why do you use `RUN bash` it doesn't do you any good – Alejandro Galera Aug 19 '20 at 08:40
  • Furthermore, can you put first Dockerfile line? `FROM ...` – Alejandro Galera Aug 19 '20 at 08:40
  • I add it sorry. I run ```RUN BASH``` because I add somethingsto ~/.bashrc file by openvino installation. I think that when I connect interactively container, it is starting with bash command. It could be unnecessary. – yellowpisagor Aug 19 '20 at 08:43
  • What you add in your `.bashrc` you should add it to Dockerfile as ENV, for example, if they are environment variables. Can you post your `.bashrc` file? – Alejandro Galera Aug 19 '20 at 09:03
  • @mulg0r you can see in Dockerfile what I add – yellowpisagor Aug 19 '20 at 09:05
  • I say `.bashrc` content: `/opt/intel/openvino/bin/setupvars.sh` content. If it only contains environment variables, they should be added as `ENV` in dockerfile – Alejandro Galera Aug 19 '20 at 09:09
  • @mulg0r additionaly, I add ```source /opt/intel/openvino/bin/setupvars.sh``` – yellowpisagor Aug 19 '20 at 09:10
  • Yes, but setupvars.sh content is just in the image, not in docker container. If you want to have it doing `docker run` (in container) you have to define them as ENV in Dockerfile or docker-compose.yml. Please, post some of your setupvars.sh content and I'll put a Dockerfile example – Alejandro Galera Aug 19 '20 at 09:15
  • @mulg0r sir https://gist.github.com/ahmetanbar/10257fd888323bf3bd3e4c6e99fcec37 – yellowpisagor Aug 19 '20 at 09:45
  • @mulg0r sir is there any keywords to search this issue? – yellowpisagor Aug 19 '20 at 11:13
  • @mulg0r thank you sir i notice the mistake. thank you very much. it is almost related that: https://stackoverflow.com/questions/47211850/docker-run-script-which-exports-env-variables – yellowpisagor Aug 19 '20 at 13:49
  • 1
    Great! It's always nice to know something is solved – Alejandro Galera Aug 19 '20 at 14:03
  • 1
    Lastly, what I think. I will have 2 stages. First stage, I install openvino. There occurs a image. After that, interactively by connect the container by the ./bashrc the enviroment variables will initiliaze. I convert the present container to a new image. By the last image, I install opencv on it. That' right? I think that I can't set all envs of openvino manually. – yellowpisagor Aug 19 '20 at 14:14
  • Yes, you can can set all env in a file, and pass it doing `docker run --env-file=foo ...` – Alejandro Galera Aug 19 '20 at 14:18

0 Answers0