Intel® Distribution of OpenVINO™ Toolkit
Community support and discussions about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all things computer vision-related on Intel® platforms.
5541 Discussions

How to make python script work when using openvino on arm64

lynn1050
Novice
1,596 Views
I wanted to use NCS2, and installed openvino on Nvida TX2, following this guide:
 
Installation was successful, but when I ran script ./setupvars.sh , I got this error:
 
[setupvars.sh] WARNING: Can not find OpenVINO Python binaries by path /home/dajian/Code/openvino/scripts/python
[setupvars.sh] WARNING: OpenVINO Python environment does not set properly
[setupvars.sh] OpenVINO environment initialized
 
In a result, the command below works well:
./bin/aarch64/Release/object_detection_sample_ssd -m face-detection-adas-0001.xml -d MYRIAD -i jialin.jpg
But  I didn't succeed in running my python script that used openvino api.  "No module named 'openvino' " occurred.
 
Any suggetion will be appreciated.

0 Kudos
1 Solution
Rizal_Intel
Moderator
1,544 Views

You can follow this building OpenVINO from source wiki guide.

Depending on your OS distribution, you may also need to compile Python from source.

 

Regards,

Rizal


View solution in original post

10 Replies
Rizal_Intel
Moderator
1,585 Views

Hi Lynn,


Are you able to get the benchmark app to run?

I do not think the instructions you followed build the python libraries.

You may need to build and use existing C++ examples or develop them.


Regards,

Rizal


lynn1050
Novice
1,580 Views

 Yes, I am able to get the benchmark app to run, because the excutable binary file benchmark was build from c++ code. I may build a c++ project to get my app.

But there is another problem. When I run benchmark app with option '-d CPU',  I got this error,

[ ERROR ] Device with "CPU" name is not registered in the InferenceEngine

It seems to support MYRIAD only. And I want to do th comparison among CPU, GPU, or MYRIAD.

Rizal_Intel
Moderator
1,570 Views

Hi Lynn,


The CPU and GPU plugin support Intel hardware only.

ARM based processor devices such as Jetson is not compatible for the CPU plugin.

The NVIDIA graphics card is also not compatible with OpenVINO and should be used with the CUDA interface instead.

The only compatible devices are MYRIAD devices such as the Neural Compute Stick 2 or Intel® Vision Accelerator.


You can refer to the list of supported devices for more information.


Regards,

Rizal


lynn1050
Novice
1,566 Views

Thank you for your information. It's very helpful.

Then I want to know how to build the python libraries so that I  can develop in python code and do some comparison. 

jonnymo
Novice
1,549 Views

I have the same question. I followed the instructions but there does not appear to be any python folder created.

Also, the SqueezeNetv1.1 example is not present.

 

How to fix?

Rizal_Intel
Moderator
1,545 Views

You can follow this building OpenVINO from source wiki guide.

Depending on your OS distribution, you may also need to compile Python from source.

 

Regards,

Rizal


View solution in original post

jonnymo
Novice
1,539 Views

Ah, yeah I had seen this previously and did try to specify the Python version but it was failing.  With the latest OpenVINO code downloaded, 2021.2, this seemed to work. I was able to run cmake and make without issue.

 

I added the following to the cmake options:

NOTE: Not specifying the Python version results in a Python2.7 build.

    -DENABLE_PYTHON=ON \
    -DPYTHON_EXECUTABLE=`which python3.8` \
    -DPYTHON_LIBRARY=/usr/lib/aarch64-linux-gnu/libpython3.8.so \
    -DPYTHON_INCLUDE_DIR=/usr/include/python3.8

 

This did require installing Cython before running cmake though.

sudo apt install python3-pip
pip3 install Cython

 

Thanks.

 

 

 

jonnymo
Novice
1,526 Views

From the following link, I was able to test that the OpenVINO Python libs were created and working as expected:

https://www.intel.com/content/www/us/en/support/articles/000057448/software/development-software.htm... 

odroid@odroid:~/develop/openvino2$ export PYTHONPATH=$PYTHONPATH:/home/odroid/develop/openvino2/openvino/bin/aarch64/Release/lib/python_api/python3.8/
odroid@odroid:~/develop/openvino2$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/odroid/develop/openvino2/openvino/bin/aarch64/Release/lib/
odroid@odroid:~/develop/openvino2$ python3.8
Python 3.8.5 (default, Jul 28 2020, 12:59:40)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from openvino.inference_engine import IENetwork, IECore
>>>

There was no error on the import, so it appears to be good.

 

The issue I found with the setupvars.sh script is that it is expecting the OpenVINO Python libs to be located under {INTEL_OPENVINO_DIR}/python and {INTEL_OPENVINO_DIR}/python/python$python_version}. 

However, with the source build as I did, the Python libs are not placed here, but rather in my case at:

 $INTEL_OPENVINO_DIR/bin/aarch64/Release/lib/python_api/python$python_version

Also, when the script is run from say the OpenVINO directory, it sets the BASE_DIR to the SCRIPT_DIR, and other paths, to the script root directory.  Printing these out from the script, you can see what they are set to:

source /home/odroid/develop/openvino/scripts/setupvars/setupvars.sh
SCRIPT_DIR=/home/odroid/develop/openvino/scripts/setupvars
BASE_DIR=/home/odroid/develop/openvino/scripts
INSTALLDIR=/home/odroid/develop/openvino/scripts

 

Even though the script fails, it still sets the PYTHONPATH, which is based on the INSTALLDIR which is what the INTEL_OPENVINO_DIR is set to:

~$ echo $PYTHONPATH
/home/odroid/develop/openvino/scripts/deployment_tools/model_optimizer

 

The model_optimizer folder does not exist, and the deployment_tools are located at the following with no model_optimizer folder:

$ find  /home/odroid/develop/openvino -name "deployment_tools"
/home/odroid/develop/openvino/build/ngraph/CMakeFiles/Export/deployment_tools

 

I ended up changing the setupvars.sh script a bit to accommodate the source build and now succeeds but still needs work.

I changed the beginning to:

     17 BASE_DIR="${PWD}"
     18 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" && pwd )" >/dev/null 2        >&1 && pwd )"
     19 #BASE_DIR="$( dirname "$SCRIPT_DIR" )"
     20
     21 INSTALLDIR="${BASE_DIR}"
     22
     23 echo "INSTALLDIR=${INSTALLDIR}"

 

and added an elif to accommodate the the actual path for the build:

    144     elif [[ -d $INTEL_OPENVINO_DIR/bin/aarch64/Release/lib/python_api/py        thon$python_version ]]; then
    145         echo "Python path found!"
    146         # add path to OpenCV API for Python 3.x
    147         #export PYTHONPATH="$INTEL_OPENVINO_DIR/python/python3:$PYTHONPA        TH"
    148         pydir=$INTEL_OPENVINO_DIR/bin/aarch64/Release/lib/python_api/pyt        hon$python_version
    149         if [[ -d $pydir ]]; then
    150             # add path to Inference Engine Python API
    151             export PYTHONPATH="${pydir}:${PYTHONPATH}"
    152         else
    153             echo "[setupvars.sh] WARNING: Can not find OpenVINO Python m        odule for python${python_version} by path ${pydir}"
    154             echo "[setupvars.sh] WARNING: OpenVINO Python environment do        es not set properly"
    155         fi
    156     else

 

 

The "-pyver" option can be used to set the Python version for the Python libs. In my case it was 3.8.

Thus running the script ends with:

$ source /home/odroid/develop/openvino2/openvino/scripts/setupvars/setupvars.sh -pyver 3.8
INSTALLDIR=/home/odroid/develop/openvino2/openvino
python_version = 3.8
Python path found!
[setupvars.sh] OpenVINO environment initialized

 

The PYTHONPATH is set as such:

$ echo $PYTHONPATH                    /home/odroid/develop/openvino2/openvino/bin/aarch64/Release/lib/python_api/python3.8:/home/odroid/develop/openvino2/openvino/deployment_tools/model_optimizer

 

The script needs more work, but it is close.

 

Cheers,

Jon

 

lynn1050
Novice
1,515 Views

 It works well. Thanks a lot!

Munesh_Intel
Moderator
1,503 Views

Hi Lynn,

This thread will no longer be monitored since this issue has been resolved. If you need any additional information from Intel, please submit a new question.


Regards,

Munesh


Reply