文章目录
1 从源码编译
git clone -b main https://github.com/open-mmlab/mmdeploy.git --recursive
cd mmdeploy
1.1 安装onnxruntime后端
python 的onnx后端安装.
pip install onnxruntime==1.8.1
注: 在另外的机器上python3.11.5版本的环境下没有onnxruntime==1.8.1,安装了onnxruntime1.15.1,可以正常转换模型。
c++ 的onnx库,在你喜欢的目录下下载解压,设置环境变量即可。
wget https://github.com/microsoft/onnxruntime/releases/download/v1.8.1/onnxruntime-linux-x64-1.8.1.tgz
tar -zxvf onnxruntime-linux-x64-1.8.1.tgz
export ONNXRUNTIME_DIR=$(pwd)/onnxruntime-linux-x64-1.8.1
export LD_LIBRARY_PATH=$ONNXRUNTIME_DIR/lib:$LD_LIBRARY_PATH
可以用下面的方式把环境变量设为永久
echo '# set env for onnxruntime' >> ~/.bashrc
echo "export ONNXRUNTIME_DIR=${ONNXRUNTIME_DIR}" >> ~/.bashrc
echo "export LD_LIBRARY_PATH=$ONNXRUNTIME_DIR/lib:$LD_LIBRARY_PATH" >> ~/.bashrc
source ~/.bashrc
1.2 build mmdeploy
cd /the/root/path/of/MMDeploy
export MMDEPLOY_DIR=$(pwd)
mkdir -p build && cd build
cmake -DCMAKE_CXX_COMPILER=g++ -DMMDEPLOY_TARGET_BACKENDS=ort -DONNXRUNTIME_DIR=${ONNXRUNTIME_DIR} ..
make -j$(nproc) && make install