Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenVINO No module named 'cv2' #25

Closed
byarbrough opened this issue Oct 28, 2019 · 1 comment
Closed

OpenVINO No module named 'cv2' #25

byarbrough opened this issue Oct 28, 2019 · 1 comment
Labels

Comments

@byarbrough
Copy link
Owner

byarbrough commented Oct 28, 2019

This is the dreaded import cv2 error.

$make infer
sudo docker exec movrasten_app python infer/classification_sample.py -m /app/models/openvino/model.xml -nt 5 -i /app/data/infer/ -d CPU
Traceback (most recent call last):
  File "infer/classification_sample.py", line 23, in <module>
    import cv2
ModuleNotFoundError: No module named 'cv2'
Makefile:66: recipe for target 'infer' failed
make: *** [infer] Error 1

I've seen it before, as have many others, but going to try and fix it permanently this time.
ab92f8d

@byarbrough
Copy link
Owner Author

Multiple other issues address the same thing.
experiencor/keras-yolo2#230
opencv/opencv#7045
jazzsaxmafia/video_to_sequence#3 (comment)

After running pip install opencv-python as suggested, I was presented with a new error:

$make infer
sudo docker exec movrasten_app python infer/classification_sample.py -m /app/models/openvino/model.xml -nt 5 -i /app/data/infer/ -d CPU
Traceback (most recent call last):
  File "infer/classification_sample.py", line 23, in <module>
    import cv2
  File "/usr/local/lib/python3.6/dist-packages/cv2/__init__.py", line 3, in <module>
    from .cv2 import *
ImportError: libSM.so.6: cannot open shared object file: No such file or directory
Makefile:66: recipe for target 'infer' failed
make: *** [infer] Error 1

This led me to find more related issues:
ray-project/ray#923
NVIDIA/nvidia-docker#864 (comment)

I added apt-get install -y libsm6 libxext6 libxrender-dev to Dockerfile, now the error is:

$ make infer
sudo docker exec movrasten_app python infer/classification_sample.py -m /app/models/openvino/model.xml -nt 5 -i /app/data/infer/ -d CPU
Traceback (most recent call last):
  File "infer/classification_sample.py", line 27, in <module>
    from openvino.inference_engine import IENetwork, IEPlugin
ModuleNotFoundError: No module named 'openvino'
Makefile:67: recipe for target 'infer' failed
make: *** [infer] Error 1

byarbrough referenced this issue Oct 29, 2019
I am getting the common module not found error on import cv2
when trying to run an inference with classification_sample.py
Already tried moving up to latest openvino install, although I
am using the apt-get method instead of the option from Intel on
http://registrationcenter-download.intel.com/akdlm/irc_nas/16057/l_openvino_toolkit_p_2019.3.376.tgz
I might try that next, but need to go pull out my hair first.
byarbrough referenced this issue Nov 11, 2019
Close #15
Began with dreaded cv2 not found. Having earned agony earlier in this project,
I knew that the problem was most likely with running setupvars and init OpenVINO env.

Log in with a shell (as root, which prompted the run_root addition) and running
'source /opt/intel/openvino/bin/setupvars.sh' allowed me to then
run the classification sample. Actually, I had to unearth some dependencies first,
such as libsm6, libgtk... all the ones now included in the first RUN in Dockerfile.

The 'source' command in bash essentially makes variables and things set when the script
is executed available to later processes. Simply calling setupvars.sh didn't solve the
problem because then nothing was changed when I ran inference. However, source is not
included in sh, which is Docker default. Fortunately, '.' served enough of the same
purpose.

I opted to switch to . instead of using SHELL in the Dockerfile to switch the default.

I also added a '-l' to the CMD. This is to make sure that .bashrc gets sourced when
going into an interactive shell.
fatal: Invalid path '/opt/intel/openvino_2019.2.242/bin/setupvars.sh allowed me to then
run the classification sample. Actually, I had to unearth some dependencies first,
such as libsm6, libgtk... all the ones now included in the first RUN in Dockerfile.

The source command in bash essentially makes variables and things set when the script
is executed available to later processes. Simply calling setupvars.sh didn't solve the
problem because then nothing was changed when I ran inference. However, source is not
included in sh, which is Docker default. Fortunately, . served enough of the same
purpose.

I opted to switch to . instead of using SHELL in the Dockerfile to switch the default.

I also added a -l to the CMD. This is to make sure that .bashrc gets sourced when
going into an interactive shell.
@byarbrough byarbrough mentioned this issue Nov 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant