【CANN训练营第三季】CANN6.0环境MMDeploy搭建笔记

举报
JeffDing 发表于 2022/11/17 19:35:46 2022/11/17
【摘要】 CANN6.0环境MMDeploy搭建笔记

一、环境配置

华为云环境配置:

  • OS: ubuntu18.04
  • ARCH: aarch64
  • Ascend toolkit: 6.0.0.alpha001
  • Python虚拟环境:MiniAnaconda
  • CMAKE版本:3.24

二、环境安装

安装pip3

sudo apt install python3-pip

CANN 6.0安装
下载网站:https://www.hiascend.com/zh/software/cann/community
下载命令:

wget https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/6.0.0.alpha001/Ascend-cann-toolkit_6.0.0.alpha001_linux-aarch64.run

添加可执行权限

chmod a+x Ascend-cann-toolkit_6.0.0.alpha001_linux-aarch64.run

执行安装

sudo ./Ascend-cann-toolkit_6.0.0.alpha001_linux-aarch64.run --full

添加环境变量

vim ~/.bahrc

添加如下内容

export PATH=/usr/local/Ascend/ascend-toolkit/latest/bin:/usr/local/Ascend/ascend-toolkit/latest/compiler/ccec_compiler/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/Ascend/ascend-toolkit/latest/lib64:/usr/local/Ascend/ascend-toolkit/latest/lib64/plugin/opskernel:/usr/local/Ascend/ascend-toolkit/latest/lib64/plugin/nnengine:$LD_LIBRARY_PATH
export PYTHONPATH=/usr/local/Ascend/ascend-toolkit/latest/python/site-packages:/usr/local/Ascend/ascend-toolkit/latest/opp/op_impl/built-in/ai_core/tbe:$PYTHONPATH
export ASCEND_AICPU_PATH=/usr/local/Ascend/ascend-toolkit/latest
export ASCEND_OPP_PATH=/usr/local/Ascend/ascend-toolkit/latest/opp
export TOOLCHAIN_HOME=/usr/local/Ascend/ascend-toolkit/latest/toolkit
export ASCEND_HOME_PATH=/usr/local/Ascend/ascend-toolkit/latest

更新环境变量

source ~/.bashrc

安装Ascend固件及驱动
这一步非必须,如果遇到模型转换报错acl.rt.set_device,57033错误的话需要更新一下固件及驱动
下载地址:https://www.hiascend.com/hardware/firmware-drivers?tag=community
下载安装命令脚本

wget 'https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/turing/resourcecenter/Software/AtlasI/Ascend%20HDK%2022.0.RC2/A300-3000-npu-driver_5.1.rc2_linux-aarch64.run?response-content-type=application/octet-stream' --no-check-certificate
mv A300-3000-npu-driver_5.1.rc2_linux-aarch64.run\?response-content-type\=application%2Foctet-stream A300-3000-npu-driver_5.1.rc2_linux-aarch64.run
./A300-3000-npu-driver_5.1.rc2_linux-aarch64.run --full

安装cmake
camke下载地址:https://cmake.org/download/
安装步骤:

wget https://github.com/Kitware/CMake/releases/download/v3.24.3/cmake-3.24.3.tar.gz
tar -xvf cmake-3.24.3.tar.gz
cd cmake
./configure
make
sudo make install

三、模型依赖环境安装

安装miniconda

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh
bash Miniconda3-latest-Linux-aarch64.sh
export PATH=$HOME/miniconda3/bin:$PATH

创建虚拟环境

conda create --name mmlab python=3.8 -y
conda activate mmlab

安装python

pip install torch==1.8.1 torchvision==0.9.1 --extra-index-url https://download.pytorch.org/whl/cpu

安装MMCV

pip install openmim
pip install mmcv-full

模型推理依赖环境

sudo apt-get update
sudo apt-get install libopencv-dev

mmdeploy依赖安装

git clone --recursive https://github.com/open-mmlab/mmdeploy.git
cd mmdeploy

安装mmdeploy模型转换器

pip install -v -e .

编译 mmdeploy 推理SDK

#设置 ascend-toolkit环境变量
source /usr/local/Ascend/ascend-toolkit/set_env.sh
mkdir -p build && cd build
cmake .. -DMMDEPLOY_BUILD_SDK=ON -DMMDEPLOY_BUILD_SDK_PYTHON_API=ON -DMMDEPLOY_TARGET_BACKENDS=acl
make -j$(nproc) && make install
cd ..

验证

#检查mmdeploy模型转换器是否安装成功
python tools/check_env.py
#检查mmdeploy推理SDK是否编译安装成功
export PYTHONPATH=$(pwd)/build/lib:$PYTHONPATH
python -c "import mmdeploy_python"

注意:如果遇到报onnx报找不到执行

pip install onnx
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。