1 Error description
1.1 System Environment
Hardware Environment(Ascend/GPU/CPU): CPU
Software Environment:
– MindSpore version (source or binary): 1.8.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):
1.2 Basic information
1.2.1 Script
Call the ResizeBilinear operator to adjust the input Tensor to the specified size using bilinear interpolation. The script is as follows:
01 context.set_context(device_target='CPU')
02 x = Tensor([[[[1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]]], mindspore.float32)
03 resize_bilinear = ops.ResizeBilinear((5, 5), half_pixel_centers=True)
04 output = resize_bilinear(x)
05 print(output)
1.2.2 Error reporting
The error message here is as follows:
Traceback (most recent call last):
File "C:/Users/l30026544/PycharmProjects/q2_map/new/ResizeBilinear.py", line 7, in <module>
resize_bilinear = ops.ResizeBilinear((5, 5), half_pixel_centers=True)
File "C:\Users\l30026544\PycharmProjects\q2_map\lib\site-packages\mindspore\ops\primitive.py", line 687, in deco
fn(self, *args, **kwargs)
File "C:\Users\l30026544\PycharmProjects\q2_map\lib\site-packages\mindspore\ops\operations\nn_ops.py", line 3263, in __init__
raise ValueError(f"Currently `half_pixel_centers`=True only support in Ascend device_target, "
ValueError: Currently `half_pixel_centers`=True only support in Ascend device_target, but got CPU
Cause Analysis
Let’s look at the error message. In ValueError, write Current half_pixel_centers
=True only support in Ascend device_target, but got CPU, which means that only the half_pixel_centers property can be set to True in the Ascend environment. The official website API explains this:
2 Solutions
For the reasons known above, it is easy to make the following modifications:
01 context.set_context(device_target='Ascend')
02 x = Tensor([[[[1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]]], mindspore.float32)
03 resize_bilinear = ops.ResizeBilinear((5, 5), half_pixel_centers=True)
04 output = resize_bilinear(x)
05 print(output)
At this point, the execution is successful, and the output is as follows:
[[[[1. 2. 3. 4. 5.]
[1. 2. 3. 4. 5.]
[1. 2. 3. 4. 5.]
[1. 2. 3. 4. 5.]
[1. 2. 3. 4. 5.]]]]
3 Summary
Steps to locate the error report:
1. Find the line of user code that reports the error: * resize_bilinear = ops.ResizeBilinear((5, 5), half_pixel_centers=True)*;
2. According to the keywords in the log error message, narrow down the scope of the analysis problem. Currently half_pixel_centers
=True only support in Ascend device_target, but got CPU ;
Read More:
- [Solved] MindSpore Error: ReduceMean in the Ascend environment does not support inputs of 8 or more dimensions
- [Solved] MindSpore Error: StridedSlice operator does not support input of uint8 data type on Ascend hardware
- [Solved] MindSpore Error: ValueError: `padding_idx` in `Embedding` out of range
- [Solved] MindSpore Error: Should not use Python in runtime
- [Solved] MindSpore Error: TypeError: For ‘TopK’, the type of ‘x’ should be…
- [Solved] MindSpore Error: For ‘MirrorPad‘, paddings must be a Tensor with *
- [Solved] MindSpore Error: For primitive[TensorSummary], the v rank Must be greater than or equal to 0
- [Solved] MindSpore infer error when passing in sens values for derivation: For ‘MatMul’, the input dimensions
- [Solved] MindSpore Error: For ‘CellList’, each cell should be subclass of Cell
- [Solved] MindSpore Error: ValueError: For ‘AvgPool’ every dimension of the output shape must be greater than zero
- [Solved] MindSpore Error: ValueError: Minimum inputs size 0 does not match…
- [Solved] MindSpore Error: Select GPU kernel op * fail! Incompatible data type
- [Solved] MindSpore Error: Data type conversion of ‘Parameter’ is not supporte
- [Solved] MindSpore Error: task_fail_info or current_graph_ is nullptr
- [Solved] MindSpore Error: “ValueError:invalid literal for int()with base10’the’
- [Solved] MindSpore Network custom reverse error: TypeError: The params of function ‘bprop’ of
- [Solved] MindSpore Error: “TypeError: parse() missing 1 required positional.”
- ROS Error: warning: “deprecated pixel format used“
- [Solved] MindSpore Error: “GeneratorDataset’s num_workers=8, this value is …”