张小白带你玩转Atlas 200DK+CANN 5.0.4+MindStudio 3.0.4(十)安装MindSpore

举报
张辉 发表于 2022/04/17 01:30:56 2022/04/17
【摘要】 Atlas 200DK+CANN 5.0.4+MindStudio 3.0.4+MindSpore 1.6.1

十、安装MindSpore 1.6.1 ascend310版

昇腾和昇思怎么结合?当然靠Atlas 200DK和MindSpore 1.6.1结合了。强强联合是什么样子,下面即将揭晓。

这次,我们来试试在Atlas 200DK的CANN 5.0.4上安装MindSpore。

打开MindSpore官网,按照以下方式选择:

1、安装系统所需依赖

1.1 确认已有软件版本:

先确认下200DK上的软件版本(我们采用的是CANN 5.0.4 alpha005的dd镜像):

1.2 cmake 3.23

CMake版本需要3.18.3,当前略低,先安装cmake 3.23吧:

先装cmake吧:

wget https://github.com/Kitware/CMake/releases/download/v3.23.0-rc1/cmake-3.23.0-rc1.tar.gz

tar -zxvf cmake-3.23.0-rc1.tar.gz

cd cmake-3.23.0-rc1

./bootstrap

速度略慢,需要耐心等待。。。

make -j8

...

sudo make install -j8

cmake --version

看来要定义下CMAKE_ROOT

在 ~/.basrc文件中增加 CMAKE_ROOT=/usr/local/share/cmake-3.23

source ~/.bashrc使得环境变量生效

现在cmake版本是3.23了。


1.3 gmp 6.1.2

来装gmp吧

wget https://gmplib.org/download/gmp/gmp-6.1.2.tar.xz

xz -d gmp-6.1.2.tar.xz

tar -xvf gmp-6.1.2.tar

cd gmp-6.1.2

./configure

make -j8

sudo make install -j8

2、安装MindSpore

贴入上面的安装命令:(记住选择aarch64版本的)

貌似是pip对应的python版本不对。

换成python3来安装:

python3 -m pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/1.6.1/MindSpore/ascend/aarch64/mindspore_ascend-1.6.1-cp37-cp37m-linux_aarch64.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com -i https://pypi.tuna.tsinghua.edu.cn/simple

权限问题,再加上--user参数吧:

python3 -m pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/1.6.1/MindSpore/ascend/aarch64/mindspore_ascend-1.6.1-cp37-cp37m-linux_aarch64.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com -i https://pypi.tuna.tsinghua.edu.cn/simple --user

3、安装后验证

根据安装说明的要求设置环境变量: vi ~/.bashrc

# control log level. 0-DEBUG, 1-INFO, 2-WARNING, 3-ERROR, 4-CRITICAL, default level is WARNING.
export GLOG_v=2

# Conda environmental options
LOCAL_ASCEND=/home/HwHiAiUser/Ascend # the root directory of run package

# lib libraries that the run package depends on
export LD_LIBRARY_PATH=${LOCAL_ASCEND}/ascend-toolkit/latest/fwkacllib/lib64:${LOCAL_ASCEND}/driver/lib64:${LOCAL_ASCEND}/ascend-toolkit/latest/opp/op_impl/built-in/ai_core/tbe/op_tiling:${LD_LIBRARY_PATH}

# lib libraries that the mindspore depends on, modify "pip3" according to the actual situation
export LD_LIBRARY_PATH=`pip3 show mindspore-ascend | grep Location | awk '{print $2"/mindspore/lib"}' | xargs realpath`:${LD_LIBRARY_PATH}

# Environment variables that must be configured
export TBE_IMPL_PATH=${LOCAL_ASCEND}/ascend-toolkit/latest/opp/op_impl/built-in/ai_core/tbe            # TBE operator implementation tool path
export ASCEND_OPP_PATH=${LOCAL_ASCEND}/ascend-toolkit/latest/opp                                       # OPP path
export PATH=${LOCAL_ASCEND}/ascend-toolkit/latest/fwkacllib/ccec_compiler/bin/:${PATH}                 # TBE operator compilation tool path
export PYTHONPATH=${TBE_IMPL_PATH}:${PYTHONPATH}                                                       # Python library that TBE implementation depends on

source ~/.bashrc使得环境变量生效。

下载示例代码:

wget https://obs.dualstack.cn-north-4.myhuaweicloud.com/mindspore-website/sample_resources/ascend310_single_op_sample.zip

解压: unzip ascend310_single_op_sample.zip

进入目录后编译:

cd ascend310_single_op_sample

cmake . -DMINDSPORE_PATH=`pip3 show mindspore-ascend | grep Location | awk '{print $2"/mindspore"}' | xargs realpath`

make -j8

执行用例:

./tensor_add_sample

等了好一段时间,结果才出来:

张小白咨询了专家,解释了为啥有点慢的原因:

(未完待续)

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

评论(0

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

全部回复

上滑加载中

设置昵称

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

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

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