Dockerfile for mobile development

Hi. I 'd like to test the mobile applications of TVM so am learning how to prepare the environment. As it turns out, several packages are typically required for this, including gradle, Java runtime, Android studio and NDK. Unfortunately, some of them have custom installers and are overall bulky, which complicates the setup and don’t lead to reproducible workflow. There may be a reason in having default system image with all the things properly installed. AFAIK, tvm ships only *gpu and *cpu Dockerfiles for demonstration purposes. Did anybody already tried to encode tvm-friendly mobile development environment by writing a Dockerfile for it? Are there any reasons why this may be a not good idea?

Regards,
Sergey

We can consider putting something like this together; though I don’t know how well the required USB support would work in docker.

I’m very new to the project and community. Based on my experience with Docker, USB device can be mounted into the container at “runtime” and not build time. So the Dockerfile will be the same with most of your dependencies and your image startup command shall contain some custom mounting to make things work. This is very similar to GPU devices mounting in Docker containers.

Thanks, I also think that accessing USB port from Docker should be possible. Another problem - how to install Gradle, NDK and android tools? I heard it is possible to do it via GUI dialog from Android Studio, but it probably hard to encode as script. Is it possible to install those packages via command line? Do we really need Android Studio or Android SDK is enough?

As far as I’m aware, you can install Gradle and android tools with command line shell easily. You can refer to example like https://github.com/keeganwitt/docker-gradle/blob/dce2d0cea0b0e60435919b7c7faa686b6cccf2f1/jdk7/Dockerfile

You don’t need GUI tools to install these. They are just binary files you can download easily, then you can configure it inside the Dockerfile.

@walterh thank you. Here is the current version of tvm-friendly Dockerfile, based on the link you posted. I didn’t go beyond basic tests of gradle and ndk yet but it could be used as a baseline. Also I had to download ndk manually since their site asks for EULA confirmation.

Please consider reviewing https://github.com/dmlc/tvm/pull/1646

Recently I am trying to deploy on mobile device following this tutorial Android TVM Demo
,but I encountered some problems.


1.I can’t build a local environment.You can see some my posted error Build Android APK error

2.So I try to use docker image with this command showed in android tvm demo ./docker/build.sh demo_android -it bash ,but also failed.There are some error outputs:

acui@OFShare:~/tvm/tvm$ ./docker/build.sh demo_android -it bash

WORKSPACE: /home/acui/tvm/tvm/docker/../
CI_DOCKER_EXTRA_PARAMS: -it
COMMAND: bash
CONTAINER_TYPE: demo_android
BUILD_TAG: tvm
DOCKER CONTAINER NAME: tvm.demo_android

Building container (tvm.demo_android)...
Sending build context to Docker daemon  68.61kB
Step 1/21 : FROM ubuntu:16.04

some have omitted...
-- Build files have been written to: /usr/tvm/build
Scanning dependencies of target sgx_edl
Scanning dependencies of target vta
[  0%] Generating ../src/runtime/sgx/untrusted/tvm_u.h
make[2]: /opt/sgxsdk/bin/x64/sgx_edger8r: Command not found
make[2]: *** [../src/runtime/sgx/untrusted/tvm_u.h] Error 127
make[2]: *** Waiting for unfinished jobs....
CMakeFiles/sgx_edl.dir/build.make:61: recipe for target '../src/runtime/sgx/untrusted/tvm_u.h' failed
[  0%] Generating /opt/rust-sgx-sdk/sgx_ustdc/libsgx_ustdc.a
/bin/sh: 1: cd: can't cd to /opt/rust-sgx-sdk/sgx_ustdc
make[2]: *** [/opt/rust-sgx-sdk/sgx_ustdc/libsgx_ustdc.a] Error 2
CMakeFiles/sgx_edl.dir/build.make:67: recipe for target '/opt/rust-sgx-sdk/sgx_ustdc/libsgx_ustdc.a' failed
CMakeFiles/Makefile2:448: recipe for target 'CMakeFiles/sgx_edl.dir/all' failed
make[1]: *** [CMakeFiles/sgx_edl.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[  1%] Building CXX object CMakeFiles/vta.dir/vta/src/sim/sim_driver.cc.o
[  1%] Building CXX object CMakeFiles/vta.dir/vta/src/runtime.cc.o
[  1%] Building CXX object CMakeFiles/vta.dir/vta/src/device_api.cc.o
[  2%] Linking CXX shared library libvta.so
[  2%] Built target vta
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
The command '/bin/sh -c bash /install/install_tvm_cpu.sh' returned a non-zero code: 2
ERROR: docker build failed.

3.So can you provide docker image for Android,I find TVM have provided some prebuilt images,but tvmai/demo-android is empty .So this command docker pull tvmai/demo-android is also failed.

So can somebody give me some help informations @grwlf @eqy @walterh


System:
             ubuntu 18.04
             Gradle 5.0
             LLVM 6.x
             gcc and g++ 6.x
             Apache Maven 3.5.2
             Docker version 18.09.0
             ~Android/Sdk:NDK16.1

others: I can Install from Source and run tutorials nnvm-quick-start-py and get-started-py successfully.