Demonstration of using Caffe2 inside an Android application.
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 4 commits ahead of caffe2:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
Exporting Squeezenet to mobile.ipynb

Caffe2 AICamera tutorial example

This is an example for using Caffe2 on Android. See the original README for details.

Using caffe2 from PyTorch master

Newer android seems to prefer clang, at least I couldn't find the gnu stl lib.

To compile libs for armeabi-v7a I used

ANDROID_NDK=~/Android/Sdk/ndk-bundle/ ./scripts/ -DANDROID_TOOLCHAIN=clang

For x86 (useful to debug android apps) I needed to disable AVX. To do this, I inserted if (NOT DISABLE_AVX) and endif() before and after the AVX check in cmake/MiscCheck.cmake.

I then built with

ANDROID_NDK=~/Android/Sdk/ndk-bundle/ BUILD_ROOT=$(pwd)/build_android_x86   ./scripts/ -DANDROID_TOOLCHAIN=clang  -DANDROID_ABI=x86 -DDISABLE_AVX=1

Then I copied the resulting build_android*/lib/lib* into the corresponding x86 and armeabi-v7a subdirectories of app/src/main/jniLibs.

You would likely want to replace the headers in app/src/main/cpp with those from torch/lib/include or so (possibly after building PyTorch).