昇腾CANN训练营第一期应用营 详细步骤
1购买弹性云服务器
按需计费、AI加速型ai1s.large.4规格的CPU、镜像选择Ubuntu默认设置
点击下一步,网络选择默认信息,购买弹性公网,选择按流量计费,宽带大小选择100(选择1和100的价格一样)
点击下一步,设置密码
下一步,点击购买
2.https://ascend.huawei.com/#/hardware/firmware-drivers?tag=community 晟腾社区硬件平台下载相应的驱动
https://ascend.huawei.com/#/software/cann/community 软件平台下载nnrt和toolkit
https://ascend.huawei.com/#/software/mindstudio/download 下载mindstudio
3.登录弹性云服务器
输入用户名密码
登录成功!
修改HwHiAiUser用户密码
修改HwHiAiUser的shell方式
vim /etc/passwd
4.用mobaXterm远程登录服务器
点击OK,输入密码,登录成功!
创建一个新的目录downloads用于存放第二步下载的依赖
mkdir downloads
将第二步下载的依赖通过SSH工具复制到该目录下,也可以用wget下载对应的依赖。我用的wget下载
wget https://repo.huaweicloud.com/ascend/autoarchive/CANN/3.3.0.alpha001/Ascend-cann-toolkit_3.3.0.alpha001_linux-x86_64.run --no-check-certificate wget https://repo.huaweicloud.com/ascend/autoarchive/CANN/3.3.0.alpha001/Ascend-cann-nnrt_3.3.0.alpha001_linux-x86_64.run --no-check-certificate wget https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/turing/resourcecenter/Software/20.2.0/A300-3010%201.0.9/A300-3010-npu-driver_20.2.0_ubuntu18.04-x86_64.run --no-check-certificate wget https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/turing/resource/mindstudio/2.0.0-beta3/MindStudio_2.0.0-beta3_linux.tar.gz --no-check-certificate
|
|
|
5.修改apt工具的源
修改之前,先将源来的数据备份一下
cp sources.list sources.list.bak
> sources.list 清空数据
再将一下代码复制进去
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
:wq保存退出
apt-get update 更新下源索引
6.安装依赖
参考了下几位大佬的帖子,发现这一步有一个巨坑,这一步需要先安装python3.7.
apt-get install python3.7
等安装完成后,再执行下面的命令
sudo apt-get install -y gcc g++ make cmake zlib1g zlib1g-dev libbz2-dev libsqlite3-dev libssl-dev libxslt1-dev libffi-dev unzip pciutils net-tools libncursesw5-dev
7.安装python相关的源
先退出到HwHiAiUser目录下
pwd
mkdir .pip 创建隐藏的pip文件
cd .pip
vi pip.conf
将一下代码粘贴进去,保存
[global]
index-url = https://mirrors.huaweicloud.com/repository/pypi/simple
trusted-host = mirrors.huaweicloud.com
timeout = 120
添加环境变量
vim .bashrc
将下面代码粘贴在最后
export LD_LIBRARY_PATH=/usr/local/python3.7.5/lib:$LD_LIBRARY_PATH
export PATH=/usr/local/python3.7.5/bin:$PATH
保存退出后,用下面命令使环境生效
source .bashr
安装pip依赖
pip3.7.5 install attrs numpy decorator sympy==1.4 cffi==1.12.3 pyyaml pathlib2 psutil protobuf scipy requests xlrd==1.2.0 --user
8.安装软件包
cd downloads
chmod +x A*
su 切换目录
执行
./A300-3010-npu-driver_20.2.0_ubuntu18.04-x86_64.run --full
重启
reboot
重启之后,重新连接一下
cd downloads/ 进入目录 继续安装
./Ascend-cann-nnrt_3.3.0.alpha001_linux-x86_64.run --install
vim ~/.bashrc 添加环境变量
export PYTHONPATH=/home/HwHiAiUser/Ascend/nnrt/latest/pyACL/python/site-packages/acl:${PYTHONPATHG}
export ASCEND_AICPU_PATH=/home/HwHiAiUser/Ascend/nnrt/latest:${ASCEND_AICPU_PATH}
保存完,执行下面命令,使环境生效
source ~/.bashrc
# 安装 toolkit
./Ascend-cann-toolkit_3.3.0.alpha001_linux-x86_64.run --install
安装完成后,会提示一下配置环境变量
离线推理应用环境变量
Offline infer develop (cannot coexist with other scenes):
PATH includes :
/home/HwHiAiUser/Ascend/ascend-toolkit/latest/toolkit/bin:
LD_LIBRARY_PATH includes :
/home/HwHiAiUser/Ascend/ascend-toolkit/latest/acllib/lib64:
PYTHONPATH includes :
/home/HwHiAiUser/Ascend/ascend-toolkit/latest/pyACL/python/site-packages/acl:
/home/HwHiAiUser/Ascend/ascend-toolkit/latest/toolkit/python/site-packages:
ASCEND_AICPU_PATH includes :
/home/HwHiAiUser/Ascend/ascend-toolkit/latest:
ASCEND_OPP_PATH includes :
/home/HwHiAiUser/Ascend/ascend-toolkit/latest/opp:
TOOLCHAIN_HOME includes :
/home/HwHiAiUser/Ascend/ascend-toolkit/latest/toolkit:
在线推理应用环境变量
Third party AI framework develop (cannot coexist with other scenes):
PATH includes :
/home/HwHiAiUser/Ascend/ascend-toolkit/latest/fwkacllib/ccec_compiler/bin:
/home/HwHiAiUser/Ascend/ascend-toolkit/latest/fwkacllib/bin:
/home/HwHiAiUser/Ascend/ascend-toolkit/latest/toolkit/bin:
LD_LIBRARY_PATH includes :
/home/HwHiAiUser/Ascend/ascend-toolkit/latest/fwkacllib/lib64:
PYTHONPATH includes :
/home/HwHiAiUser/Ascend/ascend-toolkit/latest/fwkacllib/python/site-packages:
/home/HwHiAiUser/Ascend/ascend-toolkit/latest/toolkit/python/site-packages:
ASCEND_OPP_PATH includes :
/home/HwHiAiUser/Ascend/ascend-toolkit/latest/opp:
ASCEND_AICPU_PATH includes :
/home/HwHiAiUser/Ascend/ascend-toolkit/latest:
TOOLCHAIN_HOME includes :
/home/HwHiAiUser/Ascend/ascend-toolkit/latest/toolkit:
模型转换应用环境变量
Model transformation and operator develop (cannot coexist with other scenes):
PATH includes :
/home/HwHiAiUser/Ascend/ascend-toolkit/latest/atc/ccec_compiler/bin:
/home/HwHiAiUser/Ascend/ascend-toolkit/latest/atc/bin:
/home/HwHiAiUser/Ascend/ascend-toolkit/latest/toolkit/bin:
LD_LIBRARY_PATH includes :
/home/HwHiAiUser/Ascend/ascend-toolkit/latest/atc/lib64:
PYTHONPATH includes :
/home/HwHiAiUser/Ascend/ascend-toolkit/latest/atc/python/site-packages:
/home/HwHiAiUser/Ascend/ascend-toolkit/latest/toolkit/python/site-packages:
ASCEND_OPP_PATH includes :
/home/HwHiAiUser/Ascend/ascend-toolkit/latest/opp:
TOOLCHAIN_HOME includes :
/home/HwHiAiUser/Ascend/ascend-toolkit/latest/toolkit:
解压MindStudio
tar zxvf MindStudio_2.0.0-beta3_linux.tar.gz
进入MindStudio下,启动,发现报错。根据红字提醒,开搞~~
su 切换
apt-get -y install xterm firefox xdg-utils openjdk-8-jdk fonts-droid-fallback fonts-wqy-zenhei fonts-wqy-microhei fonts-arphic-ukai fonts-arphic-uming gnome-keyring
安装python依赖,注意切换用户
/usr/local/python3.7.5/bin/pip3 install --user coverage gnureadline pylint matplotlib pandas absl-py
安装完后,重新启动
9.启动mindstudio后,选择自带的一个demo
选择后,按finish,进入下面的界面,选择新建工程
根据readme.md文件提示的信息,下载对应的项目
找到下载地址
预训练模型下载地址:
https://obs-model-ascend.obs.cn-east-2.myhuaweicloud.com/resnet50/resnet50.caffemodel
原始模型网络链接地址:
https://github.com/KaimingHe/deep-residual-networks/blob/master/prototxt/ResNet-50-deploy.prototxt
在mindstudio启动终端 ,使用一下命令下载
wget https://gitee.com/HuaweiAscend/models/raw/master/computer_vision/classification/resnet50/resnet50.prototxt
wget https://obs-model-ascend.obs.cn-east-2.myhuaweicloud.com/resnet50/resnet50.caffemodel
然后进行模型转换
一路next,知道finish
然后,输出栏就开始输出转换信息
看到这个信息后,代表转换完成!
下载推理用的数据
切换到data目录下,用下面的命令下载
wget https://c7xcode.obs.cn-north-4.myhuaweicloud.com/models/aclsample/dog1_1024_683.jpg
wget https://c7xcode.obs.cn-north-4.myhuaweicloud.com/models/aclsample/dog2_1024_683.jpg
下载完成后,可以看到图像信息
将转换好的myapp添加到模型
点击OK.此时,myapp工程会出现model目录
回到终端,输入 python3.7.5 ../script/transferPic.py 对图片进行预处理
处理完之后,我们才能进行推理。
编译运行
编译完成
最后运行
选择刚编译好的main,点击Ok
点击菜单栏的run,开始运行
卧槽,报错了
尴尬了~~
又折腾了下,重新配置了python环境,好了
删除资源
还是要仔细呀。修改完配置变量,可能没有用source命令。血的教训。
评论(0)