Error "libc.so.6" not found while executing model on Android device

Steps followed:

python3 -m tvm.driver.tvmc compile --target “llvm -device=arm_cpu -mtriple=aarch64-linux-gnu” --cross-compiler ‘aarch64-linux-gnu-gcc’ -o resnet50-v2-7-tvm-arm64CPU.tar …/resnet50-v2-7.onnx

  • The compiled models got generated in resnet50-v2-7-tvm-arm64CPU.tar.
  • When tested on Android device using the android_deploy test app with the generated TVM compiled model files(mod.so, mod.json, mod.params) we get the following error:

09-30 17:04:23.148 8538 8582 E AndroidRuntime: Caused by: org.apache.tvm.Base$TVMError: TVMError: Check failed: lib_handle_ != nullptr: Failed to load dynamic shared library /data/user/0/org.apache.tvm.android.demo/cache/tvm4j_demo_8799703069585602242/mod.so dlopen failed: library “libc.so.6” not found: needed by /data/data/org.apache.tvm.android.demo/cache/tvm4j_demo_8799703069585602242/mod.so in namespace classloader-namespace

There is no libc.so.6 library found in the Android /system/ folder.

Is the steps followed are correct or we need to using a different cross-compiler toolchain for Android?

The issue is resolved by downloading the latest Android NDK and giving Clang compiler for cross-compilation.

tvmc compile --target “llvm -device=arm_cpu -mtriple=aarch64-linux-android” --cross-compiler ‘$ANDROID_NDK_PATH/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android30-clang’ -o mobilenet_v2_pytorch_arm64_cpu.tar models/mobilenet_v2_pytorch.onnx