Hi I am trying to inference inside openvino with Intel python distribution using the following Command, but it throws an cv2 error:
Openvino Version: 2021.1
Intel Python Distribution: Python 3.7.7 :: Intel Corporation
Error:
/opt/intel/openvino_2021/deployment_tools/inference_engine/samples/python/object_detection_sample_ssd$ python object_detection_sample_ssd.py -m /home/ubuntu/Documents/Simran/frozen_inference_graph.xml -i /home/ubuntu/Documents/Simran/images/images_2_134.jpg
Traceback (most recent call last):
File "object_detection_sample_ssd.py", line 21, in <module>
import cv2
ImportError: /opt/intel/openvino_2021/deployment_tools/inference_engine/lib/intel64/libinference_engine_transformations.so: undefined symbol: _ZNK6ngraph4Node9get_autobEv
I have tried the following links to resolve it but the issue still exists:
- https://community.intel.com/t5/Intel-Distribution-of-OpenVINO/Not-able-to-import-cv2/td-p/1176873
- https://community.intel.com/t5/Intel-Distribution-of-OpenVINO/ImportError-undefined-symbol-ZN3tbb8internal13numa/td-p/1169149
Kindly provide assistance.
链接已复制
I have switched now to openvino version 2019R3 and the error now is :
Traceback (most recent call last):
File "object_detection_sample_ssd.py", line 21, in <module>
import cv2
ImportError: No module named cv2
My OpenCV version is 3.4.2
What should be the correct PYTHONPATH and LD_LIBRARY PATH? The output of the existing paths are shown below:
echo $PYTHONPATH
/opt/intel/openvino_2019.3.376/python/python3.6:/opt/intel/openvino_2019.3.376/python/python3:/opt/intel/openvino_2019.3.376/deployment_tools/open_model_zoo/tools/accuracy_checker:/opt/intel/openvino_2019.3.376/deployment_tools/model_optimizer:
echo $LD_LIBRARY_PATH
/home/ubuntu/Downloads/intelpython3/lib/libfabric:/opt/intel/openvino_2019.3.376/opencv/lib:/opt/intel/opencl:/opt/intel/openvino_2019.3.376/deployment_tools/inference_engine/external/hddl/lib:/opt/intel/openvino_2019.3.376/deployment_tools/inference_engine/external/gna/lib:/opt/intel/openvino_2019.3.376/deployment_tools/inference_engine/external/mkltiny_lnx/lib:/opt/intel/openvino_2019.3.376/deployment_tools/inference_engine/external/tbb/lib:/opt/intel/openvino_2019.3.376/deployment_tools/inference_engine/lib/intel64:/opt/intel/openvino_2019.3.376/openvx/lib:
Since you are using OpenVINO 2021 your PYTHONPATH should contain "/opt/intel/openvino_2021/python/python3" and LD_LIBRARY_PATH should contain "/opt/intel/openvino_2021/opencv/lib". These variables are set by the "/opt/intel/openvino_2021/bin/setupvars.sh" script. See https://docs.openvinotoolkit.org/latest/openvino_docs_install_guides_installing_openvino_linux.html#set-the-environment-variables for details.
Hi SimranS,
It might cause by the OpenVINO environment is set with the correct version. Since you have other versions of OpenVINO installed on your machine, please make sure you are setting the OpenVINO environment according to the version carefully. It is important to set the correct environment variables exactly for the 2021.1 builds.
Also, please ensure you carefully followed all the additional installation steps from the OpenVINO website.
Regards,
Aznie
Hi,
I have checked the PYTHONPATH and LD_LIBRARY_PATH, seem correct.
(base) ubuntu@ubuntu:~/Downloads/intelpython3$ echo $PYTHONPATH
/opt/intel/openvino_2019.3.376/python/python3.6:/opt/intel/openvino_2019.3.376/python/python3:/opt/intel/openvino_2019.3.376/deployment_tools/open_model_zoo/tools/accuracy_checker:/opt/intel/openvino_2019.3.376/deployment_tools/model_optimizer:
(base) ubuntu@ubuntu:~/Downloads/intelpython3$ echo $LD_LIBRARY_PATH
/home/ubuntu/Downloads/intelpython3/lib/libfabric:/opt/intel/openvino_2019.3.376/opencv/lib:/opt/intel/opencl:/opt/intel/openvino_2019.3.376/deployment_tools/inference_engine/external/hddl/lib:/opt/intel/openvino_2019.3.376/deployment_tools/inference_engine/external/gna/lib:/opt/intel/openvino_2019.3.376/deployment_tools/inference_engine/external/mkltiny_lnx/lib:/opt/intel/openvino_2019.3.376/deployment_tools/inference_engine/external/tbb/lib:/opt/intel/openvino_2019.3.376/deployment_tools/inference_engine/lib/intel64:/opt/intel/openvino_2019.3.376/openvx/lib:
This cv import error only arises inside Intel python distribution environment when I try to run inference engine.
(base) ubuntu@ubuntu:/opt/intel/openvino_2019.3.376/deployment_tools/inference_engine/samples/python_samples/object_detection_sample_ssd$ sudo python object_detection_sample_ssd.py -m /home/ubuntu/Downloads/frozen_inference_graph.xml -i /home/ubuntu/Downloads/images/pics_1_124.jpg
Traceback (most recent call last):
File "object_detection_sample_ssd.py", line 21, in <module>
import cv2
ImportError: No module named cv2
Where as importing cv2 inside python shell doesnot give any error:
(base) ubuntu@ubuntu:~/Downloads/intelpython3$ python
Python 3.7.7 (default, Sep 11 2020, 20:43:12)
[GCC 7.3.0] :: Intel Corporation on linux
Type "help", "copyright", "credits" or "license" for more information.
Intel(R) Distribution for Python is brought to you by Intel Corporation.
Please check out: https://software.intel.com/en-us/python-distribution
>>> import cv2
>>>
Also attached screenshots for the same.
Running python with sudo does not preserve environment, try "sudo -E" (see https://linux.die.net/man/8/sudo). On some platforms "sudo" can drop LD_LIBRARY_PATH even with "-E" option for security reasons (see https://superuser.com/questions/544518/sudo-e-not-passing-all-variables).
Are you sure you need "sudo"? All samples should be able to run with regular user privilege level.
Hi,
I noticed from your $PYTHONPATH, it shows that you have the Python 3.6 version. If you are running the OpenVINO inference engine using Python 3.6, please make sure you have installed the OpenCV for Python 3.6 in the OpenVINO environment.
Refer to this OpenVINO installation steps carefully from the following link. https://docs.openvinotoolkit.org/latest/openvino_docs_install_guides_installing_openvino_linux.html
Regards,
Aznie
