-
Notifications
You must be signed in to change notification settings - Fork 819
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
Support cross compilation for ARM Linux #36
Comments
交叉编译的话,不需要提供芯片类型和参数吧。按理说,只要交叉编译链支持c++11(MACE用了c++11),只需要提供一个如何进行交叉编译的教程就行了额。 |
感谢mace这么赞的工作。arm linux需求巨大,支持armv8/aarch64加mali就很通用了。一个栗子 再次感谢 |
@zhy520xp 另外需要确认OpenCL的支持情况以及兼容的可行性,因为不同系统差别较大。我们没有开发环境,所以希望收集一下信息,同样如果你跑通了,也请反馈一下,非常感谢。 |
as @leogift mentioned, rk3399 is widely used in industry |
确实呀, RK3399,这个真的是需要的 |
https://github.com/zhy520xp/mace-makefile-project 做好了交叉编译,可以参考参考 |
像3559A和3536这类嵌入式平台,如何编译出能跑gpu版本的东西,是否应该支持一下。。 |
现在bazel 编译卡住在了 protobuf 的编译问题上。 mace 编译会调用protobuf 交叉编译出来的工具,这样就导致了执行格式错误。 |
我用bazel 工具在arm linux 上编译出了mace 库,但是跑起来时间很长,请问bazel 规则中的neon是默认enable的吗? |
@llhe 目前基本已经整理出了bazel 编译的方法,不过我在3516D 上跑的时间不理想。可以把前面整理的方法提供出来 |
@hbwangjinwu 赞,可以发一个PR吗?需要显式打开,可以参考此处宏定义:https://github.com/XiaoMi/mace/blob/master/mace/kernels/arm/conv_2d_neon_15x1.cc#L76 |
https://github.com/hbwangjinwu/mace_cross_compile_guide guide 和我的交叉编译设定 |
bazel 命令加上 |
What about the ASUS TinkerBoard with RK3288? |
I got it working on the TinkerBoard and made a fork of the Makefile repo with English instructions: |
@madhavajay 你好,试着运行了mace-makefile-project的demo程序,但是运行结果为什么CPU反而比GPU还要快? |
@shuxiao9058 一般来讲,移动端GPU和CPU跑同一个模型,GPU是比CPU慢一些。比如3288的GPU性能就只有CPU的一半。这其实和平台很相关的,具体来讲就是你的CPU是啥型号,GPU是啥型号,同时GPU核心数也是很重要的,核心越多越快。比如同样是Mali-G71,4个核心就比2个核心快很多 |
@shuxiao9058 @zhy520xp I don't know why the performance is as it is, perhaps i can improve with different compile flags? However 6 fps is much better than 0.8-1 fps on a RPi 3, so I think the acceleration of MACE is fairly impressive. Any suggestion on faster improvement would be appreciated. I read Winograd is theoretically 2.2x faster? |
@madhavajay if your model deploy on cpu,you can try NCNN(https://github.com/Tencent/ncnn)。NCNN uses Winograd and 8-bit quantization for convolution computation。You are worth a try! |
@zhy520xp okay great I will look at it, thank you! :) |
@zhy520xp do you know if it supports SSD MobileNet architecture? |
We will add Linaro toolchain soon which will enable official cross compiling for ARM Linux. |
近期将会添加一个基于Linaro的默认ARM交叉编译器工具链,支持ARM Linux的交叉编译 |
@llhe Would the MACE documentation be updated with this? And can the build command be added to |
@tataganesh95 It will be integrated into the tools soon, and the documents will be updated accordingly. Before that, you can simply build it with the following commands (not tested yet): bazel build -s --config aarch64_linux --define openmp=true --define opencl=true --define neon=true //mace/libmace:libmace.so Note: there is an issue with armeabi-v7a + NEON, which will be resolved soon. |
@llhe you guys are awesome! Will test this soon. I assume that this will build on Ubuntu and just needs the correct arm toolchain installed? Is there more instructions for someone like me who isnt experienced with cross compiling? |
Where do the neon headers come from are they part of the arm toolchain? |
@llhe Sorry for extending this discussion, but I am not very experienced with cross-compilation, and a little confused regarding the model deployment process. Here are the steps I followed for cross compilation -
|
@tataganesh95 Do you need Android aarch64 or Linux aarch64? They are different ABIs and need different toolchains. Currently Android build is well supported and you can follow the steps in the documents. This issue addresses the Linux aarch64 build which is not fully supported yet (you can use the previously mentioned bazel command to make the compilation). But the python tools wrapper is not well supported (e.g. tools/converter.py may not work) now (for example, it assumes adb to connect the device which is not true for Linux aarch64 boards), and we will be working on these tasks. |
@tataganesh95 If you want to try with ARM Linux aarch64 before all the tools ready, you can build |
Linux aarch64
I have done the same, ran the example script as well. But since my target os is linux, I am not sure how am I supposed to run I just wanted to know, whether the steps I followed for cross-compilating mace , and running the example on the target device, are right, or have I missed something? ( Steps have been mentioned in my previous comment ), Eagerly looking forward to tools that can facilitate cross compilation for Arm linux! Thank you once again for such a prompt response! |
@tataganesh95 The result of |
@llhe I wasn't aware of that. Thank you! I will wait till the tools for ARM linux are built. |
@tataganesh95 I was able to skip the Android stuff just by installing adb which is really easy:
Then:
|
@madhavajay I was able to run the convert script and obtained |
@tataganesh95 you have gotten further than me. I literally just got it compiled and ran the test code in the make file project. My task was to evaluate if it was possible, I havent had a chance to actually use it yet. Sorry. :) Please let me know if you solve the issue as I will likely have the same problems. |
@llhe is there any update on when the Linux aarch 64 architecture might be ready? Do you have any provisional benchmark results for it? |
I ran this:
Got this issue:
Full output:
|
@llhe any idea why i cant build the same cross compile libmace.so that the gitlab ci file says it builds? |
Anyone know how to solve the above? I'm also trying to solve this. |
@pathwayai Do you have the same problem? |
@madhavajay cd /home/pathwayai/.cache/bazel/_bazel_pathwayai/c7986ad00fc23123aa9184aa80c62d45/execroot/mace
/home/pathwayai/.cache/bazel/_bazel_pathwayai/c7986ad00fc23123aa9184aa80c62d45/execroot/mace/_bin/linux-sandbox -t 15 -w /home/pathwayai/.cache/bazel/_bazel_pathwayai/c7986ad00fc23123aa9184aa80c62d45/sandbox/linux-sandbox/1/execroot/mace -w /tmp -w /dev/shm -D -- tools/arm_compiler/linaro_linux_gcc/arm-linux-gnueabihf-gcc -shared -o bazel-out/armeabi-v7a-fastbuild/bin/mace/libmace/libmace.so -Wl,-soname,libmace.so -Wl,--version-script mace_version_script.lds -fopenmp '--sysroot=external/gcc_linaro_7_3_1_arm_linux_gnueabihf/arm-linux-gnueabihf/libc' '-fuse-ld=gold' -Wl,-no-as-needed -no-canonical-prefixes -v -Wl,-z,relro,-z,now '-Wl,--build-id=md5' '-Wl,--hash-style=gnu' -Wl,-S -Wl,@bazel-out/armeabi-v7a-fastbuild/bin/mace/libmace/libmace.so-2.params |
Depend on
I modified the "tools/build-standalone-lib.sh" to get aarch64 libraries: echo "build shared lib for aarch64 + cpu"
bazel build -s --config optimization --config aarch64_linux --define openmp=true --define opencl=false --define neon=true //mace/libmace:libmace_dynamic
# bazel build --config android --config optimization mace/libmace:libmace_dynamic --define neon=true --define openmp=true --define opencl=true --define quantize=true --cpu=arm64-v8a
cp bazel-bin/mace/libmace/libmace.so $LIB_DIR/aarch64/cpu/
if [[ "$OSTYPE" != "darwin"* ]];then
echo "build shared lib for linux-x86-64"
bazel build mace/libmace:libmace_dynamic --config optimization --define quantize=true --define openmp=true
cp bazel-bin/mace/libmace/libmace.so $LIB_DIR/linux-x86-64/
fi then got a benchmark result on mobilenet-v1:
but comparing to the benchmark result on the same model when using the latest release version mace without building libs for aarch64, it is a bad latency performance degradation:
Question
|
1. Abstact android and arm linux to one format 2. Support cross compilation for ARM linux 3. Related issue #36
@Alnlll You can try with official support. If there is a abnormal performance degradation, please file a new issue. |
Close this which is official supported. |
any one already got some benchmark on RK33XX series? we are using RK3399 and we'd love to leverage the Mali 860 on the board. But it seems a hard task. Just wanna get some sense about if the GPU can actually out perform the CPU cus I noticed in the above conversation it seems GPU is not always faster than CPU on mobile platform. BTW, this is really an awesome project! Thanks guys! |
@nolanliou thanks so much! This is very helpful |
有需求的可以在这里提一下。顺便提供一下:
The text was updated successfully, but these errors were encountered: