昇腾 CANN 开发环境

GoCoding
• 阅读 1597

昇腾 CANN 是华为开发的 AI 场景的异构计算架构,支持用户快速构建基于昇腾平台的 AI 应用和业务。

昇腾 CANN 开发环境

本文为 Ubuntu 上手动部署开发环境(与运行环境分离),安装 MindStudio 的过程。

注:也可通过 msInstaller 工具自动安装。只是本文实践时,安装服务遇到了中断问题。故给出了手动安装的方式。

基础说明

要求:

  • Ubuntu x86 18.04

非昇腾设备: 仅能用于代码开发、编译等不依赖于昇腾芯片的纯开发活动。

开发和运行环境分离部署:

昇腾 CANN 开发环境

获取软件包

  • 软件包(推理)
    • Ascend-cann-toolkit_5.0.2.alpha003_linux-x86_64.run
    • Ascend-cann-toolkit_5.0.2.alpha003_linux-aarch64.run
    • MindStudio_3.0.1_linux.tar.gz

下载页,中英文给到的版本可能不同。

配置用户(可选)

当用户使用非root用户安装时,需要操作该章节,否则请忽略。

创建用户(non-root):

sudo -i

# 创建用户
groupadd HwHiAiUser
useradd -g HwHiAiUser -d /home/HwHiAiUser -m HwHiAiUser -s /bin/bash
passwd HwHiAiUser

# 添加权限
chmod u+w /etc/sudoers
vi /etc/sudoers
  # User privilege specification
  HwHiAiUser ALL=(ALL:ALL) ALL
chmod u-w /etc/sudoers

# 切换用户
su HwHiAiUser

安装依赖

sudo apt update
sudo apt-get install -y gcc g++ make cmake zlib1g zlib1g-dev libsqlite3-dev openssl libssl-dev libffi-dev unzip pciutils net-tools libblas-dev gfortran libblas3 libopenblas-dev

wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tgz
tar -zxvf Python-3.7.5.tgz
cd Python-3.7.5
./configure --prefix=$HOME/python3.7.5 --enable-loadable-sqlite-extensions --enable-shared
make -j`nproc`
make install

sudo cp $HOME/python3.7.5/lib/libpython3.7m.so.1.0 /usr/lib

sudo ln -s $HOME/python3.7.5/bin/python3 /usr/bin/python3.7
sudo ln -s $HOME/python3.7.5/bin/pip3    /usr/bin/pip3.7
sudo ln -s $HOME/python3.7.5/bin/python3 /usr/bin/python3.7.5
sudo ln -s $HOME/python3.7.5/bin/pip3    /usr/bin/pip3.7.5

sudo ln -s $HOME/python3.7.5/bin/pip3      /usr/bin/pip3
sudo ln -s $HOME/python3.7.5/lib/python3.7 /usr/lib/python3.7

pip3.7.5 config set global.index-url https://mirrors.aliyun.com/pypi/simple/
pip3.7.5 install attrs psutil decorator numpy protobuf==3.11.3 scipy sympy cffi

安装开发包

$ chmod +x Ascend-cann-toolkit_5.0.2.alpha003_linux-x86_64.run
$ ./Ascend-cann-toolkit_5.0.2.alpha003_linux-x86_64.run --install
Verifying archive integrity...  100%   SHA256 checksums are OK. All good.
Uncompressing ASCEND_RUN_PACKAGE  100%
[Toolkit] [20210610-20:42:05] [INFO] LogFile:/home/HwHiAiUser/var/log/ascend_seclog/ascend_toolkit_install.log
[Toolkit] [20210610-20:42:05] [INFO] install start
[Toolkit] [20210610-20:42:05] [INFO] The install path is /home/HwHiAiUser/Ascend !
[Toolkit] [20210610-20:42:05] [WARNING] driver package maybe not installed
[Toolkit] [20210610-20:42:05] [WARNING] driver package maybe not installed
[Toolkit] [20210610-20:42:05] [INFO] install package Ascend-acllib-1.78.t20.0.b200-linux.x86_64.run start
[Toolkit] [20210610-20:42:08] [INFO] Ascend-acllib-1.78.t20.0.b200-linux.x86_64.run --devel --quiet --nox11   install success
[Toolkit] [20210610-20:42:08] [INFO] install package Ascend-pyACL-3.3.0.alpha003-linux.x86_64.run start
[Toolkit] [20210610-20:42:08] [INFO] Ascend-pyACL-3.3.0.alpha003-linux.x86_64.run --devel --quiet --nox11   install success
[Toolkit] [20210610-20:42:08] [INFO] install package Ascend-atc-1.78.t20.0.b200-linux.x86_64.run start
[Toolkit] [20210610-20:42:41] [INFO] Ascend-atc-1.78.t20.0.b200-linux.x86_64.run --devel --pylocal --quiet --nox11   install success
[Toolkit] [20210610-20:42:41] [INFO] install package Ascend-opp-1.78.t20.0.b200-linux.x86_64.run start
[Toolkit] [20210610-20:43:11] [INFO] Ascend-opp-1.78.t20.0.b200-linux.x86_64.run --devel --quiet --nox11   install success
[Toolkit] [20210610-20:43:11] [INFO] install package Ascend-toolkit-1.78.t20.0.b200-linux.x86_64.run start
[Toolkit] [20210610-20:44:11] [INFO] Ascend-toolkit-1.78.t20.0.b200-linux.x86_64.run --devel --pylocal --quiet --nox11   install success
[Toolkit] [20210610-20:44:11] [INFO] install package Ascend310-aicpu_kernels-1.78.t20.0.b200.run start
[Toolkit] [20210610-20:44:12] [INFO] Ascend310-aicpu_kernels-1.78.t20.0.b200.run --devel --quiet --nox11   install success
[Toolkit] [20210610-20:44:12] [INFO] install package Ascend910-aicpu_kernels-1.78.t20.0.b200.run start
[Toolkit] [20210610-20:44:13] [INFO] Ascend910-aicpu_kernels-1.78.t20.0.b200.run --devel --quiet --nox11   install success
[Toolkit] [20210610-20:44:13] [INFO] install package Ascend310-aicpu_kernels_minirc-1.78.t20.0.b200.run start
[Toolkit] [20210610-20:44:14] [INFO] Ascend310-aicpu_kernels_minirc-1.78.t20.0.b200.run --devel --quiet --nox11   install success
[Toolkit] [20210610-20:44:14] [INFO] /home/HwHiAiUser/Ascend/ascend_cann_install.info generate success
[Toolkit] [20210610-20:44:14] [INFO] Please make sure that:
Offline infer develop (cannot coexist with other scenes):
    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:
    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:
    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:
[Toolkit] [20210610-20:44:15] [INFO] Ascend-cann-toolkit_5.0.2.alpha003_linux-x86_64.run install success,The install path is /home/HwHiAiUser/Ascend !
$ chmod +x Ascend-cann-toolkit_5.0.2.alpha003_linux-aarch64.run
$ ./Ascend-cann-toolkit_5.0.2.alpha003_linux-aarch64.run --install
Verifying archive integrity...  100%   SHA256 checksums are OK. All good.
Uncompressing ASCEND_RUN_PACKAGE  100%
[Toolkit] [20210610-20:46:27] [INFO] LogFile:/home/HwHiAiUser/var/log/ascend_seclog/ascend_toolkit_install.log
[Toolkit] [20210610-20:46:27] [INFO] install start
[Toolkit] [20210610-20:46:27] [INFO] The install path is /home/HwHiAiUser/Ascend !
[Toolkit] [20210610-20:46:27] [WARNING] driver package maybe not installed
[Toolkit] [20210610-20:46:27] [WARNING] driver package maybe not installed
[Toolkit] [20210610-20:46:27] [INFO] The current OS is x86_64
[Toolkit] [20210610-20:46:27] [INFO] install package Ascend-acllib-1.78.t20.0.b200-linux.aarch64.run start
[Toolkit] [20210610-20:46:29] [INFO] Ascend-acllib-1.78.t20.0.b200-linux.aarch64.run --devel --quiet --nox11   install success
[Toolkit] [20210610-20:46:29] [INFO] install package Ascend310-aicpu_kernels-1.78.t20.0.b200.run start
[Toolkit] [20210610-20:46:31] [INFO] Ascend310-aicpu_kernels-1.78.t20.0.b200.run --devel --quiet --nox11   install success
[Toolkit] [20210610-20:46:31] [INFO] install package Ascend310-aicpu_kernels_minirc-1.78.t20.0.b200.run start
[Toolkit] [20210610-20:46:32] [INFO] Ascend310-aicpu_kernels_minirc-1.78.t20.0.b200.run --devel --quiet --nox11   install success
[Toolkit] [20210610-20:46:32] [INFO] Ascend-cann-toolkit_5.0.2.alpha003_linux-aarch64.run install success,The install path is /home/HwHiAiUser/Ascend !

创建 Docker 镜像(可选)

docker pull ubuntu:18.04

cat <<-EOF > Dockerfile
# syntax=docker/dockerfile:experimental
FROM ubuntu:18.04

ARG ASCEND_DIR=./ascend
# ./ascend
#  Ascend-cann-toolkit_5.0.2.alpha003_linux-x86_64.run
#  Ascend-cann-toolkit_5.0.2.alpha003_linux-aarch64.run
#  Python-3.7.5.tgz

COPY \${ASCEND_DIR} /ascend

RUN apt-get update \\
 && apt-get install -y gcc g++ make cmake zlib1g zlib1g-dev libsqlite3-dev \\
                       openssl libssl-dev libffi-dev unzip pciutils net-tools \\
 && rm -rf /var/lib/apt/lists/*

RUN cd /ascend \\
 && tar -zxvf Python-3.7.5.tgz \\
 && cd Python-3.7.5 \\
 && ./configure --prefix=/usr/local/python3.7.5 \\
                --enable-loadable-sqlite-extensions --enable-shared \\
 && make -j\$(nproc) && make install \\
 && cp /usr/local/python3.7.5/lib/libpython3.7m.so.1.0 /usr/lib \\
 && ln -s /usr/local/python3.7.5/bin/python3 /usr/bin/python3 \\
 && ln -s /usr/local/python3.7.5/bin/pip3 /usr/bin/pip3 \\
 && ln -s /usr/local/python3.7.5/bin/python3 /usr/bin/python3.7 \\
 && ln -s /usr/local/python3.7.5/bin/pip3 /usr/bin/pip3.7 \\
 && ln -s /usr/local/python3.7.5/bin/python3 /usr/bin/python3.7.5 \\
 && ln -s /usr/local/python3.7.5/bin/pip3 /usr/bin/pip3.7.5 \\
 && pip3.7.5 install attrs psutil decorator numpy protobuf==3.11.3 scipy sympy \\
      cffi -i https://mirrors.aliyun.com/pypi/simple/ \\
 && rm -r /ascend/Python-3.7.5

RUN cd /ascend \\
 && chmod +x *.run \\
 && ./Ascend-cann-toolkit_5.0.2.alpha003_linux-x86_64.run \\
      --install-username=root --install-usergroup=root --install \\
 && ./Ascend-cann-toolkit_5.0.2.alpha003_linux-aarch64.run \\
      --install-username=root --install-usergroup=root --install

RUN echo '\nawk "/Please make sure that:/,/chmod_authority/" /var/log/ascend_seclog/ascend_toolkit_install.log' >> /root/.bashrc

CMD ["/bin/bash"]
EOF

docker build \
-t ascend/cann:5.0.2.alpha003 \
--build-arg ASCEND_DIR=./ascend \
-f ./Dockerfile .

docker run -it --rm ascend/cann:5.0.2.alpha003

安装 MindStudio

tar xzvf MindStudio_3.0.1_linux.tar.gz -C $HOME
sudo ln -s $HOME/MindStudio/bin/MindStudio.sh /usr/local/bin/MindStudio

初次运行 MindStudio 如果提示依赖缺失,则运行提示命令安装:

$ MindStudio
Checking MindStudio environment dependencies...
Success

Checking Python environment dependencies...
Success

Some dependencies are missing. Execute the following command first:
sudo  apt-get -y install xterm fonts-wqy-zenhei fonts-wqy-microhei  && /home/HwHiAiUser/python3.7.5/bin/pip3 install --user  grpcio coverage gnureadline pylint matplotlib requests pandas xlrd absl-py

此外,还需安装 JDK:

sudo apt-get -y install openjdk-8-jdk

最后,即可正常运行 MindStudio

配置 MindStudio

初次提示导入设置:

昇腾 CANN 开发环境

选择不导入 OK。若有以前设置,可设路径如: $HOME/.config/Huawei/MindStudioMS-3.0

接着选择开发包路径:

昇腾 CANN 开发环境

之后用户体验改进 Argree

昇腾 CANN 开发环境

最后进入 MindStudio 首页:

昇腾 CANN 开发环境

参考

GoCoding 个人实践的经验分享,可关注公众号!

点赞
收藏
评论区
推荐文章
blmius blmius
3年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
皕杰报表之UUID
​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为
待兔 待兔
4个月前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
Jacquelyn38 Jacquelyn38
3年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
Stella981 Stella981
3年前
Opencv中Mat矩阵相乘——点乘、dot、mul运算详解
Opencv中Mat矩阵相乘——点乘、dot、mul运算详解2016年09月02日00:00:36 \牧野(https://www.oschina.net/action/GoToLink?urlhttps%3A%2F%2Fme.csdn.net%2Fdcrmg) 阅读数:59593
Stella981 Stella981
3年前
KVM调整cpu和内存
一.修改kvm虚拟机的配置1、virsheditcentos7找到“memory”和“vcpu”标签,将<namecentos7</name<uuid2220a6d1a36a4fbb8523e078b3dfe795</uuid
Easter79 Easter79
3年前
Twitter的分布式自增ID算法snowflake (Java版)
概述分布式系统中,有一些需要使用全局唯一ID的场景,这种时候为了防止ID冲突可以使用36位的UUID,但是UUID有一些缺点,首先他相对比较长,另外UUID一般是无序的。有些时候我们希望能使用一种简单一些的ID,并且希望ID能够按照时间有序生成。而twitter的snowflake解决了这种需求,最初Twitter把存储系统从MySQL迁移
Stella981 Stella981
3年前
Nginx反向代理upstream模块介绍
!(https://oscimg.oschina.net/oscnet/1e67c46e359a4d6c8f36b590a372961f.gif)!(https://oscimg.oschina.net/oscnet/819eda5e7de54c23b54b04cfc00d3206.jpg)1.Nginx反
Easter79 Easter79
3年前
TensorFlow有Tensorboard,MindSpore框架如何做可视化?
5月12日,机器之心联合华为昇腾学院开设的线上公开课《轻松上手开源框架MindSpore》第6课完成,王越讲师为大家带来了主题分享《MindSpore可视化工具使用指南》,第6课回顾视频如下:https://www.bilibili.com/video/BV1et4y117aW​www.bilibili.com(https://
司马炎 司马炎
1年前
【MindStudio训练营第一季】MindStudio 可视化AI应用开发体验随笔
MindStudioMindStudio提供一站式AI开发环境,依靠工具与性能调优,采用插件化扩展机制,打造高效、便捷的全流程开发工具链。目前最新版本是5.0.RC3,发布于2022年20月,对应的昇腾社区版本:6.0.RC1。新增众多特性,
GoCoding
GoCoding
Lv1
Go coding in my way :)
文章
32
粉丝
5
获赞
10