ubuntu20.04 tvm 安装教程:
参考:
步骤:
-
创建容器:docker run -itd --name tvm --gpus=all --ipc=host -p 20322:22 -v /mnt/iro/tt:/home/tt ubuntu:20.04 /bin/bash -c "while true; do echo \'Hello\'; sleep 1000; done"
-
apt update
apt-get install -y python3 python3-dev python3-setuptools gcc libtinfo-dev zlib1g-dev build-essential libedit-dev libxml2-dev
- 安装cmake:
wget https://github.com/Kitware/CMake/releases/download/v3.28.3/cmake-3.28.3.tar.gz
tar -zxvf cmake-3.28.3.tar.gz
apt-get install libssl-dev
./bootstrap
make
make install
ln -s /home/tt/tools/cmake-3.28.3/bin/* /usr/bin/
cmake -version
- apt install libncurses5
tar -xvf clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz
mv clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04 llvm13
vim /etc/profile
最后添加两行:
export LLVM_HOME=/home/tt/tools/llvm13/bin
export PATH=LLVM_HOME:PATH
source /etc/profile
llvm-as --version
set(USE_LLVM OFF)
改为:
set(USE_LLVM ON) 或者 SET(USE_LLVM /home/tt/tools/llvm13/bin/llvm-config)
set(USE_CUDA OFF)
改为:
set(USE_CUDA ON) 或者 SET(USE_CUDA /cuda的路径)
set(USE_CUDNN OFF) 改为:set(USE_CUDNN ON)
set(USE_GRAPH_EXECUTOR OFF) 改为:set(USE_GRAPH_EXECUTOR ON)
set(USE_PROFILER OFF) 改为:set(USE_PROFILER ON)
cd build
cmake ..
make -j24
vim ~/.bashrc
文件末尾添加这几行
export TVM_HOME=/home/tt/project/tvm
export PYTHONPATH=TVM_HOME/python:TVM_HOME/python/tvm:TVM_HOME/build:TVM_HOME/python/tvm/runtime:$[PYTHONPATH]
注意:
-
官方导出TVM_LOG_DEBUG有bug,import tvm时会报错,修改为:
export TVM_LOG_DEBUG="ir/transform.cc=1,relay/ir/transform.cc=1" -
ubuntu20.04的话,注意用13.0.0的llvm,不然会core dump!!!!!