Why do we need to build TVM runtime on remote device for Auto TVM?


#1

Can I build the TVM runtime locally and then put it inside the target device? I am going to use iMX 6 DL and it has a total of only 32 MB flash.


#2

Yes, you can cross-compile it.


#3

you can compile tvm runtime on any armv7 device. e.g. on RaspberryPi and then copy whl, egg or install tvm runtime to folder , zip the folder and copy zip file to iMX 6 DL.


#4

@apivovarov iMX 6 DL has arm cortex A9 v7 and none of the Rasberry Pi available product has arm cortex A9. If I generate the Auto TVM log file from any arm v7 then will it work on iMX 6 DL as well?


#5

The run time should work on a Cortex-A9 as long as you are using the same ABI on the Raspberry pi and the imx6 . Further you should be using command line options that are compatible with the Cortex-A9. -march=armv7-a , -mfpu=neon , -mfloat-abi=hard .

regards
Ramana


#6

What OS does it have? Linux / Android ?
Do you ssh <ip> or adb shell in order to get to the device shell?

Can you run the following commands on the device and give us the output?

uname -a

cat /etc/issue

getprop sys.kernel.version                                     
getprop ro.build.version.release
getprop ro.build.version.name
getprop ro.product.cpu.abi
getprop ro.product.cpu.abilist32
getprop ro.product.cpu.abilist64
getprop ro.product.cpu.abilist

cat /proc/cpuinfo

#7

I have a stripped down version of Linux running on iMX 6 DL.
I use ssh to connect to my board.

uname -a: Linux #### 3.0.35-#### #1 SMP PREEMPT Fri Nov 10 10:15:08 CET 2017 armv7l GNU/Linux

cat /proc/cpuinfo:

                       Processor       : ARMv7 Processor rev 10 (v7l)
                       processor       : 0
                       BogoMIPS        : 1581.05

                       processor       : 1
                       BogoMIPS        : 1581.05

                       Features        : swp half thumb fastmult vfp edsp thumbee neon vfpv3
                       CPU implementer : 0x41
                       CPU architecture: 7
                       CPU variant     : 0x2
                       CPU part        : 0xc09
                       CPU revision    : 10

                       Hardware        : Freescale i.MX 6Quad/DualLite/Solo Sabre Auto Board
                       Revision        : 61112
                       Serial          : 0000000000000000

I don’t have the /etc/issue folder so I couldn’t provide the output of cat /etc/issue.


#8

We also need to check glibc version available on the device

Can you compile the following C program glibc_version.c
copy executable (glibc_version) to the device and run it ./glibc_version

# Use gcc cross compiler on Ubuntu to compile the program for Armv7
# sudo apt-get install gcc-arm-linux-gnueabihf
arm-linux-gnueabihf-gcc glibc_version.c -o glibc_version

glibc_version.c

#include <stdio.h>
#include <stdlib.h>
#include <gnu/libc-version.h>

int main() {
  printf("glibc version: %s\n", gnu_get_libc_version());
  return 0;
}

#9

glibc_version cross compiled with arm-linux-gnueabihf-gcc is not working on my board and when I cross compiled it with arm-linux-gnueabi-gcc it gave the output as:

glibc version: 2.20


#10

Can you double check that your device has /lib/arm-linux-gnueabi folder without hf?

As for glibc version - you can use Ubuntu 14.04 or Debian 8 (Jessie) OS to cross-compile TVM runtime for your device - both has glibc 2.19


#11

To cross-compile TVM runtime for arm-linux-gnueabi

cd tvm
mkdir build
cd build
cp ../cmake/config.cmake .

cmake \
-DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_SYSTEM_VERSION=1 \
-DCMAKE_C_COMPILER=/usr/bin/arm-linux-gnueabi-gcc \
-DCMAKE_CXX_COMPILER=/usr/bin/arm-linux-gnueabi-g++ \
-DCMAKE_FIND_ROOT_PATH=/usr/arm-linux-gnueabi \
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
..

make -j1 VERBOSE=1 runtime

One issue here - tvm code compilation requires gcc version 5.4 or higher.
Ubuntu 14.04 or Debian 8 (Jessie) OS has gcc version 4.x

Try to compile TVM runtime on Ubuntu 16. Maybe the device will not complain about libtvm_runtime.so glibc version.

to Test TVM

copy tvm folder to the device to /opt
export LD_LIBRARY_PATH=/opt/tvm/build
export PYTHONPATH=/opt/tvm/python

python3

import tvm
from tvm.contrib import graph_runtime
...