环境要求:ubuntu18.04
参考文件:
《ATC工具使用指南》《应用开发指南》《驱动和开发环境安装指南》
《昇腾模型压缩工具使用指南(ONNX)》
交叉编译器的安装---------------------------------------------------------------------------------------------------
直接./aarch64-mix210-linux.install
vi /etc/profile
source /etc/profile使之生效
atc安装(非root)----------------------------------------------------------------------------------------------------
1:检查相关依赖
gcc --version
g++ --version
cmake --version
make --version
unzip --version
dpkg -l build-essential | grep build-essential | grep ii
dpkg -l zlib1g-dev| grep zlib1g-dev| grep ii
dpkg -l libbz2-dev| grep libbz2-dev| grep ii
dpkg -l libsqlite3-dev| grep libsqlite3-dev| grep ii
dpkg -l libssl-dev| grep libssl-dev| grep ii
dpkg -l libxslt1-dev| grep libxslt1-dev| grep ii
dpkg -l libffi-dev| grep libffi-dev| grep ii
如没有安装可以使用sudo apt-get install xxxx进行安装
2:安装python3.7.5
1)获取安装包--wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tgz
cd Python-3.7.5
./configure --prefix=/usr/local/python3.7.5 --enable-loadable-sqlite-extensions --enable-shared
make
sudo make install
sudo ln -s /usr/local/python3.7.5/bin/python3 /usr/local/python3.7.5/bin/python3.7.5
sudo ln -s /usr/local/python3.7.5/bin/pip3 /usr/local/python3.7.5/bin/pip3.7.5
vi ~/.bashrc
在最后加入
#用于设置 python3.7.5 库文件路径
export LD_LIBRARY_PATH=/usr/local/python3.7.5/lib:$LD_LIBRARY_PATH
#如果用户环境存在多个 python3 版本,则指定使用 python3.7.5 版本
export PATH=/usr/local/python3.7.5/bin:$PATH
source ~/.bashrc
python3.7.5 --version
pip3.7.5 install --upgrade(升级pip)
pip3.7.5 --version
3)安装相关的依赖
4:./Ascend-cann-toolkit_5.20.t6.2.b060_linux-x86_64.run --install
5:配置环境变量
source /home/warren/Ascend/ascend-toolkit/latest/x86_64-linux/bin/setenv.bash
:6:安装aarch64-mix210-linux
7:若需要卸载
bash /home/warren/Ascend/ascend-toolkit/latest/x86_64-linux/script/toolkit_uninstall.sh
atc使用:
1:首先设置环境变量
source /home/warren/Ascend/ascend-toolkit/latest/x86_64-linux/bin/setenv.bash
2:框架转换案例
atc --model=/home/warren/ss928/model_onnx/resnet101_v11.onnx \
--soc_version=OPTG --framework=5 \
--output=/home/warren/ss928/model_onnx/out \
--input_shape="input:-1,3,224,224" --dynamic_batch_size="1,2,4,8"
amct(主要用于量化)安装-----------------------------------------------------------------------
3)pip3 install amct_onnx-0.3.2-py3-none-linux_x86_64.whl
可以查看是否安装成功
4:cd amct_onnx_op/ && python3 setup.py build(请使用root权限)
至此完成
转换案例---------------------------------------------------------------------------------
1:获取sample--> samples: CANN Samples
2:文件结构如下,其中data里放矫正的图片
3:python3 ./src/resnet-101_calibration.py(请使用root)
至此量化完成。
应用开发测试----------------------------------------------------------------------------------------------------
PC端:
下载sample
https://gitee.com/ascend/samples/tree/master/cplusplus/level2_simple_inference/1_classification/resnet50_imagenet_classification
1:添加环境变量:
export DDK_PATH=$HOME/Ascend/ascend-toolkit/latest
export NPU_HOST_LIB=$DDK_PATH/runtime/lib64/stub
2:创建build目录
mkdir -p build/intermediates/host
3:cmake ../../../src -DCMAKE_CXX_COMPILER=aarch64-mix210-linux-g++ -DCMAKE_SKIP_RPATH=TRUE
板端---------------------------------------------------------------------------------------------------------------------------
设置环境变量
export LD_LIBRARY_PATH=/opt/sd/lib_svp
export ASCEND_AACPU_KERNEL_PATH=/opt/sd/lib_svp
直接运行./main
2:./main