Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Amalgamation for android arm64 was built successfully but failed to run in device #8151

Closed
zhenglaizhang opened this issue Oct 5, 2017 · 10 comments

Comments

@zhenglaizhang
Copy link

zhenglaizhang commented Oct 5, 2017

Environment info

Operating System: Arch Linux (build host)
Targeting Device: Android 7.0 with arm64-v8a CPU

Compiler:

  • Android toolchain produced from python make_standalone_toolchain.py --arch arm64 --install-dir /tmp/my-android-toolchain --stl=libc++
  • Latest NDK (15.2) & NDK 14, both run failed with same error
  • export CC=aarch64-linux-android-clang
  • export CXX=aarch64-linux-android-clang++

MXNet version: installed from source:

MXNet commit hash (git rev-parse HEAD):8a4221bca2ddd4fa05840f7951a7216775021237

Error Message:

When try to run on device, following exception was thrown.

Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_ZTVN4dmlc2io23IndexedRecordIOSplitterE" referenced by "/data/app/com.test.face-2/lib/arm64/libmxnet_predict.so"...
                                                                                       at java.lang.Runtime.loadLibrary0(Runtime.java:994)
                                                                                       at java.lang.System.loadLibrary(System.java:1533)
                                                                                       at org.dmlc.mxnet.Predictor.<clinit>(Predictor.java:28)

What have you tried to solve it?

  1. with c++fit it shows as below:
% c++filt _ZTVN4dmlc2io23IndexedRecordIOSplitterE
vtable for dmlc::io::IndexedRecordIOSplitter

Want to know if anybody have succeeded in building the arm64 arch for android with latest source. Thanks in advance.

@piiswrong
Copy link
Contributor

@larroy

@zhenglaizhang
Copy link
Author

And i checked the so, the symbol is indeeded undefined:

% nm libmxnet_predict.so | grep _ZTVN4dmlc2io23IndexedRecordIOSplitterE
         U _ZTVN4dmlc2io23IndexedRecordIOSplitterE

@larroy
Copy link
Contributor

larroy commented Oct 5, 2017

Please have a look at this PR:
#7792

I added an Android arm64 build file:

Dockerfile.build.android.arm64

I think we should remove the amalgamation and rely on the build system for cross platform builds as we discussed before.

@zhenglaizhang can you provide more details on how are you running on the device?

@zhenglaizhang
Copy link
Author

zhenglaizhang commented Oct 5, 2017

@larroy thanks for quick response!

just with following code at android side.

static {
        System.loadLibrary("mxnet_predict");
    }

Now as i checked, it's all because the generated mxnet_predict-all.cc really misses some method definitions, it compiles but fails at runtime, as I added the missed definitions, 3 to 4 missed definitions, I could load the mxnet_predict so on android device successfully.

Agree with you, amalgamation might be out of dated, and cross platform builds should be better, I will take some time tomorrow to try your dockerfile android arm64 build, hope it will works.

thanks for your helpful info -:)

@larroy
Copy link
Contributor

larroy commented Oct 5, 2017

@zhenglaizhang can you share the code of the project?

@zhenglaizhang
Copy link
Author

@larroy Hi,sorry for late response, thanks for the help, with the help from other thread, #4783 i added missing header files and built the so successfully.
And I tried the cross build docker, and found the built so was so large, around 30M if i remember correctly, and I couldn't run that successfully on android device.

@novioleo
Copy link

@zhenglaizhang you have to also add indexedRecordIOSplitter into mxnet_predict0.cc

@zhenglaizhang
Copy link
Author

zhenglaizhang commented Oct 24, 2017

@novioleo yeah, you are right, that's what i did to solve the problem. thanks for the info -:)

@novioleo
Copy link

@zhenglaizhang i think this issue had been solved,can you close it?

@zhenglaizhang
Copy link
Author

Close as the issue was resolved, thanks all for the help!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants