* change docs from 1.x to main * bump version * update readme status info and highlights * revert version change * fix dead links * fix script * fix docs * fix building status * fix md lint error * upgrade to ubuntu20.04 for github ci * Revert "upgrade to ubuntu20.04 for github ci" This reverts commit 9c598f4857633dfb96b116ca9fb9a5d15b5fa6b4. * update codebase md files * upgrade to ubuntu20.04 for github ci * fix * fix requirements * fix * fix ci * bump version * fix * fix pplnn torchscript * fix building status * fix ncnn * fix * remove circileci hold * fix pytorch image
4.2 KiB
Build for Android
MMDeploy provides cross compile for android platform.
Model converter is executed on linux platform, and SDK is executed on android platform.
Here are two steps for android build.
-
Build model converter on linux, please refer to How to build linux
-
Build SDK using android toolchain on linux.
This doc is only for how to build SDK using android toolchain on linux.
Build From Source
Install Toolchains
-
cmake
Make sure cmake version >= 3.14.0. If not, you can follow instructions below to install cmake 3.20.0. For more versions of cmake, please refer to cmake website.
wget https://github.com/Kitware/CMake/releases/download/v3.20.0/cmake-3.20.0-linux-x86_64.tar.gz tar -xzvf cmake-3.20.0-linux-x86_64.tar.gz sudo ln -sf $(pwd)/cmake-3.20.0-linux-x86_64/bin/* /usr/bin/
-
ANDROID NDK 19+
Make sure android ndk version >= 19.0. If not, you can follow instructions below to install android ndk r23c. For more versions of android ndk, please refer to android ndk website.
wget https://dl.google.com/android/repository/android-ndk-r23c-linux.zip unzip android-ndk-r23c-linux.zip cd android-ndk-r23c export NDK_PATH=${PWD}
Install Dependencies
Install Dependencies for SDK
You can skip this chapter if only interested in model converter.
NAME | INSTALLATION |
---|---|
OpenCV (>=3.0) |
|
ncnn | A high-performance neural network inference computing framework supporting for android. Now, MMDeploy supports 20220721 and has to use git clone to download it. For supported android ABI, see here .
|
OpenJDK | It is necessary for building Java API. See Java API build for building tutorials. |
Build MMDeploy
Build SDK and Demos
MMDeploy provides a recipe as shown below for building SDK with ncnn as inference engine for android.
- cpu + ncnn
export ANDROID_ABI=arm64-v8a cd ${MMDEPLOY_DIR} mkdir -p build_${ANDROID_ABI} && cd build_${ANDROID_ABI} cmake .. \ -DMMDEPLOY_BUILD_SDK=ON \ -DMMDEPLOY_BUILD_SDK_JAVA_API=ON \ -DMMDEPLOY_BUILD_EXAMPLES=ON \ -DOpenCV_DIR=${OPENCV_ANDROID_SDK_DIR}/sdk/native/jni/abi-${ANDROID_ABI} \ -Dncnn_DIR=${NCNN_DIR}/build_${ANDROID_ABI}/install/lib/cmake/ncnn \ -DMMDEPLOY_TARGET_BACKENDS=ncnn \ -DMMDEPLOY_SHARED_LIBS=OFF \ -DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \ -DANDROID_ABI=${ANDROID_ABI} \ -DANDROID_PLATFORM=android-30 \ -DANDROID_CPP_FEATURES="rtti exceptions" make -j$(nproc) && make install
Please check cmake build option spec