Skip to content
This repository has been archived by the owner on Jan 7, 2020. It is now read-only.

Latest commit

 

History

History
127 lines (107 loc) · 4.03 KB

run_on_arm_en.md

File metadata and controls

127 lines (107 loc) · 4.03 KB

Build Anakin for ARM from source

Now, we have successfully build on mac os and centos, using Android NDK

Installation overview

1. system requirements

  • Host machine: linux, mac
  • cmake 3.8.2+
  • Android NDK r14, download linux version from here

2. dependencies

  $ tar -xzf protobuf-3.4.0.tar.gz  
  $ cd protobuf-3.4.0   
  $ ./autogen.sh  
  $ ./configure    
  $ make  
  $ make check   
  $ make install

for details, please refer here

  • 2.1.2 Build protobuf for ARM armeabi-v7a

Set your protobuf path here, search anakin_find_protobuf, and set ARM_RPOTO_ROOT to your path.

set(ARM_RPOTO_ROOT "${CMAKE_SOURCE_DIR}/third-party/arm-android/protobuf")
  • 2.2 opencv 2.4.3+(optional)
    We only use opencv in examples
    For Android, visit opencv release page, choose Android pack and download, copy libs in 3rdparty/libs/armeabi-v7a to libs/armeabi-v7a.
    Set your opencv path here, Search anakin_find_opencv, and set include_directories and LINK_DIRECTORIES according to your path.
    include_directories(${CMAKE_SOURCE_DIR}/third-party/arm-android/opencv/sdk/native/jni/include/)
    LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/third-party/arm-android/opencv/sdk/native/libs/armeabi-v7a/)

3. build from source

build for Android

clone the source code

    cd your_dir
    git clone https://github.com/PaddlePaddle/Anakin.git
    cd Anakin
    git fetch origin arm
    git checkout arm

change the android_build.sh

  • Set NDK path to yours

      #modify "your_ndk_path" to your NDK path
      export ANDROID_NDK=your_ndk_path
  • Set your ARM target platform

    For 32bits ARM CPU with NEON, Set ANDROID_ABI to armeabi-v7a with NEON, for 64bits ARM CPU, either arm64-v8a or armeabi-v7a with NEON can work.
    Now, we only support armeabi-v7a with NEONarm64-v8a is under developing

        -DANDROID_ABI="armeabi-v7a with NEON"
  • Set Android API level
    Choose your API LEVEL according to your android system version
    API Level 21 -> Android 5.0.1

        -DANDROID_NATIVE_API_LEVEL=21
  • build static or shared lib
    if building static lib, set BUILD_SHARED=NO
    if building shared lib, set BUILD_SHARED=YES

        -DBUILD_SHARED=NO
  • OpenMP for multi-threads
    set USE_OPENMP=YES to use OpenMP multi-threads

        -DUSE_OPENMP=YES
  • build unit test
    set BUILD_WITH_UNIT_TEST=YES to build unit tests

        -DBUILD_WITH_UNIT_TEST=YES
  • build examples
    set BUILD_EXAMPLES=YES to build detection and classification examples

        -DBUILD_EXAMPLES=YES
  • use opencv in examples
    set USE_OPENCV=YES to use opencv in examples

        -DUSE_OPENCV=YES
  • build
    run android_build.sh to build the Anakin

        ./android_build.sh

4. Verification

The libs is in ${Anakin_root}/output, the unit test and benchmark file is in ${Anakin_root}/output/unit_test and the examples is in ${Anakin_root}/output/examples
Open USB debug mode in your Android device, Use ADB to push the test files and model files to data/local/tmp/your_dir
run the test