oberluz / pycoral

Python API for ML inferencing and transfer-learning on Coral devices
https://coral.ai
Apache License 2.0
34 stars 2 forks source link

Error during the build step #5

Closed StefanoGiu closed 9 months ago

StefanoGiu commented 9 months ago

ERROR: /root/.cache/bazel/_bazel_root/eab0d61a99b6696edb3d2aff87b585e8/external/ruy/ruy/BUILD:576:11: Compiling ruy/pack_arm.cc failed: (Exit 1): arm-linux-gnueabihf-gcc failed: error executing command (cd /root/.cache/bazel/_bazel_root/eab0d61a99b6696edb3d2aff87b585e8/sandbox/processwrapper-sandbox/1348/execroot/pycoral && \ exec env - \ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin \ PWD=/proc/self/cwd \ /usr/bin/arm-linux-gnueabihf-gcc -fPIC -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-march=armv7-a' '-mfpu=neon-vfpv4' -g0 -O3 -DNDEBUG '-D_FORTIFY_SOURCE=2' -ffunction-sections -fdata-sections -funsafe-math-optimizations -ftree-vectorize '-std=c++14' -MD -MF bazel-out/armv7a-opt/bin/external/ruy/ruy/_objs/pack_arm/pack_arm.d '-frandom-seed=bazel-out/armv7a-opt/bin/external/ruy/ruy/_objs/pack_arm/pack_arm.o' -iquote external/ruy -iquote bazel-out/armv7a-opt/bin/external/ruy -iquote external/cpuinfo -iquote bazel-out/armv7a-opt/bin/external/cpuinfo -iquote external/clog -iquote bazel-out/armv7a-opt/bin/external/clog -Ibazel-out/armv7a-opt/bin/external/cpuinfo/_virtual_includes/cpuinfo -Ibazel-out/armv7a-opt/bin/external/clog/_virtual_includes/clog '-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION' '-ffp-contract=off' -Wall -Wextra -Wc++14-compat -Wundef '-mfpu=neon' -O3 -no-canonical-prefixes -fno-canonical-system-headers -Wno-builtin-macro-redefined '-DDATE="redacted"' '-DTIMESTAMP="redacted"' '-DTIME="redacted"' -c external/ruy/ruy/pack_arm.cc -o bazel-out/armv7a-opt/bin/external/ruy/ruy/_objs/pack_arm/pack_arm.o) Execution platform: @local_execution_config_platform//:platform

Use --sandbox_debug to see verbose messages from the sandbox arm-linux-gnueabihf-gcc failed: error executing command (cd /root/.cache/bazel/_bazel_root/eab0d61a99b6696edb3d2aff87b585e8/sandbox/processwrapper-sandbox/1348/execroot/pycoral && \ exec env - \ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin \ PWD=/proc/self/cwd \ /usr/bin/arm-linux-gnueabihf-gcc -fPIC -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-march=armv7-a' '-mfpu=neon-vfpv4' -g0 -O3 -DNDEBUG '-D_FORTIFY_SOURCE=2' -ffunction-sections -fdata-sections -funsafe-math-optimizations -ftree-vectorize '-std=c++14' -MD -MF bazel-out/armv7a-opt/bin/external/ruy/ruy/_objs/pack_arm/pack_arm.d '-frandom-seed=bazel-out/armv7a-opt/bin/external/ruy/ruy/_objs/pack_arm/pack_arm.o' -iquote external/ruy -iquote bazel-out/armv7a-opt/bin/external/ruy -iquote external/cpuinfo -iquote bazel-out/armv7a-opt/bin/external/cpuinfo -iquote external/clog -iquote bazel-out/armv7a-opt/bin/external/clog -Ibazel-out/armv7a-opt/bin/external/cpuinfo/_virtual_includes/cpuinfo -Ibazel-out/armv7a-opt/bin/external/clog/_virtual_includes/clog '-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION' '-ffp-contract=off' -Wall -Wextra -Wc++14-compat -Wundef '-mfpu=neon' -O3 -no-canonical-prefixes -fno-canonical-system-headers -Wno-builtin-macro-redefined '-DDATE="redacted"' '-DTIMESTAMP="redacted"' '-DTIME="redacted"' -c external/ruy/ruy/pack_arm.cc -o bazel-out/armv7a-opt/bin/external/ruy/ruy/_objs/pack_arm/pack_arm.o) Execution platform: @local_execution_config_platform//:platform

Use --sandbox_debug to see verbose messages from the sandbox In file included from external/ruy/ruy/pack_arm.cc:16: external/ruy/ruy/pack_arm.h:492:9: warning: multi-line comment [-Wcomment] 492 | #endif // (RUY_PLATFORM_NEON_64 || RUY_PLATFORM_NEON_32) && \

oberluz commented 9 months ago

I haven't provided armv7a wheels due to this issue which I reported 3 weeks ago: https://github.com/google/ruy/issues/347

Your best bet is to clone tensorflow and try to build it for armv7a and when it fails raise an issue with the tensorflow project.

Or try to fix it in Ruy yourself ;)

StefanoGiu commented 9 months ago

I don't have an ARMv7 processor... I have an Intel i3 octacore... 64 bit... Why I enter into the ARMv7 path?

oberluz commented 9 months ago

Please paste the commands you are using to build it

StefanoGiu commented 9 months ago

I tried both with scripts/build.sh and scripts/build_deb.sh.

I'm on Linux Mint 21

oberluz commented 9 months ago

Can you paste the command you are using?

If you are using just scripts/builds.sh then you will be building all python versions for all archs, including arm7a

StefanoGiu commented 9 months ago

I'm using "scripts/build.sh"... this is the command... what shall I use?

oberluz commented 9 months ago

What arch / python version are you after?

On Wed, 8 Nov 2023, 17:28 StefanoGiu, @.***> wrote:

I'm using "scripts/build.sh"... this is the command... what shall I use?

— Reply to this email directly, view it on GitHub https://github.com/oberluz/pycoral/issues/5#issuecomment-1802242898, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKFR7TFSIPNDCRAZ2QJQK3YDOXMPAVCNFSM6AAAAAA7CJ6PEKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBSGI2DEOBZHA . You are receiving this because you modified the open/close state.Message ID: @.***>

StefanoGiu commented 9 months ago

I'm on Python 3.10.12 and x86_64 arch.

oberluz commented 9 months ago

Why don't you use the wheels already provided in the releases?

$ python --version
Python 3.10.12

$ python3 -m pip install ~/Downloads/tflite_runtime-2.13.0-cp310-cp310-linux_x86_64.whl 
Defaulting to user installation because normal site-packages is not writeable
Processing /home/eyeot-demo/Downloads/tflite_runtime-2.13.0-cp310-cp310-linux_x86_64.whl
Requirement already satisfied: numpy>=1.16.0 in /usr/local/lib/python3.10/dist-packages (from tflite-runtime==2.13.0) (1.23.3)
Installing collected packages: tflite-runtime
Successfully installed tflite-runtime-2.13.0

$ python3 -m pip install ~/Downloads/pycoral-2.13.0-cp310-cp310-linux_x86_64.whl 
Defaulting to user installation because normal site-packages is not writeable
Processing /home/eyeot-demo/Downloads/pycoral-2.13.0-cp310-cp310-linux_x86_64.whl
Requirement already satisfied: Pillow>=4.0.0 in /usr/local/lib/python3.10/dist-packages (from pycoral==2.13.0) (10.1.0)
Requirement already satisfied: numpy>=1.16.0 in /usr/local/lib/python3.10/dist-packages (from pycoral==2.13.0) (1.23.3)
Requirement already satisfied: tflite-runtime==2.13.0 in /home/eyeot-demo/.local/lib/python3.10/site-packages (from pycoral==2.13.0) (2.13.0)
Installing collected packages: pycoral
Successfully installed pycoral-2.13.0

You can build it yourself with:

$ git checkout 2_7_0 # or 2_14_0
$ git submodule update --init --recursive
$ DOCKER_CPUS=k8 scripts/build.sh --python_versions 310

Note in scripts/build.sh that 310 is built using ubuntu:22.04. If you get an error message when installing the wheels due to libc you could try changing ubuntu:22.04 to use a docker image for your linux mint release.

StefanoGiu commented 9 months ago

Sorry, where can I get those whl files?

oberluz commented 9 months ago

Look in the main page on the right there is a link called releases.

It points to https://github.com/oberluz/pycoral/releases

StefanoGiu commented 9 months ago

Thanks a lot!! I installed it, but now when I run:

root@ServerNVR:/home/stefano/coral/coral/pycoral# python3 examples/classify_image.py \ --model test_data/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite \ --labels test_data/inat_bird_labels.txt \ --input test_data/parrot.jpg

I get the following error: Traceback (most recent call last): File "/usr/local/lib/python3.10/dist-packages/tflite_runtime/interpreter.py", line 166, in load_delegate delegate = Delegate(library, options) File "/usr/local/lib/python3.10/dist-packages/tflite_runtime/interpreter.py", line 104, in init raise ValueError(capture.message) ValueError

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/stefano/coral/coral/pycoral/examples/classify_image.py", line 121, in main() File "/home/stefano/coral/coral/pycoral/examples/classify_image.py", line 71, in main interpreter = make_interpreter(*args.model.split('@')) File "/usr/local/lib/python3.10/dist-packages/pycoral/utils/edgetpu.py", line 87, in make_interpreter delegates = [load_edgetpu_delegate({'device': device} if device else {})] File "/usr/local/lib/python3.10/dist-packages/pycoral/utils/edgetpu.py", line 52, in load_edgetpu_delegate return tflite.load_delegate(_EDGETPU_SHARED_LIB, options or {}) File "/usr/local/lib/python3.10/dist-packages/tflite_runtime/interpreter.py", line 168, in load_delegate raise ValueError('Failed to load delegate from {}\n{}'.format( ValueError: Failed to load delegate from libedgetpu.so.1

Can you help here?

oberluz commented 9 months ago

Paste the relevant code...

StefanoGiu commented 9 months ago

I'm following this link: https://coral.ai/docs/accelerator/get-started/#3-run-a-model-on-the-edge-tpu

StefanoGiu commented 9 months ago

I'm trying to run: python3 examples/classify_image.py --model test_data/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite --labels test_data/inat_bird_labels.txt --input test_data/parrot.jpg

oberluz commented 9 months ago

Did you plugin in your coral stick into the USB port?

I ran it without the coral and I got the same error:

eyeot-demo@eyeotdemo-ThinkPad-X380-Yoga:~/src/pycoral/tmp(2_7_0)$ python3.8 ../examples/classify_image.py --model ../test_data/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite --labels ../test_data/inat_bird_labels.txt --input ../test_data/parrot.jpg
Traceback (most recent call last):
  File "/home/eyeot-demo/.local/lib/python3.8/site-packages/tflite_runtime/interpreter.py", line 182, in load_delegate
    delegate = Delegate(library, options)
  File "/home/eyeot-demo/.local/lib/python3.8/site-packages/tflite_runtime/interpreter.py", line 120, in __init__
    raise ValueError(capture.message)
ValueError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "../examples/classify_image.py", line 122, in <module>
    main()
  File "../examples/classify_image.py", line 72, in main
    interpreter = make_interpreter(*args.model.split('@'))
  File "/home/eyeot-demo/.local/lib/python3.8/site-packages/pycoral/utils/edgetpu.py", line 87, in make_interpreter
    delegates = [load_edgetpu_delegate({'device': device} if device else {})]
  File "/home/eyeot-demo/.local/lib/python3.8/site-packages/pycoral/utils/edgetpu.py", line 52, in load_edgetpu_delegate
    return tflite.load_delegate(_EDGETPU_SHARED_LIB, options or {})
  File "/home/eyeot-demo/.local/lib/python3.8/site-packages/tflite_runtime/interpreter.py", line 184, in load_delegate
    raise ValueError('Failed to load delegate from {}\n{}'.format(
ValueError: Failed to load delegate from libedgetpu.so.1

I plugged it in and it works:

eyeot-demo@eyeotdemo-ThinkPad-X380-Yoga:~/src/pycoral/tmp(2_7_0)$ vi ../examples/classify_image.py
eyeot-demo@eyeotdemo-ThinkPad-X380-Yoga:~/src/pycoral/tmp(2_7_0)$ python3.8 ../examples/classify_image.py --model ../test_data/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite --labels ../test_data/inat_bird_labels.txt --input ../test_data/parrot.jpg
----INFERENCE TIME----
Note: The first inference on Edge TPU is slow because it includes loading the model into Edge TPU memory.
98.9ms
11.1ms
11.0ms
11.1ms
11.1ms
-------RESULTS--------
Ara macao (Scarlet Macaw): 0.75781
eyeot-demo@eyeotdemo-ThinkPad-X380-Yoga:~/src/pycoral/tmp(2_7_0)$ 
StefanoGiu commented 9 months ago

Yes, it's plugged in, but used by Frigate in a container. Maybe Frigate is locking the USB Coral somehow?

StefanoGiu commented 9 months ago

Any idea? The issue seems to be intermittent and sometimes I get a segmentation fault... with a core dump!

StefanoGiu commented 9 months ago

I tried to stop Frigate, but the issue is still there...

oberluz commented 9 months ago

I can't give you any advice re Frigate.

Try it outside is all I can suggest

On Sat, 11 Nov 2023, 12:10 StefanoGiu, @.***> wrote:

I tried to stop Frigate, but the issue is still there...

— Reply to this email directly, view it on GitHub https://github.com/oberluz/pycoral/issues/5#issuecomment-1806786392, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKFR7RJPTBJ66FEJJXXBZLYD5MI7AVCNFSM6AAAAAA7CJ6PEKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBWG44DMMZZGI . You are receiving this because you modified the open/close state.Message ID: @.***>

StefanoGiu commented 9 months ago

I tried outside Frigate container... it's the same...