1 Error description
1.1 System Environment
Hardware Environment(Ascend/GPU/CPU): Ascend
Software Environment:
– MindSpore version (source or binary): 1.8.0
– Python version (eg, Python 3.7.5): 3.7.6
– OS platform and distribution (eg, Linux Ubuntu 16.04): Ubuntu 4.15.0-74-generic
– GCC/Compiler version (if compiled from source):
1.2 Basic information
1.2.1 Script
The training script is to average and reduce axis1 by constructing the ReduceMean operator network. The script is as follows:
01 class Net(nn.Cell):
02 def __init__(self, axis, keep_dims):
03 super().__init__()
04 self.reducemean = ops.ReduceMean(keep_dims=keep_dims)
05 self.axis = axis
06 def construct(self, input_x):
07 return self.reducemean(input_x, self.axis)
08 net = Net(axis=(1,), keep_dims=True)
09 x = Tensor(np.random.randn(1, 2, 3, 4, 5, 6, 7, 8, 9), mindspore.float32)
10 out = net(x)
11 print("out shape: ", out.shape)
1.2.2 Error reporting
The error message here is as follows:
Traceback (most recent call last):
File "test.py", line 18, in <module>
out = net(x)
File "/root/archiconda3/envs/lh37_ascend/lib/python3.7/site-packages/mindspore/nn/cell.py", line 574, in __call__
out = self.compile_and_run(*args)
File "/root/archiconda3/envs/lh37_ascend/lib/python3.7/site-packages/mindspore/nn/cell.py", line 975, in compile_and_run
self.compile(*inputs)
File "/root/archiconda3/envs/lh37_ascend/lib/python3.7/site-packages/mindspore/nn/cell.py", line 948, in compile
jit_config_dict=self._jit_config_dict)
File "/root/archiconda3/envs/lh37_ascend/lib/python3.7/site-packages/mindspore/common/api.py", line 1092, in compile
result = self._graph_executor.compile(obj, args_list, phase, self._use_vm_mode())
RuntimeError: Single op compile failed, op: reduce_mean_d_1629966128061146056_6
except_msg: 2022-07-15 01:36:29.720449: Query except_msg:Traceback (most recent call last):
File "/root/archiconda3/envs/lh37_ascend/lib/python3.7/site-packages/te_fusion/parallel_compilation.py", line 1469, in run
relation_param=self._relation_param)
File "/root/archiconda3/envs/lh37_ascend/lib/python3.7/site-packages/te_fusion/fusion_manager.py", line 1283, in build_single_op
compile_info = call_op()
File "/root/archiconda3/envs/lh37_ascend/lib/python3.7/site-packages/te_fusion/fusion_manager.py", line 1270, in call_op
opfunc(*inputs, *outputs, *new_attrs, **kwargs)
File "/root/archiconda3/envs/lh37_ascend/lib/python3.7/site-packages/tbe/common/utils/para_check.py", line 537, in _in_wrapper
formal_parameter_list[i][1], op_name)
File "/root/archiconda3/envs/lh37_ascend/lib/python3.7/site-packages/tbe/common/utils/para_check.py", line 516, in _check_one_op_param
_check_input(op_param, param_name, param_type, op_name)
File "/root/archiconda3/envs/lh37_ascend/lib/python3.7/site-packages/tbe/common/utils/para_check.py", line 299, in _check_input
_check_input_output_dict(op_param, param_name, op_name)
File "/root/archiconda3/envs/lh37_ascend/lib/python3.7/site-packages/tbe/common/utils/para_check.py", line 223, in _check_input_output_dict
param_name=param_name)
File "/root/archiconda3/envs/lh37_ascend/lib/python3.7/site-packages/tbe/common/utils/para_check.py", line 689, in check_shape
_check_shape_range(max_rank, min_rank, param_name, shape)
File "/root/archiconda3/envs/lh37_ascend/lib/python3.7/site-packages/tbe/common/utils/para_check.py", line 727, in _check_shape_range
% (error_info['param_name'], min_rank, max_rank, len(shape)))
RuntimeError: ({'errCode': 'E80012', 'op_name': 'reduce_mean_d', 'param_name': 'input_x', 'min_value': 0, 'max_value': 8, 'real_value': 9}, 'In op, the num of dimensions of input/output[input_x] should be inthe range of [0, 8], but actually is [9].')
Cause Analysis
Let’s look at the error message. In RuntimeError, ‘In op, the num of dimensions of input/output[input_x] should be in the range of [0, 8], but actually is [9].’ means that the input of ReduceMean is a dimension It should be greater than or equal to 0 and less than or equal to 8, but the actual value is 9, which obviously exceeds the dimension supported by the ReduceMean operator. In the official website, ReduceSum also made a description of the input dimension limitation:
2 Solutions
For the reasons known above, it is easy to make the following modifications:
01 class Net(nn.Cell):
02 def __init__(self, axis, keep_dims):
03 super().__init__()
04 self.reducemean = ops.ReduceMean(keep_dims=keep_dims)
05 self.axis = axis
06 def construct(self, input_x):
07 return self.reducemean(input_x, self.axis)
08 net = Net(axis=(1,), keep_dims=True)
09 x = Tensor(np.random.randn(2, 3, 4, 5, 6, 7, 8, 9), mindspore.float32)
10 out = net(x)
11 print("out shape: ", out.shape)
At this point, the execution is successful, and the output is as follows:
out shape: (2, 1, 4, 5, 6, 7, 8, 9)
3 Summary
Steps to locate the error report:
1. Find the user code line that reports the error: out = net(x);
2. According to the keywords in the log error message, narrow the scope of the analysis problem: should be in the range of [0, 8] , but actually is [10];
3. Focus on the correctness of variable definition and initialization.
Read More:
- [Solved] MindSpore Error: StridedSlice operator does not support input of uint8 data type on Ascend hardware
- [Solved] MindSpore Error: `half_pixel_centers`=True only support in Ascend
- [Solved] MindSpore Error: ValueError: Minimum inputs size 0 does not match…
- [Solved] MindSpore infer error when passing in sens values for derivation: For ‘MatMul’, the input dimensions
- [Solved] MindSpore Error: task_fail_info or current_graph_ is nullptr
- [Solved] MindSpore Error: For primitive[TensorSummary], the v rank Must be greater than or equal to 0
- [Solved] MindSpore Error: Data type conversion of ‘Parameter’ is not supporte
- [Solved] MindSpore Error: ValueError: For ‘AvgPool’ every dimension of the output shape must be greater than zero
- [Solved] MindSpore Error: ValueError: `padding_idx` in `Embedding` out of range
- [Solved] MindSpore Error: Should not use Python in runtime
- [Solved] MindSpore Error: For ‘MirrorPad‘, paddings must be a Tensor with *
- [Solved] MindSpore Error: TypeError: For ‘TopK’, the type of ‘x’ should be…
- [Solved] MindSpore Error: Select GPU kernel op * fail! Incompatible data type
- [Solved] MindSpore Error: For ‘CellList’, each cell should be subclass of Cell
- [Solved] matlab Error: Error in port widths or dimensions. ‘Output Port 1‘ of ‘sl_arm_ibvs/camera‘
- [Solved] MindSpore Network custom reverse error: TypeError: The params of function ‘bprop’ of
- flask init-db Error: Error: Could not locate a Flask application. Use the ‘flask –app’ option, ‘FLASK_APP’ environment variable, or a ‘wsgi.py’ or ‘app.py’ file in the current directory.
- Cmake Setting Support C++11 This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options
- [Solved] MindSpore Error: “TypeError: parse() missing 1 required positional.”