google-ai-edge / mediapipe

Cross-platform, customizable ML solutions for live and streaming media.
https://ai.google.dev/edge/mediapipe
Apache License 2.0
27.45k stars 5.15k forks source link

undefined symbol: _ZN12carotene_o4t during import mediapipe in raspberry pi 3 #2056

Closed superuser789 closed 3 years ago

superuser789 commented 3 years ago

I am trying to build mediapipe for Raspberry Pi 3 on RPi3 itself. I built the latest opencv release 4.5.2 by following these guide

and successfully built opencv with these flags cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr \ -D OPENCV_EXTRA_MODULES_PATH=/home/pi/opencv/opencv_contrib-4.5.2/modules \ -D ENABLE_NEON=ON \ -D ENABLE_VFPV3=ON \ -D BUILD_TESTS=OFF \ -D INSTALL_PYTHON_EXAMPLES=OFF \ -D OPENCV_ENABLE_NONFREE=ON \ -D CMAKE_SHARED_LINKER_FLAGS=-latomic \ -D BUILD_EXAMPLES=OFF ..

To build mediapipe, I used bazel binary and prebuilt opencv 4.5.2. Followed official guide, made the changes in opencv_linux.BUILD & ffmpeg_linux.BUILD using

sed -i "s/x86_64-linux-gnu/arm-linux-gnueabihf/g" third_party/opencv_linux.BUILD
sed -i "s/x86_64-linux-gnu/arm-linux-gnueabihf/g" third_party/ffmpeg_linux.BUILD

and also commented "include/opencv2/**/*.h*", & uncommented "include/opencv4/opencv2/**/*.h*", under hdrs and commented "include/", & uncommented "include/opencv4/", under includes in opencv_linux.BUILD.

To resolve _ZN3ruy14Kernel8bitNeon issue. I added :

        '--copt=-march=armv7-a',
        '--copt=-mfpu=neon-vfpv3',

as told by arron2003 here.

Built the package : python3 setup.py gen_protos && python3 setup.py bdist_wheel & Installed using : sudo python3 -m pip install mediapipe-0.8-cp37-cp37m-linux_aarch64.whl --no-deps

But during import mediapipe I get this error :

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/dist-packages/mediapipe/__init__.py", line 16, in <module>
    from mediapipe.python import *
  File "/usr/local/lib/python3.7/dist-packages/mediapipe/python/__init__.py", line 17, in <module>
    from mediapipe.python._framework_bindings import resource_util
ImportError: /usr/local/lib/python3.7/dist-packages/mediapipe/python/_framework_bindings.cpython-37m-arm-linux-gnueabihf.so: undefined symbol: _ZN12carotene_o4t7rgb2hsvERKNS_6Size2DEPKhiPhii

Checking with nm -gCD /usr/local/lib/python3.7/dist-packages/mediapipe/python/_framework_bindings.cpython-37m-arm-linux-gnueabihf.so | grep -n rgb2hsv gives :

2047:         U carotene_o4t::rgb2hsv(carotene_o4t::Size2D const&, unsigned char const*, int, unsigned char*, int, int)
2176:007b0424 W TegraCvtColor_rgb2hsv_Invoker::~TegraCvtColor_rgb2hsv_Invoker()
2177:007b03f0 W TegraCvtColor_rgb2hsv_Invoker::~TegraCvtColor_rgb2hsv_Invoker()
2178:007b03f0 W TegraCvtColor_rgb2hsv_Invoker::~TegraCvtColor_rgb2hsv_Invoker()
4653:007b03b0 W TegraCvtColor_rgb2hsvf_Invoker::~TegraCvtColor_rgb2hsvf_Invoker()
4654:007b037c W TegraCvtColor_rgb2hsvf_Invoker::~TegraCvtColor_rgb2hsvf_Invoker()
4655:007b037c W TegraCvtColor_rgb2hsvf_Invoker::~TegraCvtColor_rgb2hsvf_Invoker()
17943:007b10d0 W TegraCvtColor_rgb2hsv_Invoker::operator()(cv::Range const&) const
18400:007b107c W TegraCvtColor_rgb2hsvf_Invoker::operator()(cv::Range const&) const
24049:00f85818 V typeinfo for TegraCvtColor_rgb2hsv_Invoker
24056:00f85848 V typeinfo for TegraCvtColor_rgb2hsvf_Invoker
25727:00f306cc V typeinfo name for TegraCvtColor_rgb2hsv_Invoker
25734:00f30754 V typeinfo name for TegraCvtColor_rgb2hsvf_Invoker
27388:00f85878 V vtable for TegraCvtColor_rgb2hsv_Invoker
27395:00f858c8 V vtable for TegraCvtColor_rgb2hsvf_Invoker

I even tried to build opencv without custom hal carotene by changing ON to OFF in this line. But still throws the same undefined symbol: _ZN12carotene_o4t7r error. Which program or library is causing this issue ?

Please guide me to resolve this issue. Thanks.

jiuqiant commented 3 years ago

I disabled carotene_o4t when I built mediapipe python on aarch64 ubuntu. See the step 6 of https://github.com/jiuqiant/mediapipe_python_aarch64#readme.

sgowroji commented 3 years ago

Hi @superuser789, Please check the above comment.

hhajae commented 3 years ago

I have a Raspberrypi4 with Raspbian os. After import mediapipe as mp mp.solutions.hands in python3.7.3,

"module 'mediapipe' has no attribute 'solutions'".

I'm looking for the solution.

  1. file name = module name? --> My file name isn't same any module names.
  2. When I compared my desktop with Rpi, I found that there was another mediapipe folder in the mediapipe folder of the pie. So I wrote "from mediapipe import mediapipe" in init.py in the first mediapipe folder, and ran. An error occurred in "from mediapipe.python import *" in init.py in python module. It was that there was no "_framework_binding" module. Even though I have 'framework_binding.cc' in mediapipe/mediapipe/python.

So I found '_frameworkbinding~~.so' in mediapipe/python in mediapipe_python_aarch64/mediapipe-0.8.1-cp38-cp38-linux_aarch64.whl in https://github.com/jiuqiant/mediapipe_python_aarch64 but when I ran, I received error "ELFCLASS64".

Can't I use mediapipe in Python in Raspian? Should I install Ubuntu?

Please help. thank you. @jiuqiant @sgowroji

superuser789 commented 3 years ago

I disabled carotene_o4t when I built mediapipe python on aarch64 ubuntu. See the step 6 of https://github.com/jiuqiant/mediapipe_python_aarch64#readme.

I think, the most appropriate option to disable carotene_o4t is to add "WITH_CAROTENE": "OFF", in third_party/BUILD. After adding "WITH_CAROTENE": "OFF",, the ImportError was gone.

I have written all the steps here https://github.com/superuser789/MediaPipe-on-RaspberryPi#readme .

superuser789 commented 3 years ago

I have a Raspberrypi4 with Raspbian os. After import mediapipe as mp mp.solutions.hands in python3.7.3,

"module 'mediapipe' has no attribute 'solutions'".

I'm looking for the solution.

  1. file name = module name? --> My file name isn't same any module names.
  2. When I compared my desktop with Rpi, I found that there was another mediapipe folder in the mediapipe folder of the pie. So I wrote "from mediapipe import mediapipe" in init.py in the first mediapipe folder, and ran. An error occurred in "from mediapipe.python import *" in init.py in python module. It was that there was no "_framework_binding" module. Even though I have 'framework_binding.cc' in mediapipe/mediapipe/python.

So I found '_frameworkbinding~~.so' in mediapipe/python in mediapipe_python_aarch64/mediapipe-0.8.1-cp38-cp38-linux_aarch64.whl in https://github.com/jiuqiant/mediapipe_python_aarch64 but when I ran, I received error "ELFCLASS64".

Can't I use mediapipe in Python in Raspian? Should I install Ubuntu?

Please help. thank you. @jiuqiant @sgowroji

I think following steps 5&6 of https://github.com/jiuqiant/mediapipe_python_aarch64#readme, gives "module 'mediapipe' has no attribute 'solutions'" error. I rebuilt my mediapipe package without removing any OpenCV modules and did not face any error. I have written my steps here https://github.com/superuser789/MediaPipe-on-RaspberryPi#readme .

hhajae commented 3 years ago

I have a Raspberrypi4 with Raspbian os. After import mediapipe as mp mp.solutions.hands in python3.7.3, "module 'mediapipe' has no attribute 'solutions'". I'm looking for the solution.

  1. file name = module name? --> My file name isn't same any module names.
  2. When I compared my desktop with Rpi, I found that there was another mediapipe folder in the mediapipe folder of the pie. So I wrote "from mediapipe import mediapipe" in init.py in the first mediapipe folder, and ran. An error occurred in "from mediapipe.python import *" in init.py in python module. It was that there was no "_framework_binding" module. Even though I have 'framework_binding.cc' in mediapipe/mediapipe/python.

So I found '_frameworkbinding~~.so' in mediapipe/python in mediapipe_python_aarch64/mediapipe-0.8.1-cp38-cp38-linux_aarch64.whl in https://github.com/jiuqiant/mediapipe_python_aarch64 but when I ran, I received error "ELFCLASS64". Can't I use mediapipe in Python in Raspian? Should I install Ubuntu? Please help. thank you. @jiuqiant @sgowroji

I think following steps 5&6 of https://github.com/jiuqiant/mediapipe_python_aarch64#readme, gives "module 'mediapipe' has no attribute 'solutions'" error. I rebuilt my mediapipe package without removing any OpenCV modules and did not face any error. I have written my steps here https://github.com/superuser789/MediaPipe-on-RaspberryPi#readme .

I haven't tried "https://github.com/superuser789/MediaPipe-on-RaspberryPi#readme" yet, but thank you for uploading it. I'll try it in a minute. thank you.

sgowroji commented 3 years ago

Hi @superuser789, Glad to see your contributions for RaspberryPi in the above repo. We are closing this issue now. Please reach us if you still have any further queries relevant to the above issue.

google-ml-butler[bot] commented 3 years ago

Are you satisfied with the resolution of your issue? Yes No