0.前提条件
已安装好Anaconda和Python3.10
1.ONNX下载安装
ONNX官方链接:
https://github.com/onnx/onnx#installation
根据官方指导,使用Conda进行安装:
conda install -c conda-forge onnx
2.SNPE下载
下载地址为:
https://www.qualcomm.com/developer/software/neural-processing-sdk-for-ai
点击Get Software 直接下载
然后复制到ubuntu系统中并解压
3.安装SNPE相关依赖
进到刚才下载解压的snpe文件夹bin目录下:
cd v2.22.6.240515/qairt/2.22.6.240515/bin
安装linux依赖:
source check-linux-dependency.sh
成功后会提示:
=============================================================
All Dependency Packages Found
Done!!
安装python依赖:
python check-python-dependency
注:这里有些库可能在国内无法下载,修改check-python-dependency文件使用清华源即可:
vim check-python-dependency
将如下代码:
subprocess.check_call(
[
sys.executable,
'-m',
"pip",
"install",
toBeInstalledPackage
+ "=="
+ toBeInstalledPackages[toBeInstalledPackage],
],
增加一行改为:
subprocess.check_call(
[
sys.executable,
'-m',
"pip",
"install",
toBeInstalledPackage
+ "=="
+ toBeInstalledPackages[toBeInstalledPackage],
"-i https://pypi.tuna.tsinghua.edu.cn/simple",
],
所有python依赖都安装完成后提示:
Summary:
Package Recommended Installed
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ ~~~~~~~~~~~
absl-py 2.1.0 2.1.0
attrs 23.2.0 23.1.0
dash 2.12.1 2.17.1
decorator 4.4.2 5.1.1
invoke 1.7.3 2.2.0
joblib 1.4.0 1.2.0
jsonschema 4.19.0 4.19.2
lxml 5.2.1 4.9.3
mako 1.1.0 1.3.5
matplotlib 3.3.4 3.8.0
mock 3.0.5 5.1.0
numpy 1.26.4 1.26.4
opencv-python 4.5.4.58 4.9.0.80
optuna 3.3.0 3.6.1
packaging 24.0 23.1
pandas 2.0.1 2.1.4
paramiko 3.4.0 3.4.1
pathlib2 2.3.6 2.3.7.post1
pillow 10.2.0 10.2.0
plotly 5.20.0 5.9.0
protobuf 3.19.6 3.20.3
psutil 5.6.4 5.9.0
pytest 8.1.1 7.4.0
pyyaml 5.3 6.0.1
scikit-optimize 0.9.0 0.10.2
scipy 1.10.1 1.11.4
six 1.16.0 1.16.0
tabulate 0.9.0 0.9.0
typing-extensions 4.10.0 4.9.0
xlsxwriter 1.2.2 3.2.0
4.设置环境变量
执行指令:
source envsetup.sh
5.将ONNX模型转为DLC
执行指令
snpe-onnx-to-dlc -i xxx.onnx
其中xxx.onnx为onnx文件所在位置
成功完成后会提示:
2024-08-13 09:39:46,382 - 235 - INFO - INFO_INITIALIZATION_SUCCESS:
注:
这里可能会遇到问题
/home/gy/v2.22.6.240515/qairt/2.22.6.240515/bin/x86_64-linux-clang/snpe-onnx-to-dlc: Permission denied
进入x86_64-linux-clang路径下查看发现snpe-onnx-to-dlc缺少执行权限:
-rw-r–r-- 1 root root 2931 May 16 01:29 snpe-onnx-to-dlc
将所有snpe指令都加上执行权限就好啦:
cd x86_64-linux-clang
chmod a+x snpe*