【环境搭建】mnn

1,介绍
    MNN是一个轻量级的深度神经网络推理引擎,在端侧加载深度神经网络模型进行推理预测。

2,安装
2.1 编译mnn

git clone https://github.com/alibaba/MNN.git
cd MNN
 ./schema/generate.sh
mkdir build
cd build
cmake .. \
	-DMNN_BUILD_CONVERTER=true \
	-DMNN_VULKAN=true \ # vulkan 2-4
	-DMNN_USE_SYSTEM_LIB=true \ 
	-DMNN_SEP_BUILD=false \
	-DMNN_BUILD_QUANTOOLS=on # quantization
make -j 4

2.2 protobuf>3.0

2.3 VULKAN

# https://vulkan.lunarg.com/sdk/home,下载,vulkansdk-linux-x86_64-1.2.141.0.tar.gz
tar -xf vulkansdk-linux-x86_64-1.2.141.0.tar.gz
sudo apt install vulkan-utils

# setup vulkan env
export VULKAN_SDK=$HOME/vulkansdk-linux-x86_64-1.2.141.0/x86_64
export PATH=$VULKAN_SDK/bin:$PATH
export LD_LIBRARY_PATH=$VULKAN_SDK/lib:$LD_LIBRARY_PATH
export LIBRARY_PATH=$VULKAN_SDK/lib:$LIBRARY_PATH
export VK_LAYER_PATH=$VULKAN_SDK/etc/vulkan/explicit_layer.d

3,模型转换
3.1 onnx->mnn

./MNNConvert -version
0.2.1.5git

./MNNConvert -f ONNX \
	--modelFile mnist.onnx \
	--MNNModel mnist.mnn \
	--bizCode biz

3.2 量化转换

./quantized.out origin.mnn quan.mnn pretreatConfig.json

pretreatConfig.json

4,mnn -> android


你可能感兴趣的:(环境搭建)