昇腾 CANN 是华为开发的 AI 场景的异构计算架构,支持用户快速构建基于昇腾平台的 AI 应用和业务。
本文为 Ubuntu 上手动部署开发环境(与运行环境分离),安装 MindStudio 的过程。
注:也可通过 msInstaller 工具自动安装。只是本文实践时,安装服务遇到了中断问题。故给出了手动安装的方式。
基础说明
要求:
- Ubuntu x86 18.04
非昇腾设备: 仅能用于代码开发、编译等不依赖于昇腾芯片的纯开发活动。
开发和运行环境分离部署:
image获取软件包
-
软件包(推理)
- 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
初次提示导入设置:
image选择不导入 OK
。若有以前设置,可设路径如: $HOME/.config/Huawei/MindStudioMS-3.0
。
接着选择开发包路径:
image之后用户体验改进 Argree
:
最后进入 MindStudio
首页:
参考
GoCoding 个人实践的经验分享,可关注公众号!
网友评论