参考:http://tvm.apache.org/docs/install/from_source.html
1.下载代码
git clone --recursive https://github.com/apache/tvm tvm
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
#The minimal building requirements are
#A recent c++ compiler supporting C++ 14 (g++-5 or higher)
#CMake 3.5 or higher
#We highly recommend to build with LLVM to enable all the features.
配置编译选项
mkdir build
cp cmake/config.cmake build
#Edit build/config.cmake to customize the compilation options
#Change set(USE_CUDA OFF) to set(USE_CUDA ON) to enable CUDA backend. Do the same for other backends and libraries you want to build for (OpenCL, RCOM, METAL, VULKAN, …).
#To help with debugging, ensure the embedded graph runtime and debugging functions are enabled with set(USE_GRAPH_RUNTIME ON) and set(USE_GRAPH_RUNTIME_DEBUG ON)
#TVM requires LLVM for for CPU codegen. We highly recommend you to build with the LLVM support on.
#LLVM 4.0 or higher is needed for build with LLVM. Note that version of LLVM from default apt may lower than 4.0.
#Since LLVM takes long time to build from source, you can download pre-built version of LLVM from LLVM Download Page.
#Unzip to a certain location, modify build/config.cmake to add set(USE_LLVM /path/to/your/llvm/bin/llvm-config)
#You can also directly set set(USE_LLVM ON) and let cmake search for a usable version of LLVM.
#You can also use LLVM Nightly Ubuntu Build
#Note that apt-package append llvm-config with version number. For example, set set(USE_LLVM llvm-config-10) if you installed LLVM 10 package
编译TVM
cd build
cmake -DCMAKE_BUILD_TYPE=Debug .. (Debug模式,编译时会用-g -O0选项编译文件)
make -j4
3.Python包安装
export TVM_HOME=/path/to/tvm
export PYTHONPATH=$TVM_HOME/python:${PYTHONPATH}
4.Python依赖包
pip3 install --user numpy decorator attrs
pip3 install --user tornado psutil xgboost cloudpickle