Skip to content
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

Have built successfully, but cannot used in Android studio project #5

Open
joyzhou28 opened this issue Nov 2, 2017 · 4 comments
Open

Comments

@joyzhou28
Copy link

I have built this successfully resulting in libcaffe.so and libcaffe.jni.so, but when importing .so and .jni.so into caffe-android-demo, error comes as following,
11-02 10:23:28.625 8540-8540/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.sh1r0.caffe_android_demo, PID: 8540
java.lang.UnsatisfiedLinkError: No implementation found for void com.sh1r0.caffe_android_lib.CaffeMobile.setNumThreads(int) (tried Java_com_sh1r0_caffe_1android_1lib_CaffeMobile_setNumThreads and Java_com_sh1r0_caffe_1android_1lib_CaffeMobile_setNumThreads__I)
at com.sh1r0.caffe_android_lib.CaffeMobile.setNumThreads(Native Method)
at com.sh1r0.caffe_android_demo.MainActivity.onCreate(MainActivity.java:91)
at android.app.Activity.performCreate(Activity.java:6861)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2693)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2801)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1548)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6365)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:791)

I guess it may be because something wrong with the dynamic library files since it is ok when I import .so and .jni.so in caffe-android-lib into this project.

@OValery16
Copy link

I made it work (one year ago), I will give you few tips to solve your problem:

  • check that you are building your shared library for the right ABI (for me your code seems to say that your compiler cannot find the library and maybe the reason might be because of the ABI)

  • if it doesn't work, I advise you to check line by line in the code which function is actually not working

  • There is a problem with the file "deploy.proto", the reason is that caffe slightly modified their definition of a valid deploy.proto, which make older version such as the one used in this repo to fail. I advise you to take a look at the previous definition of deploy.proto, and manually make the changes.

  • I want to give you a hint about the performance you can get. Caffe with OpenCL means your program will run on the GPU, but it doesn't guarantee you good performance. The reason is that Caffe-OpenCL is optimized for running on high-end GPU (such as the one existing on servers), and low-end GPUs (the one on mobile devices) suffer from a lack of hardware resources, such as local memory. Since Caffe-OpenCL uses matrix multiplication operation (GEMM kernel), the lack of local memory limits the ability of GPU cores to collaborate.

Personally, I worked on Deep Learning on mobile devices, and I release my own framework
https://github.com/OValery16/TransferCL
I published a paper about it and I will present it during the next ICPADS conference.

In addition, there are several other interesting frameworks. (they are not mine)
https://github.com/ENCP/CNNdroid
https://github.com/JC1DA/DeepMon

This is a list of papers about the topic
https://github.com/csarron/emdl

Feel free to contact me if you have any question about deep learning on mobile devices.

Best regards,

Olivier

@joyzhou28
Copy link
Author

Thank you so much for your answer. I checked the original codes actually could not find the functions mentioned in logcat. I've made modification.
But new problem comes up--native crash --SIGABT

screenshot_2017-11-02-16-01-25-613_com miui bugreport

screenshot_2017-11-06-15-05-56-727_com miui bugreport

The mobile phone I test is Xiaomi6 (snapdragon835, AArch64, corresponding abi is arm64-v8a). I wander whether shared library could support arm64-v8a.

@OValery16
Copy link

look at the end: the function "readNetParamsFromTextOrDie". As I mentioned earlier, you may use the new definition of "deploy.proto". Caffe is looking for some information and don't find it, so it quit the program. On NDK, it immediately lead to a segmentation error.

Check the old definition of deploy.proto. From what i remember it is just a difference of one line.

Olivier

@joyzhou28
Copy link
Author

android app could run but as you said, of very bad performance. I looked at logcat and found the problem:

11-08 10:46:17.983 28133-28133/? I/caffe_jni: I1108 10:46:17.982991 28133 caffe_mobile.cpp:66] #GPUs1
11-08 10:46:17.983 28133-28133/? I/caffe_jni: I1108 10:46:17.983104 28133 caffe_mobile.cpp:70] Use GPU with device ID 0
11-08 10:46:17.986 28133-28133/? W/Adreno-Prof: q3dToolsDrvInitGraphics:1322: PROFILER: Error Loading gl2 driver library jumptable

when select an image for classification, there comes:
11-08 10:47:28.230 28133-28133/strin.caffe_android_demo I/Choreographer: Skipped 169 frames! The application may be doing too much work on its main thread.

Could you please tell tell why "Skipped XXX frames! The application may be doing too much work on its main thread." .

Thank you!

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

No branches or pull requests

2 participants