Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.
6392 Discussions

No ngraph bindings for python in raspbian distribution?

Hawkes__Rycharde
New Contributor I
3,160 Views

Unlike the downloads for Linux and Windows, the download for Raspbian, (e.g. https://storage.openvinotoolkit.org/repositories/openvino/packages/2021.1/l_openvino_toolkit_runtime_raspbian_p_2021.1.110.tgz) does not contain any python bindings for ngraph which are normally  in <install_dir>/python/python3.7/ngraph. 

Do you know why? Do I have to build from source to get it?

Thanks.

14 Replies
SebastianE_N_Intel
3,129 Views

Hi,
I'm having the same problem too. Have you found a solution?
Could you also please offer me a link from where you learned how to build and run the python demos? I've tried this: https://www.intel.com/content/www/us/en/support/articles/000055510/boards-and-kits/neural-compute-sticks.html
but it does not work.

Any help would be gladly accepted.
Thank you

0 Kudos
Hawkes__Rycharde
New Contributor I
3,122 Views

I haven't found a solution yet.  It seems pywheels used to be built for ngraph before it was merged into OpenVINO - if they were built now as part of the process for making a new distribution that would solve the problem.

I haven't tried building the demos using the latest distribution - I'm just working with my own applications.  Probably a good idea to post a new question with the details of your problems to resolve those.

 

0 Kudos
Peh_Intel
Moderator
3,112 Views

Hi Rycharde,


Greetings to you. You’re right. There is no ngraph folder under this directory, <install_dir>/python/python3.7.


The ngraph folder architecture of OpenVINO™ toolkit for Raspbian OS is slightly different with Windows & Linux. For your information, it is located at this directory: <install_dir>/deployment_tools/ngraph



Regards,

Peh


0 Kudos
Hawkes__Rycharde
New Contributor I
3,103 Views

Yes, I noticed that folder but it is also present in the Linux and Windows distributions because it contains the CPP libraries.  It does not contain the python bindings to those libraries which should be in python3.7/ngraph.

That folder contains (amongst other things) a .pyd file, e.g. _pyngraph.cp37-win_amd64.pyd, and without the equivalent one for arm it is not possible to use the ngraph API from python.  It's a major piece of functionality missing from the Raspbian distro.

 

0 Kudos
SebastianE_N_Intel
3,087 Views

Hey,

I was able to solve my problem and hopefully it will yours, too.
My problem was that ngraph was there (in <install_dir>/openvino/build/ngraph) but was not added to the PYTHONPATH. So, "export PYTHONPATH="${PYTHONPATH}:<install_dir>/openvino/build" solved it for me. However you have to run this every time you open a new console, or make a script and add it to .basrch like this: "echo "source <my_script>.sh" >> ~/.bashrc

Hope you'll be able to solve it.

0 Kudos
Hawkes__Rycharde
New Contributor I
3,079 Views

Thanks for the suggestion.  If you have a build folder then I presume you built from source.  I have been using the downloadable distributions which don't have build folders.  I can see a few PRs in the openvino github related to python bindings but I don't think they will materialise until 2021.3 and I need to use 2021.1 in any case.

I've started trying to build from source but so far have not been able to work out how to produce the ngraph python bindings.

0 Kudos
Peh_Intel
Moderator
3,050 Views

Hi Rycharde,


Greetings to you.


I’ve verified on my side and I can confirm to you that the ngraph folder is available through Open Source OpenVINO™ Toolkit.


The ngraph folder is located under this directory:

/home/pi/openvino/ngraph/python/src/ngraph


You may refer to this article on how to build Open Source OpenVINO™ Toolkit for Raspbian OS:

https://www.intel.com/content/www/us/en/support/articles/000057005/boards-and-kits.html



Regards,

Peh


0 Kudos
Hawkes__Rycharde
New Contributor I
2,978 Views

Those instructions for building for Raspbian may have been complete at one point but they are no longer complete in that the build process does not build the new ngraph python bindings by default, i.e. cmake followed by make & make install.

I spent many hours trying many different cmake options, etc., to build something that represents the downloadable pre-built distributions.  There is a different make target (python_wheel) that builds out the ngraph python bindings.  Then there is a lot of work to move all the built artifacts into a structure that mirrors the distributions.  Perhaps there is a build target to automate that but I couldn't find one.

This was not helped by the fact that cross compilation in docker fails when trying to build the python 3.7 bindings of ngraph so I had to build on my RPI4. I now have something that works but the distributions produced for Raspbian for 2021.1 (and maybe earlier) do not have the ngraph bindings.  Does Intel produce the distributions?  Should I just post an issue on the openvinotoolkit github?

Azizul_Intel
Moderator
2,911 Views

Hi Rycharde,

Apologize for the late reply as we were trying to replicate the Raspian OS build from source with ngraph python binding to provide better and workable solution for you. We shall get back to you once successfully replication from our end.

You can test to add these commands during cmake build as shared in Intel® Neural Compute Stick 2 and Open Source OpenVINO™ Toolkit for...

-DNGRAPH_PYTHON_BUILD_ENABLE=ON

-DNGRAPH_ONNX_IMPORT_ENABLE=ON

You may refer at this GitHub article: Align builds locations for ngraph and ie python bindings by slyubimt · Pull Request #4095 · openvinotoolkit/openvino (github.com)

Regards,

Azizul

0 Kudos
Hawkes__Rycharde
New Contributor I
2,905 Views

moBuilding the distribution does seem to be in a state of flux with locations and script names changing between recent releases.  I've included below the the relevant section of my dockerfile for building OpenVINO (which builds on an existing build of the correct version of OpenCV) and creating a distribution structure that resembles those that were downloadable for previous versions.  It worked on 2021.1 and then I had to tweak it again because things had changed again for 2021.2.  In order to build the python bindings for ngraph you have to explicitly call "make python_wheel" since they are not built with the usual make step even when using the cmake options you suggested.  Just to complicate matters, you have to do that after "make install" as of 2021.2  You may find it helpful.

 

# Install OpenVINO from source.  Name of build dependencies script changes between 2021.1 and 2021.2
RUN cd / && \
  git clone https://github.com/openvinotoolkit/openvino/ --depth 1 --recursive --branch $OPENVINO_VERSION && \
  cd openvino && \
  git submodule update --init --recursive && \
  if [[ -f "install_build_dependencies.sh"  ]] ; then \
  sh ./install_build_dependencies.sh \
  else \
  sh ./install_dependencies.sh  ; \
  fi

RUN rm /usr/bin/python && \
  ln -s /usr/bin/python3 /usr/bin/python

RUN cd /openvino/inference-engine/ie_bridges/python/ && \
  pip3 install -r requirements.txt && \
  cd /openvino && \
  mkdir build && \
  cd build && \
  cmake \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_INSTALL_PREFIX=$OPENVINO_INSTALL_DIR \
  -DENABLE_SSE42=OFF \
  -DTHREADING=SEQ \
  -DENABLE_OPENCV=OFF \
  -DENABLE_PYTHON=ON \
  -DNGRAPH_PYTHON_BUILD_ENABLE=ON \
  -DNGRAPH_ONNX_IMPORT_ENABLE=ON \
  -DPYTHON_EXECUTABLE=$(which python3.7) \
  -DPYTHON_LIBRARY=/usr/lib/arm-linux-gnueabihf/libpython3.7m.so \
  -DPYTHON_INCLUDE_DIR=/usr/include/python3.7 \
  -DENABLE_GNA=OFF \
  -DCMAKE_CXX_FLAGS=-latomic \
  .. && \
  make --jobs=$(nproc --all)

RUN cd /openvino/build && \
  make install && \
  make python_wheel

# Copy and adjust file locations to match distribution layout
RUN cd $OPENVINO_INSTALL_DIR && \
  ln -s deployment_tools/inference_engine inference_engine && \
  cp -r $OPENCV_INSTALL_DIR opencv && \
  chmod +x install_dependencies/*.sh && \
  cp -r $OPENCV_INSTALL_DIR/lib/python3.7/dist-packages python/python3 && \
  cp -r /openvino/bin/armv7l/Release/lib/*.so deployment_tools/inference_engine/lib/armv7l && \
  mkdir deployment_tools/ngraph && \
  if [[ $OPENVINO_VERSION = "2021.1" ]] ; then \
  cp -r /openvino/build/ngraph/python/_install/opt/intel/openvino/* deployment_tools/ngraph ; \
  fi && \
  rm deployment_tools/inference_engine/lib/armv7l/libinterpreter_backend.so && \
  cp -r /openvino/ngraph/python/build/lib.linux-armv7l-3.7/* python/python3.7/

 

 

0 Kudos
Azizul_Intel
Moderator
2,890 Views

Hi Rycharde,

Thanks for the helpful solution. I shall try to use them in building the python binding for ngraph from my end and will share my output later.

Meanwhile, could you confirm that your provided scripts has resolved your ngraph python binding issue? Thanks ~


Regards,

Azizul


0 Kudos
Hawkes__Rycharde
New Contributor I
2,885 Views

Hi Azizul,

I can get the bindings by laboriously building from source but personally I would only consider the issue closed when the ngraph bindings are in the distributions produced for Raspbian, which they are not.

Rych

Azizul_Intel
Moderator
2,875 Views

Hi Rych,

Understood on the considerable time and effort from your end in getting the bindings to be available from the source and we do appreciate your scripts as part of the contribution to our OpenVINO community.

 

I did tried to replicate to build Open Source OpenVINO™ Toolkit for Raspbian OS using this article (Intel® Neural Compute Stick 2 and Open Source OpenVINO™ Toolkit for...) and successfully created the ngraph folder as attached.

Our investigation found that below commands carry significant part in ensuring the submodule folders are created.

cd ~/openvino

git submodule update --init --recursive

We are acknowledged that your solution does provide an alternative for us to make this work. Nevertheless, feel free to explore this again as we already released OpenVINO 2021.3 this week.

Regards,

Azizul

 

0 Kudos
Azizul_Intel
Moderator
2,823 Views

This thread will no longer be monitored since we have provided a solution. If you need any additional information from Intel, please submit a new question. 


0 Kudos
Reply