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
- GNU Compiler – A c++ compiler supporting C++ 14 (g++-5 or higher)
- CMake – Ver 3.5 or higher
- Python 3.6 or higher
- LLVM – highly recommended to enable all features
Tools For VTA Simulator and Chisel
- sbt
- verilator
Install Development Tools – g++ and Python
- sudo apt update
- 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
- wget https://apt.llvm.org/llvm.sh
- chmod +x llvm.sh
- sudo ./llvm.sh 12
Install Tools For VTA simulator and Chisel
- Add ‘sbt’ to package manager Of Ubuntu 18.4
- echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | sudo tee /etc/apt/sources.list.d/sbt.list
- echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | sudo tee /etc/apt/sources.list.d/sbt_old.list
- curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search= 0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | sudo apt-key add
- sudo apt-get update
- sudo apt-get install sbt
- sudo apt install verilator
Pull Source Code From GitHub
Run below command to pull tcm source code to your host PC:
- git clone --recursive https://github.com/apache/tvm tvm
How To Build TVM
Below are TVM building process
- cd “tvm_root” folder
- mkdir build
- cp cmake/config.camke build/
- echo 'set(USE_VTA_TSIM ON)' >> build/config.cmake
- echo 'set(USE_VTA_FSIM ON)' >> build/config.cmake
- echo 'set(USE_LLVM llvm-config-12)' >> build/config.cmake
- cd build
- cmake ..
- Make –jn (at here,n is CPU core/thread number)
- sudo make install
Build VTA Simulator
Build TVM Simulator TSIM
- Modify /Root of tvm/3rdparty/vta-hw/apps/tsim_example/CMakeLists.txt file.
- 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
- export TVM_PATH=“path_to_tvm”
- export VTA_HW_PATH=$TVM_PATH/3rdparty/vta-hw
- cp $VTA_HW_PATH/config/tsim_sample.json $VTA_HW_PATH/config/vta_config.josn
- If use Verilog backend
- run command "make"
- If use Chisek3 Backend
- run command "make run_chisel"
Run TVM with VTA Simulator Demo
- export TVM_PATH=/path to tvm
- export PYTHONPATH=$TVM_PATH/python:$PYTHONPATH: =$TVM_PATH/vta/python
- export LDLIBRARYPATH=/usr/local/lib
- python tvm_root/vta/tests/python/integration/test_benchmark_topi_conv2d.py