How to build TVM with VTA simulator - torontotong/tvm GitHub Wiki

Development Environment Setup

Host Computer

Ubuntu Linux 18.4 is recommended

Tools For Building TVM

  1. GNU Compiler – A c++ compiler supporting C++ 14 (g++-5 or higher)
  2. CMake – Ver 3.5 or higher
  3. Python 3.6 or higher
  4. LLVM – highly recommended to enable all features

Tools For VTA Simulator and Chisel

  1. sbt
  2. verilator

Install Development Tools – g++ and Python

  1. sudo apt update
  2. sudo apt-get install -y python3 python3-dev python3-setuptools gcc libtinfo-dev zlib1g-dev build-essential cmake libedit-dev libxml2-dev

Install Cmake Tool

  • sudo apt install cmake

Install LLVM

  1. wget https://apt.llvm.org/llvm.sh
  2. chmod +x llvm.sh
  3. sudo ./llvm.sh 12

Install Tools For VTA simulator and Chisel

  1. Add ‘sbt’ to package manager Of Ubuntu 18.4
  2. echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | sudo tee /etc/apt/sources.list.d/sbt.list
  3. echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | sudo tee /etc/apt/sources.list.d/sbt_old.list
  4. curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search= 0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | sudo apt-key add
  5. sudo apt-get update
  6. sudo apt-get install sbt
  7. sudo apt install verilator

Pull Source Code From GitHub

Run below command to pull tcm source code to your host PC:

How To Build TVM

Below are TVM building process

  1. cd “tvm_root” folder
  2. mkdir build
  3. cp cmake/config.camke build/
  4. echo 'set(USE_VTA_TSIM ON)' >> build/config.cmake
  5. echo 'set(USE_VTA_FSIM ON)' >> build/config.cmake
  6. echo 'set(USE_LLVM llvm-config-12)' >> build/config.cmake
  7. cd build
  8. cmake ..
  9. Make –jn (at here,n is CPU core/thread number)
  10. sudo make install

Build VTA Simulator

Build TVM Simulator TSIM

  1. Modify /Root of tvm/3rdparty/vta-hw/apps/tsim_example/CMakeLists.txt file.
  2. Change below configuration from -std=c++11 to -std=c++14 at line 34.
  • set(CMAKE_CXX_FLAGS "-O2 -Wall –fPIC -fvisibility=hidden -std=c++14")

Make TVM TSIM examples

  • Go to tvm_root/3rdparty/vta-hw/apps/tsim_example, run below commands
  1. export TVM_PATH=“path_to_tvm”
  2. export VTA_HW_PATH=$TVM_PATH/3rdparty/vta-hw
  3. cp $VTA_HW_PATH/config/tsim_sample.json $VTA_HW_PATH/config/vta_config.josn
  4. If use Verilog backend
  • run command "make"
  1. If use Chisek3 Backend
  • run command "make run_chisel"

Run TVM with VTA Simulator Demo

  1. export TVM_PATH=/path to tvm
  2. export PYTHONPATH=$TVM_PATH/python:$PYTHONPATH: =$TVM_PATH/vta/python
  3. export LDLIBRARYPATH=/usr/local/lib
  4. python tvm_root/vta/tests/python/integration/test_benchmark_topi_conv2d.py