MindSpore报错Can not select a valid kernel info for [Default/Pow-op0]
2024/02/22
152
问题信息
问题来源 | 产品大类 | 产品子类 | 关键字 |
---|---|---|---|
官方 | 模型训练 | MindSpore | 无 |
问题现象描述
系统环境:
Hardware Environment(Ascend/GPU/CPU): Ascend Software Environment: -- MindSpore version (source or binary): 1.6.0 -- Python version (e.g., Python 3.7.5): 3.7.6 -- OS platform and distribution (e.g., Linux Ubuntu 16.04): Ubuntu 4.15.0-74-generic -- GCC/Compiler version (if compiled from source):
训练脚本是通过构建Pow的单算子网络,对第一个输入的每个值进行幂运算。脚本如下:
class Net(nn.Cell): def __init__(self): super(Net, self).__init__() self.pow = ops.Pow() def construct(self, x,y): output = self.pow(x, y) return output net = Net() x = Tensor(np.array([1.0, 2.0, 4.0]), mindspore.float64) .astype(mindspore.float32) y = 3.0 output = net(x, y) print('output', output)
报错信息如下:
Traceback (most recent call last): File 'demo.py', line 11, in <module> output = net(x, y) … TypeError: mindspore/ccsrc/runtime/device/ascend/kernel_select_ascend.cc:788 PrintNotMatchMessage] Can not select a valid kernel info for [Default/Pow-op0] in AI CORE or AI CPU kernel info candidates list: AI CORE: (<Int8xDefaultFormat>, <Int8xDefaultFormat>) -> (<Int8xDefaultFormat>) (<UInt8xDefaultFormat>, <UInt8xDefaultFormat>) -> (<UInt8xDefaultFormat>) (<Int32xDefaultFormat>, <Int32xDefaultFormat>) -> (<Int32xDefaultFormat>) (<Float16xDefaultFormat>, <Float16xDefaultFormat>) -> (<Float16xDefaultFormat>) (<Float32xDefaultFormat>, <Float32xDefaultFormat>) -> (<Float32xDefaultFormat>) AI CPU: {} Please check the given data type or shape: AI CORE: : (<Tensor[Float64], (3)>, <Tensor[Float64], (), value=...>) -> (<Tensor[Float64], (3)>) AI CPU: : (<Tensor[Float64], (3)>, <Tensor[Float64], (), value=...>) -> (<Tensor[Float64], (3)>) For more details, please refer to 'Kernel Select Failed' at https://www.mindspore.cn The function call stack: In file demo.py(06)/ output = self.pow(x, y)/
原因分析
在TypeError中,Can not select a valid kernel info for [Default/Pow-op0] in AI CORE or AI CPU kernel info candidates list,结合列出的数据类型格式,判断为在提示传入的数据类型不在支持的类型范围内,支持的数据类型为:int8、uint8、int32、float16、float32,再结合*Please check the given data type or shape:AI CORE : (<Tensor[Float64], (3)>*可知,传入的数据类型为float64, 检查代码发现,x = Tensor(np.array([1.0, 2.0, 4.0]), mindspore.float64) .astype(mindspore.float32)代码的输入数据类型确实为float64,此时需要将该类型转化为其他支持类型。
参考文档:Pow算子API接口
解决措施
基于以上原因,修改训练脚本:
执行训练。成功后输出如下:
output [ 1. 8. 64.]
本页内容