1、下載源碼
git clone --recursive https://github.com/apache/tvm tvm
cd tvm
git submodule init
git submodule update
2匹涮、下載依賴
sudo apt-get update
sudo apt-get install -y python3 python3-dev python3-setuptools gcc libtinfo-dev zlib1g-dev build-essential cmake libedit-dev libxml2-dev
mkdir build
cp cmake/config.cmake build
3肮柜、安裝llvm
去[llvm官網(wǎng)](LLVM Download Page)下載適合自己系統(tǒng)的壓縮包,下面以ubuntu20.04為例
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz
tar xJvf clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz
編輯~/.bashrc
,加入以下內(nèi)容
export PATH=$PATH:/path/to/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin
source ~/.bashrc
#使用下面命令測試llvm是否安裝成功
llvm-config --version
4煮纵、自定義編譯選項
cd tvm
vi build/config.cmake
將其中一行set(USE_LLVM OFF)
改為set(USE_LLVM ON)
如果要加入VTA,將其中一行set(USE_VTA_FSIM OFF)
改為set(USE_VTA_FSIM ON)
5偏螺、編譯TVM
cd build
cmake ..
make -j4
6行疏、增加python支持
在~/.bashrc
中加入以下幾行
export TVM_HOME=/path/to/tvm
export PYTHONPATH=$TVM_HOME/python:$TVM_HOME/topi/python:$TVM_HOME/nnvm/python:$TVM_HOME/vta/python:${PYTHONPATH}
#如果要加入VTA支持,下面一行要加入
export VTA_HW_PATH=$TVM_HOME/3rdparty/vta-hw
保存~/.bashrc
后套像,執(zhí)行source ~/.bashrc
7酿联、安裝python相關(guān)依賴
pip3 install numpy decorator attrs
pip3 install tornado
pip3 install tornado psutil xgboost
pip3 install mypy orderedset antlr4-python3-runtime