张小白带你玩转Atlas 200DK+CANN 5.0.4+MindStudio 3.0.4(十)安装MindSpore
十、安装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使得环境变量生效。
下载示例代码:
解压: 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
等了好一段时间,结果才出来:
张小白咨询了专家,解释了为啥有点慢的原因:
(未完待续)
- 点赞
- 收藏
- 关注作者
评论(0)