google-coral / edgetpu

Coral issue tracker (and legacy Edge TPU API source)
https://coral.ai
Apache License 2.0
426 stars 125 forks source link

Building EdgeTPU Python API: make swig failed for armv7a #160

Closed othmaneAZ closed 3 years ago

othmaneAZ commented 4 years ago

Hello, I'm trying to cross-compile the EdgeTPU Python API for the armv7a by running make swig and make wheel . The bazel build fails and throws the following error :

`| NOTE: make -j 4 swig
| bazel build --compilation_mode=opt --copt=-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION --verbose_failures --sandbox_debug --subcommands --define PY3_VER=37 --cpu=armv7a --linkopt=-L/path/to/my/edgetpu/repo/libedgetpu/direct/armv7a --experimental_repo_remote_exec --crosstool_top=@crosstool//:toolchains --compiler=gcc --linkopt=-l:libedgetpu.so.1 --linkopt=-Wl,--strip-all --copt=-ffp-contract=off //src/cpp/swig:edgetpu_cpp_wrapper

| file is invalid or corrupted (missing end of central directory record)
| Opening zip "/proc/self/exe": Cannot find central directory
| FATAL: Failed to open '/proc/self/exe' as a zip file: (error: 5): Input/output error
| Makefile:138: recipe for target 'swig' failed
| make: *** [swig] Error 36`

I'm a bit confused about the root cause of this bug. I left the flags as set by default and changed the CPU to armv7a instead of k8. I don't know if I'm doing something wrong.

Thank you !

Namburger commented 4 years ago

@othmaneAZ hey! What exact command did you use to build? It should be something like this:

make CPU=armv7a swig

This may also be system independent type of issue, there are quite a few packages that needed to be install in order for all of our targets to build :) And even after successful build, your host pc may have mismatching glibc version than your build target :)
The recommended way is to build with docker:

make DOCKER_IMAGE=ubuntu:18.04  DOCKER_CPUS="armv7a" DOCKER_TARGETS=swig docker-build
othmaneAZ commented 4 years ago

Hey @Namburger, Thank's for the quick answer. Yes I used a make CPU=armv7a swig to build the EdgeTPU API. Actually I'm trying to avoid using docker containers and image since I'm using Yocto and bitbake to build my packages. It may be because of some missing dependencies, I'll try to make sure everything is present on the build environment. I was thinking that would be because of the --crosstool_top=@crosstool//:toolchains since it is not in the same repository as edgetpu, that's maybe why he is showing file is invalid or corrupted (missing end of central directory record), what is your saying ? I have another question though, do you find it normal that bazel is using gcc as a compiler instead of a cross compiler (something more like arm-linux-gnueabihf-gcc ) ?

Thank you,

Namburger commented 4 years ago

@othmaneAZ ahh I see, then that may be a little complicated since I don't even think we build these packages without docker haha I can build swig but not swig with CPU=armv7a and ideally we want everything to align when testing our library. Let me give it some try when i have a chance and will let you know, but I imagine that I'll run into different issues than you :/

To answer your question, --crosstool_top=@crosstool//:toolchains should be fine, because it comes from this toolchain which was pulled by bazel in the WORKSPACE. Now our crosstool is actually just using your system's crosscompiler that's why we instructed to first dpkg --add-architecture for armhf and arm64 and then install all the crossbuild packages.

othmaneAZ commented 4 years ago

@Namburger Thank you a lot for all these explanations, that makes the image clearer for me. I'll wait for your review about building swig with an amrv7a. Meanwhile I'll try to adapt my configuration to the dockerfile so I can build using docker_build and bazel instead.

Thank you,

Namburger commented 4 years ago

@othmaneAZ apologies, by means of an update, I just have not had a chance to give this a try since we've been having lots of new issues with the new runtime and all :/

hjonnala commented 3 years ago

closing this issue as EdgeTPU API is deprecated. it has been modeified to libcoral for c++ and pycoral for python.

google-coral-bot[bot] commented 3 years ago

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