https://www.mindspore.cn/install
根据提示
根据提示安装驱动和软件包
版本要匹配上
conda create -n mindspore_py39 -c conda-forge python=3.9.0
conda install -c conda-forge openmpi=4.0.3
conda install gmp=6.1.2
version=0.4.0
pip install /usr/local/Ascend/ascend-toolkit/latest/fwkacllib/lib64/topi-${version}-py3-none-any.whl
pip install /usr/local/Ascend/ascend-toolkit/latest/fwkacllib/lib64/te-${version}-py3-none-any.whl
pip install /usr/local/Ascend/ascend-toolkit/latest/fwkacllib/lib64/hccl-0.1.0-py3-none-any.whl
version=1.5.0
conda install mindspore-ascend=${version} -c mindspore -c conda-forge
conda install sympy
之后是配置环境变量
配置环境变量
如果Ascend 910 AI处理器配套软件包没有安装在默认路径,安装好MindSpore之后,需要导出Runtime相关环境变量,下述命令中LOCAL_ASCEND=/usr/local/Ascend的/usr/local/Ascend表示配套软件包的安装路径,需注意将其改为配套软件包的实际安装路径
# control log level. 0-DEBUG, 1-INFO, 2-WARNING, 3-ERROR, default level is WARNING.
export GLOG_v=2
# Conda environmental options
LOCAL_ASCEND=/usr/local/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}
# 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
环境变量可以写在conda 环境里
https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#setting-environment-variables
然后就是测试
注意点ls
没找到 xx.so 基本上是 ${LD_LIBRARY_PATH} 没配置好。
如果是 undefined symbol xxx 的报错,可能是 .so的版本不匹配,里面没这个符号。
我的环境
export CMAKE_ROOT=/opt/cmake-3.20.0-rc4-linux-aarch64
#用于设置python3.7.5库文件路径
export LD_LIBRARY_PATH=/usr/local/python3.7.5/lib:$LD_LIBRARY_PATH
#如果用户环境存在多个python3版本则指定使用python3.7.5版本
export PATH=/usr/local/python3.7.5/bin:$PATH
export PATH=/opt/cmake-3.20.0-rc4-linux-aarch64/bin:$PATH
export DDK_PATH=/usr/local/Ascend/ascend-toolkit/latest/arm64-linux
export LD_LIBRARY_PATH=$DDK_PATH/fwkacllib/lib64:$LD_LIBRARY_PATH
export PATH=${DDK_PATH}/fwkacllib/ccec_compiler/bin:${DDK_PATH}/fwkacllib/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/python3.7.5/lib:$LD_LIBRARY_PATH
#如果用户环境存在多个python3版本则指定使用python3.7.5版本
export PATH=/usr/local/python3.7.5/bin:$PATH
export PYTHONPATH=${DDK_PATH}/fwkacllib/python/site-packages:${DDK_PATH}/toolkit/python/site-packages:$PYTHONPATH
export PYTHONPATH=/usr/local/Ascend/tfplugin/latest/tfplugin/python/site-packages:$PYTHONPATH
export ASCEND_OPP_PATH=${DDK_PATH}/opp
export ASCEND_AICPU_PATH=${DDK_PATH}/arm64-linux #其中{arch}请根据实际情况替换(arm64或x86_64)
export TOOLCHAIN_HOME=${DDK_PATH}/toolkit