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

[Q&A] raspberry pi 4 + NCS2 ngraph module not found

semteuls
Beginner
2,530 Views

Hello.

I installed the following version on my raspberry pi.

l_openvino_toolkit_runtime_raspbian_p_2021.3.394.tgz

 

When I run the demo program using Python, I get an error.

pi@raspberrypi:~/sw/openvino/deployment_tools/inference_engine/samples/python/object_detection_sample_ssd $ python3 object_detection_sample_ssd.py
Traceback (most recent call last):
File "object_detection_sample_ssd.py", line 26, in <module>
import ngraph as ng
ModuleNotFoundError: No module named 'ngraph'

 

Python 3.7.3 (default, Jan 22 2021, 20:04:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'4.5.2-openvino'

 

 Do I have to install the ngraph module separately?

Even after installing the source, I keep getting a compilation error.

Is there a solution?

 

Thanks.

0 Kudos
1 Solution
Peh_Intel
Moderator
2,495 Views

Hi semteuls,


Thanks for reaching out to us.


For your information, nGraph module is not included in the OpenVINO™ Toolkit for Raspbian OS Package. You have to build Open Source OpenVINO™ Toolkit for Raspbian OS in order to import the nGraph module.


Please refer to the steps below for building Open Source OpenVINO™ Toolkit for Raspbian OS:

1.    Set up build environment and install build tools

sudo apt update && sudo apt upgrade -y

 

sudo apt install build-essential


2.      Install CMake from source

cd ~/

 

wget https://github.com/Kitware/CMake/releases/download/v3.14.4/cmake-3.14.4.tar.gz

 

tar xvzf cmake-3.14.4.tar.gz

 

cd ~/cmake-3.14.4

 

./bootstrap

 

make -j4 && sudo make install

 

3.      Install OpenCV from source

sudo apt install git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev python3-scipy libatlas-base-dev

 

cd ~/

 

git clone --depth 1 --branch 4.5.2 https://github.com/opencv/opencv.git

 

cd opencv && mkdir build && cd build

 

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..

 

make -j4 && sudo make install

 

4.      Download source code and install dependencies

cd ~/

 

git clone --depth 1 --branch 2021.3 https://github.com/openvinotoolkit/openvino.git

 

cd ~/openvino

 

git submodule update --init --recursive


sh ./install_build_dependencies.sh


cd ~/openvino/inference-engine/ie_bridges/python/

 

pip3 install -r requirements.txt

 

5. Start CMake build

export OpenCV_DIR=/usr/local/lib/cmake/opencv4

 

cd ~/openvino

 

mkdir build && cd build


cmake -DCMAKE_BUILD_TYPE=Release \

-DCMAKE_INSTALL_PREFIX=/home/pi/openvino_dist \

-DENABLE_MKL_DNN=OFF \

-DENABLE_CLDNN=OFF \

-DENABLE_GNA=OFF \

-DENABLE_SSE42=OFF \

-DTHREADING=SEQ \

-DENABLE_OPENCV=OFF \

-DNGRAPH_PYTHON_BUILD_ENABLE=ON \

-DNGRAPH_ONNX_IMPORT_ENABLE=ON \

-DENABLE_PYTHON=ON \

-DPYTHON_EXECUTABLE=$(which python3.7) \

-DPYTHON_LIBRARY=/usr/lib/arm-linux-gnueabihf/libpython3.7m.so \

-DPYTHON_INCLUDE_DIR=/usr/include/python3.7 \

-DCMAKE_CXX_FLAGS=-latomic ..

 

make -j4 && sudo make install


6.      Configure the Intel® Neural Compute Stick 2 Linux USB Driver

sudo usermod -a -G users "$(whoami)"

 

source /home/pi/openvino_dist/bin/setupvars.sh

 

sh /home/pi/openvino_dist/install_dependencies/install_NCS_udev_rules.sh

 

7.      Verify nGraph module binding to Python

source /home/pi/openvino_dist/bin/setupvars.sh


cd /home/pi/openvino_dist/deployment_tools/inference_engine/samples/python/object_detection_sample_ssd


python3 object_detection_sample_ssd.py -h



Regards,

Peh


View solution in original post

0 Kudos
6 Replies
Peh_Intel
Moderator
2,496 Views

Hi semteuls,


Thanks for reaching out to us.


For your information, nGraph module is not included in the OpenVINO™ Toolkit for Raspbian OS Package. You have to build Open Source OpenVINO™ Toolkit for Raspbian OS in order to import the nGraph module.


Please refer to the steps below for building Open Source OpenVINO™ Toolkit for Raspbian OS:

1.    Set up build environment and install build tools

sudo apt update && sudo apt upgrade -y

 

sudo apt install build-essential


2.      Install CMake from source

cd ~/

 

wget https://github.com/Kitware/CMake/releases/download/v3.14.4/cmake-3.14.4.tar.gz

 

tar xvzf cmake-3.14.4.tar.gz

 

cd ~/cmake-3.14.4

 

./bootstrap

 

make -j4 && sudo make install

 

3.      Install OpenCV from source

sudo apt install git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev python3-scipy libatlas-base-dev

 

cd ~/

 

git clone --depth 1 --branch 4.5.2 https://github.com/opencv/opencv.git

 

cd opencv && mkdir build && cd build

 

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..

 

make -j4 && sudo make install

 

4.      Download source code and install dependencies

cd ~/

 

git clone --depth 1 --branch 2021.3 https://github.com/openvinotoolkit/openvino.git

 

cd ~/openvino

 

git submodule update --init --recursive


sh ./install_build_dependencies.sh


cd ~/openvino/inference-engine/ie_bridges/python/

 

pip3 install -r requirements.txt

 

5. Start CMake build

export OpenCV_DIR=/usr/local/lib/cmake/opencv4

 

cd ~/openvino

 

mkdir build && cd build


cmake -DCMAKE_BUILD_TYPE=Release \

-DCMAKE_INSTALL_PREFIX=/home/pi/openvino_dist \

-DENABLE_MKL_DNN=OFF \

-DENABLE_CLDNN=OFF \

-DENABLE_GNA=OFF \

-DENABLE_SSE42=OFF \

-DTHREADING=SEQ \

-DENABLE_OPENCV=OFF \

-DNGRAPH_PYTHON_BUILD_ENABLE=ON \

-DNGRAPH_ONNX_IMPORT_ENABLE=ON \

-DENABLE_PYTHON=ON \

-DPYTHON_EXECUTABLE=$(which python3.7) \

-DPYTHON_LIBRARY=/usr/lib/arm-linux-gnueabihf/libpython3.7m.so \

-DPYTHON_INCLUDE_DIR=/usr/include/python3.7 \

-DCMAKE_CXX_FLAGS=-latomic ..

 

make -j4 && sudo make install


6.      Configure the Intel® Neural Compute Stick 2 Linux USB Driver

sudo usermod -a -G users "$(whoami)"

 

source /home/pi/openvino_dist/bin/setupvars.sh

 

sh /home/pi/openvino_dist/install_dependencies/install_NCS_udev_rules.sh

 

7.      Verify nGraph module binding to Python

source /home/pi/openvino_dist/bin/setupvars.sh


cd /home/pi/openvino_dist/deployment_tools/inference_engine/samples/python/object_detection_sample_ssd


python3 object_detection_sample_ssd.py -h



Regards,

Peh


0 Kudos
dengyu
Novice
2,413 Views
0 Kudos
JimmyMiller
Beginner
1,371 Views

Thank you Peh, this script does correctly install openVino with ngraph.

For my Rasbian Buster(32 bit) kernel 5.10.103-v7l+ I had to install Cython first, and add its location to $PATH.

Also the line

git submodule update --init --recursive

will throw an error if you haven't entered an email or name into git config.

Otherwise, it worked so thanks! I can now use ngraph for my inferencing!

JimmyMiller_0-1652633583468.png

 

0 Kudos
Peh_Intel
Moderator
2,359 Views

Hi dengyu,


Please open a new thread with the elaboration of your issue encountered for us to better assist you.



Regards,

Peh


0 Kudos
Peh_Intel
Moderator
2,359 Views

Hi semteuls,


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.



Regards,

Peh


0 Kudos
semteuls
Beginner
2,335 Views

Thanks.

However, it has not been practiced yet.
Let's install it from source.

0 Kudos
Reply