在Altas 200I DK A2开发版上配置Ascend版本的Mindspore环境。
使用烧录软件烧录了下图的固件和驱动。
查找资料显示上述固件和驱动支持Mindspore版本2.2.0。
在安装并配置完环境后,测试环境时会出现如下报错:
(mindspore_ascend) HwHiAiUser@davinci-mini:~$ python
Python 3.9.25 (main, Nov 3 2025, 22:33:42)
[GCC 11.2.0] :: Anaconda, Inc. on linux
Type “help”, “copyright”, “credits” or “license” for more information.
import numpy as np
import mindspore as ms
/home/HwHiAiUser/.conda/envs/mindspore_ascend/lib/python3.9/site-packages/numpy/core/getlimits.py:549: UserWarning: The value of the smallest subnormal for <class ‘numpy.float64’> type is zero.
setattr(self, word, getattr(machar, word).flat[0])
/home/HwHiAiUser/.conda/envs/mindspore_ascend/lib/python3.9/site-packages/numpy/core/getlimits.py:549: UserWarning: The value of the smallest subnormal for <class ‘numpy.float32’> type is zero.
setattr(self, word, getattr(machar, word).flat[0])
from mindspore import opsms.set_context(mode=ms.PYNATIVE_MODE, device_target=“Ascend”)
x = ms.Tensor(np.ones([1,3,3,4]).astype(np.float32))
y = ms.Tensor(np.ones([1,3,3,4]).astype(np.float32))
z = ops.add(x, y)
print(z)
Traceback (most recent call last):
File “”, line 1, in
File "/home/HwHiAiUser/.conda/envs/mindspore_ascend/lib/python3.9/site-packages/mindspore/common/stub_tensor.py", line 49, in fun
return method(*arg, **kwargs)
File “/home/HwHiAiUser/.conda/envs/mindspore_ascend/lib/python3.9/site-packages/mindspore/common/tensor.py”, line 493, in str
return str(self.asnumpy())
File “/home/HwHiAiUser/.conda/envs/mindspore_ascend/lib/python3.9/site-packages/mindspore/common/tensor.py”, line 964, in asnumpy
return Tensor.asnumpy(self)
RuntimeError: The device address type is wrong: type name in address:CPU, type name in context:Ascend
- C++ Call Stack: (For framework developers)
mindspore/ccsrc/plugin/device/ascend/hal/hardware/ge_device_res_manager.cc:72 AllocateMemory
经过尝试在使用了ops运算符后,对z无法执行.asnumpy()函数。
上述错误是由于驱动和mindspore版本不匹配导致的吗?还是说Ascend相关配置不正确。
使用npu-smi info命令可以看到npu硬件
(mindspore_ascend) HwHiAiUser@davinci-mini:~$ npu-smi info
±-------------------------------------------------------------------------------------------------------+
| npu-smi 23.0.rc3 Version: 23.0.rc3 |
±------------------------------±----------------±-----------------------------------------------------+
| NPU Name | Health | Power(W) Temp(C) Hugepages-Usage(page) |
| Chip Device | Bus-Id | AICore(%) Memory-Usage(MB) |
+===============================+=================+======================================================+
| 0 310B4 | Alarm | 7.4 50 15 / 15 |
| 0 0 | NA | 0 3294 / 3513 |
+===============================+=================+======================================================+
