草庐IT

华为云AI加速型(昇腾Ascend310)Ubuntu18.04系统下使用msame模型推理工具

Alderaan 2023-04-04 原文

文章目录

弹性云服务器ECS信息

  • 规格:AI加速型 | ai1s.large.4 | 2vCPUs | 8GiB
  • 镜像:Ubuntu 18.04 server 64bit for Ai1s | 公共镜像

默认分配的服务器,toolkit的版本为20.1.rc1,而msame模型推理工具的版本现在要求5.0.3.alpha001及以上版本。虽然官方也有提供5.0.3.alpha001前的版本,但我下载后编译会报错,所以还是升级一下CANN开发环境,同时更新硬件驱动。

更新Ascend310驱动

系统自带原驱动信息如下:

## 查询驱动信息
npu-smi info
## 返回如下结果
+------------------------------------------------------------------------------+
| npu-smi 20.1.0                       Version: 20.1.0                         |
+-------------------+-----------------+----------------------------------------+
| NPU     Name      | Health          | Power(W)          Temp(C)              |
| Chip    Device    | Bus-Id          | AICore(%)         Memory-Usage(MB)     |
+===================+=================+========================================+
| 0       310       | OK              | 12.8              45                   |
| 0       0         | 0000:00:0D.0    | 0                 2703 / 8192          |
+===================+=================+========================================+

在华为官网下载支持CANN 5.1.RC1.alpha001版本的驱动1.0.13.aplha
这里我下载的软件名称为:
A300-3010-npu_21.0.4_linux-x86_64.zip
可在服务器上执行如下命令进行下载并安装:

## 创建driver目录并进入driver目录
mkdir driver && cd driver
## 下载驱动安装包
wget --no-check-certificate https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/turing/resourcecenter/Software/AtlasI/A300-3010%201.0.13/A300-3010-npu_21.0.4_linux-x86_64.zip
## 解压安装包到指定目录A310
unzip -d A310 A300-3010-npu_21.0.4_linux-x86_64.zip
## 进入A310目录
cd A310
## 再次执行解压命令(官方下载的默认解压有一个同名ZIP,需要二次解压)
## 解压出来后还有一个是固件,但云服务器无法更新固件所以更新固件
unzip A300-3010-npu_21.0.4_linux-x86_64.zip
## 安装驱动
./npu-driver_21.0.4_linux-x86_64.run --full

安装过程会得到如下提示:

Verifying archive integrity...  100%   SHA256 checksums are OK. All good.
Uncompressing npu-driver-run-package  100%  
[Driver] [2022-03-04 13:23:04] [INFO]Start time: 2022-03-04 13:23:04
[Driver] [2022-03-04 13:23:04] [INFO]LogFile: /var/log/ascend_seclog/ascend_install.log
[Driver] [2022-03-04 13:23:04] [INFO]OperationLogFile: /var/log/ascend_seclog/operation.log
[Driver] [2022-03-04 13:23:04] [INFO]base version is 20.1.0.
[Driver] [2022-03-04 13:23:04] [WARNING]Do not power off or restart the system during the installation/upgrade
[Driver] [2022-03-04 13:23:04] [INFO]set username and usergroup, HwHiAiUser:HwHiAiUser
[Driver] [2022-03-04 13:23:04] [INFO]Driver package has been installed on the path /usr/local/Ascend, the version is 20.1.0, and the version of this package is 21.0.4,do you want to continue?  [y/n]

输入y确认更新驱动,最终提示如下:

deleting install files...
remove install files successfully!
deleting installed folders...
remove install folders successfully!
[Driver] [2022-03-04 13:24:12] [INFO]driver install type: DKMS
[Driver] [2022-03-04 13:24:12] [INFO]upgradePercentage:10%
[Driver] [2022-03-04 13:24:16] [INFO]upgradePercentage:30%
[Driver] [2022-03-04 13:24:16] [INFO]upgradePercentage:40%
[Driver] [2022-03-04 13:25:09] [INFO]upgradePercentage:90%
[Driver] [2022-03-04 13:25:09] [INFO]upgradePercentage:100%
[Driver] [2022-03-04 13:25:10] [INFO]Driver package installed successfully! Reboot needed for installation/upgrade to take effect! 
[Driver] [2022-03-04 13:25:10] [INFO]End time: 2022-03-04 13:25:10

提示重启生效,此时执行reboot命令进行重启。
重启后执行npu-smi info命令得到如下结果:

+--------------------------------------------------------------------------------------------+
| npu-smi 21.0.4                       Version: 21.0.4                                       |
+-------------------+-----------------+------------------------------------------------------+
| NPU     Name      | Health          | Power(W)     Temp(C)           Hugepages-Usage(page) |
| Chip    Device    | Bus-Id          | AICore(%)    Memory-Usage(MB)                        |
+===================+=================+======================================================+
| 13      310       | OK              | 12.8         45                0    / 970            |
| 0       0         | 0000:00:0D.0    | 0            608  / 7765                             |
+===================+=================+======================================================+

即可看到驱动版本已更新为21.0.4

更新CANN开发环境

在华为官网上下载CANN社区版,需要下载机器对应CPU架构的平台开发套件软件包,这里我下载的是x86_64架构的,对应软件名称为:
Ascend-cann-toolkit_5.1.RC1.alpha001_linux-x86_64.run
可在服务器上执行如下命令进行下载并安装:

推荐使用此方式下载,实测下载速度最高可达4.66MB/s,超过了我外网IP的固定带宽10 Mbit/s。

## 创建cann目录并进入cann目录
mkdir cann && cd cann
## 下载toolkit安装包
wget --no-check-certificate https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/5.1.RC1.alpha001/Ascend-cann-toolkit_5.1.RC1.alpha001_linux-x86_64.run
## 添加可执行权限
chmod +x Ascend-cann-toolkit_5.1.RC1.alpha001_linux-x86_64.run
## 执行安装
./Ascend-cann-toolkit_5.1.RC1.alpha001_linux-x86_64.run --install

安装过程可得到如下提示:

Verifying archive integrity...  100%   SHA256 checksums are OK. All good.
Uncompressing ASCEND_RUN_PACKAGE  100%  
[Toolkit] [20220304-13:27:35] [INFO] mkdir /usr/local/Ascend/ascend-toolkit/5.1.RC1.alpha001/x86_64-linux
[Toolkit] [20220304-13:27:35] [INFO] touch /var/log/ascend_seclog/ascend_toolkit_install.log
[Toolkit] [20220304-13:27:35] [INFO] LogFile:/var/log/ascend_seclog/ascend_toolkit_install.log
[Toolkit] [20220304-13:27:35] [INFO] install start
[Toolkit] [20220304-13:27:35] [INFO] The install path is /usr/local/Ascend !
[Toolkit] [20220304-13:27:35] [INFO] install package CANN-runtime-5.1.RC1.alpha001-linux.x86_64.run start
[Toolkit] [20220304-13:27:37] [INFO] CANN-runtime-5.1.RC1.alpha001-linux.x86_64.run --full --quiet --nox11 install success
[Toolkit] [20220304-13:27:37] [INFO] install package CANN-compiler-5.1.RC1.alpha001-linux.x86_64.run start
WARNING: You are using pip version 19.2.3, however version 22.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
WARNING: You are using pip version 19.2.3, however version 22.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
WARNING: You are using pip version 19.2.3, however version 22.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
WARNING: You are using pip version 19.2.3, however version 22.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
WARNING: You are using pip version 19.2.3, however version 22.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
WARNING: You are using pip version 19.2.3, however version 22.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[Toolkit] [20220304-13:28:13] [INFO] CANN-compiler-5.1.RC1.alpha001-linux.x86_64.run --full --pylocal --quiet --nox11 install success
[Toolkit] [20220304-13:28:13] [INFO] install package CANN-opp-5.1.RC1.alpha001-linux.x86_64.run start
[Toolkit] [20220304-13:28:33] [INFO] CANN-opp-5.1.RC1.alpha001-linux.x86_64.run --full --quiet --nox11 install success
[Toolkit] [20220304-13:28:33] [INFO] install package CANN-toolkit-5.1.RC1.alpha001-linux.x86_64.run start
[Toolkit] [20220304-13:29:13] [INFO] CANN-toolkit-5.1.RC1.alpha001-linux.x86_64.run --full --pylocal --quiet --nox11 install success
[Toolkit] [20220304-13:29:13] [INFO] install package Ascend-mindstudio-toolkit_3.0.3.B120_linux-x86_64.run start
[Toolkit] [20220304-13:29:14] [INFO] Ascend-mindstudio-toolkit_3.0.3.B120_linux-x86_64.run --full --quiet --nox11 install success
[Toolkit] [20220304-13:29:14] [INFO] install package CANN-aoe-5.1.RC1.alpha001-linux.x86_64.run start
WARNING: You are using pip version 19.2.3, however version 22.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[Toolkit] [20220304-13:29:16] [INFO] CANN-aoe-5.1.RC1.alpha001-linux.x86_64.run --full --quiet --nox11 install success
[Toolkit] [20220304-13:29:16] [INFO] install package Ascend-test-ops_5.0.3_linux.run start
[Toolkit] [20220304-13:29:17] [INFO] Ascend-test-ops_5.0.3_linux.run --full --quiet --nox11 install success
[Toolkit] [20220304-13:29:17] [INFO] install package Ascend-pyACL_5.0.3_linux-x86_64.run start
[Toolkit] [20220304-13:29:17] [INFO] Ascend-pyACL_5.0.3_linux-x86_64.run --full --quiet --nox11 install success
[Toolkit] [20220304-13:29:17] [INFO] /etc/Ascend/ascend_cann_install.info generate success
[Toolkit] [20220304-13:29:17] [INFO] Please make sure that:
PATH includes :
	/usr/local/Ascend/ascend-toolkit/latest/bin:
	/usr/local/Ascend/ascend-toolkit/latest/compiler/ccec_compiler/bin:
LD_LIBRARY_PATH includes :
	/usr/local/Ascend/ascend-toolkit/latest/lib64:
	/usr/local/Ascend/ascend-toolkit/latest/compiler/lib64/plugin/opskernel:
	/usr/local/Ascend/ascend-toolkit/latest/compiler/lib64/plugin/nnengine:
PYTHONPATH includes :
	/usr/local/Ascend/ascend-toolkit/latest/python/site-packages:
	/usr/local/Ascend/ascend-toolkit/latest/opp/op_impl/built-in/ai_core/tbe:
ASCEND_AICPU_PATH includes :
	/usr/local/Ascend/ascend-toolkit/latest:
ASCEND_OPP_PATH includes :
	/usr/local/Ascend/ascend-toolkit/latest/opp:
TOOLCHAIN_HOME includes :
	/usr/local/Ascend/ascend-toolkit/latest/toolkit:
ASCEND_HOME_PATH includes :
	/usr/local/Ascend/ascend-toolkit/latest:
[Toolkit] [20220304-13:29:17] [INFO] If your service is started using the shell script, you can call the /usr/local/Ascend/ascend-toolkit/set_env.sh script to configure environment variables. Note that this script can not be executed mannually.
[Toolkit] [20220304-13:29:17] [INFO] Ascend-cann-toolkit_5.1.RC1.alpha001_linux-x86_64 install success,The install path is /usr/local/Ascend !

下载并编译msame模型推理工具

## 下载msame源码
git clone https://gitee.com/ascend/tools.git
## 切换到代码目录
cd tools/msame
## 添加可执行权限
chmod +x build.sh
## 开始编译工具
./build.sh g++

提示编译成功

-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/g++
-- Check for working CXX compiler: /usr/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- env INC_PATH: /usr/local/Ascend/ascend-toolkit/latest
-- env LIB_PATH: /usr/local/Ascend/ascend-toolkit/latest/acllib/lib64/stub
-- Configuring done
-- Generating done
-- Build files have been written to: /root/cann/tools/msame/build/intermediates/host
Scanning dependencies of target main
[ 20%] Building CXX object CMakeFiles/main.dir/utils.cpp.o
[ 40%] Building CXX object CMakeFiles/main.dir/model_process.cpp.o
[ 60%] Building CXX object CMakeFiles/main.dir/sample_process.cpp.o
[ 80%] Building CXX object CMakeFiles/main.dir/main.cpp.o
[100%] Linking CXX executable /root/cann/tools/msame/out/main
[100%] Built target main

下载googlenet模型

## 创建googlenet目录并进入googlenet目录
mkdir googlenet && cd googlenet
wget https://modelzoo-train-atc.obs.cn-north-4.myhuaweicloud.com/003_Atc_Models/AE/ATC%20Model/classification/googlenet.om

进行空数据推理

../out/msame --model ./googlenet.om --output ./output --outfmt BIN --loop 1
[INFO] acl init success
[INFO] open device 0 success
[INFO] create context success
[INFO] create stream success
[INFO] get run mode success
[INFO] load model ./googlenet.om success
[INFO] create model description success
[INFO] get input dynamic gear count success
[INFO] create model output success
./output/202234_12_58_29_218043
[INFO] model execute success
Inference time: 1.963ms
[INFO] get max dynamic batch size success
[INFO] output data success
Inference average time: 1.963000 ms
[INFO] destroy model input success
[INFO] unload model success, model Id is 1
[INFO] Execute sample success
[INFO] end to destroy stream
[INFO] end to destroy context
[INFO] end to reset device is 0
[INFO] end to finalize acl

上述输出结果提示成功,无报错!

参考来源

麒麟系统安装CANN开发环境
CANN 社区版下载-昇腾社区
固件与驱动-昇腾社区

有关华为云AI加速型(昇腾Ascend310)Ubuntu18.04系统下使用msame模型推理工具的更多相关文章

  1. ruby - i18n Assets 管理/翻译 UI - 2

    我正在使用i18n从头开始​​构建一个多语言网络应用程序,虽然我自己可以处理一大堆yml文件,但我说的语言(非常)有限,最终我想寻求外部帮助帮助。我想知道这里是否有人在使用UI插件/gem(与django上的django-rosetta不同)来处理多个翻译器,其中一些翻译器不愿意或无法处理存储库中的100多个文件,处理语言数据。谢谢&问候,安德拉斯(如果您已经在ruby​​onrails-talk上遇到了这个问题,我们深表歉意) 最佳答案 有一个rails3branchofthetolkgem在github上。您可以通过在Gemfi

  2. ruby-on-rails - Rails 3 I18 : translation missing: da. datetime.distance_in_words.about_x_hours - 2

    我看到这个错误:translationmissing:da.datetime.distance_in_words.about_x_hours我的语言环境文件:http://pastie.org/2944890我的看法:我已将其添加到我的application.rb中:config.i18n.load_path+=Dir[Rails.root.join('my','locales','*.{rb,yml}').to_s]config.i18n.default_locale=:da如果我删除I18配置,帮助程序会处理英语。更新:我在config/enviorments/devolpment

  3. ruby-on-rails - 如果我将 ruby​​ 版本 2.5.1 与 rails 版本 2.3.18 一起使用会怎样? - 2

    如果我使用ruby​​版本2.5.1和Rails版本2.3.18会怎样?我有基于rails2.3.18和ruby​​1.9.2p320构建的rails应用程序,我只想升级ruby的版本,而不是rails,这可能吗?我必须面对哪些挑战? 最佳答案 GitHub维护apublicfork它有针对旧Rails版本的分支,有各种变化,它们一直在运行。有一段时间,他们在较新的Ruby版本上运行较旧的Rails版本,而不是最初支持的版本,因此您可能会发现一些关于需要向后移植的有用提示。不过,他们现在已经有几年没有使用2.3了,所以充其量只能让更

  4. ruby - 如何在 Ubuntu 中清除 Ruby Phusion Passenger 的缓存? - 2

    我试过重新启动apache,缓存的页面仍然出现,所以一定有一个文件夹在某个地方。我没有“公共(public)/缓存”,那么我还应该查看哪些其他地方?是否有一个URL标志也可以触发此效果? 最佳答案 您需要触摸一个文件才能清除phusion,例如:touch/webapps/mycook/tmp/restart.txt参见docs 关于ruby-如何在Ubuntu中清除RubyPhusionPassenger的缓存?,我们在StackOverflow上找到一个类似的问题:

  5. ruby-on-rails - Ruby on Rails I18n 插值 - 2

    大家好!我对我的:username字段进行了一个小的验证,它应该是4到30个字符。我写了一个验证::length=>{:within=>4..30,:message=>I18n.t('activerecord.errors.range')-我想显示一个错误各种错误的消息(不像,太长或太短),但这里有一个问题-我可以将最小值和最大值都传递给翻译,以便有类似的东西:用户名应该在4到30个字符之间。目前我有:range:"shouldbebetween%{count}and%{count}characters",这显然不起作用(只是为了检查)。是否可以从范围中获取这些值?谢谢大家的指教!

  6. Vscode+Cmake配置并运行opencv环境(Windows和Ubuntu大同小异) - 2

    之前在培训新生的时候,windows环境下配置opencv环境一直教的都是网上主流的vsstudio配置属性表,但是这个似乎对新生来说难度略高(虽然个人觉得完全是他们自己的问题),加之暑假之后对cmake实在是爱不释手,且这样配置确实十分简单(其实都不需要配置),故斗胆妄言vscode下配置CV之法。其实极为简单,图比较多所以很长。如果你看此文还配不好,你应该思考一下是不是自己的问题。闲话少说,直接开始。0.CMkae简介有的人到大二了都不知道cmake是什么,我不说是谁。CMake是一个开源免费并且跨平台的构建工具,可以用简单的语句来描述所有平台的编译过程。它能够根据当前所在平台输出对应的m

  7. 在VMware16虚拟机安装Ubuntu详细教程 - 2

    在VMware16.2.4安装Ubuntu一、安装VMware1.打开VMwareWorkstationPro官网,点击即可进入。2.进入后向下滑动找到Workstation16ProforWindows,点击立即下载。3.下载完成,文件大小615MB,如下图:4.鼠标右击,以管理员身份运行。5.点击下一步6.勾选条款,点击下一步7.先勾选,再点击下一步8.去掉勾选,点击下一步9.点击下一步10.点击安装11.点击许可证12.在百度上搜索VM16许可证,复制填入,然后点击输入即可,亲测有效。13.点击完成14.重启系统,点击是15.双击VMwareWorkstationPro图标,进入虚拟机主

  8. kvm虚拟机安装centos7基于ubuntu20.04系统 - 2

    需求:要创建虚拟机,就需要给他提供一个虚拟的磁盘,我们就在/opt目录下创建一个10G大小的raw格式的虚拟磁盘CentOS-7-x86_64.raw命令格式:qemu-imgcreate-f磁盘格式磁盘名称磁盘大小qemu-imgcreate-f磁盘格式-o?1.创建磁盘qemu-imgcreate-fraw/opt/CentOS-7-x86_64.raw10G执行效果#ls/opt/CentOS-7-x86_64.raw2.安装虚拟机使用virt-install命令,基于我们提供的系统镜像和虚拟磁盘来创建一个虚拟机,另外在创建虚拟机之前,提前打开vnc客户端,在创建虚拟机的时候,通过vnc

  9. ruby - ri 有空文件 – Ubuntu 11.10, Ruby 1.9 - 2

    我正在运行Ubuntu11.10并像这样安装Ruby1.9:$sudoapt-getinstallruby1.9rubygems一切都运行良好,但ri似乎有空文档。ri告诉我文档是空的,我必须安装它们。我执行此操作是因为我读到它会有所帮助:$rdoc--all--ri现在,当我尝试打开任何文档时:$riArrayNothingknownaboutArray我搜索的其他所有内容都是一样的。 最佳答案 这个呢?apt-getinstallri1.8编辑或者试试这个:(非rvm)geminstallrdocrdoc-datardoc-da

  10. ruby - 在 Ubuntu 14.04 中使用 Curl 安装 RVM 时出错 - 2

    我试图在Ubuntu14.04中使用Curl安装RVM。我运行了以下命令:\curl-sSLhttps://get.rvm.io|bash-sstable出现如下错误:curl:(7)Failedtoconnecttoget.rvm.ioport80:Networkisunreachable非常感谢解决此问题的任何帮助。谢谢 最佳答案 在执行curl之前尝试这个:echoipv4>>~/.curlrc 关于ruby-在Ubuntu14.04中使用Curl安装RVM时出错,我们在Stack

随机推荐