×

签到

分享到微信

打开微信,使用扫一扫进入页面后,点击右上角菜单,

点击“发送给朋友”或“分享到朋友圈”完成分享

STDC-seg适配270板卡问题 已完结 ZHhaowei2023-04-12 15:09:17 回复 10 查看 技术答疑 使用求助
STDC-seg适配270板卡问题
分享到:

我把stdc-seg模型在cpu上量化之后在mlu上推理报错如下

源码:

# 模型量化

            qconfig = {'use_avg': False, 'data_scale': 1.0, 'firstconv': False, 'per_channel': False}

            quantized_model = mlu_quantize.quantize_dynamic_mlu(net, qconfig_spec=qconfig, dtype='int8', gen_quant=True)

            quantized_model = quantized_model.eval()

            res = quantized_model(imgs.to(device))

            torch.save(quantized_model.state_dict(), 'model_quantized.pth')


            corenum=1

            mcore='MLU270'


            net.float().eval()

            quantized_model = mlu_quantize.quantize_dynamic_mlu(net)

            state_dict = torch.load("model_quantized.pth")

            quantized_model.load_state_dict(state_dict, strict=True)

            quantized_model.eval()

            res = quantized_model(imgs.to(device))

            quantized_model.to(ct.mlu_device())


           

            ct.save_as_cambricon('stdc_cambrion')

            torch.set_grad_enabled(False)

            ct.set_core_number(corenum)

            ct.set_core_version(mcore)


            input_mlu_data = imgs.to(ct.mlu_device())

            pred = quantized_model(input_mlu_data)

            print(pred)




报错:

2023-04-12 14:27:03.064035: [cnmlError] Internal type: MLU::concat_byshape, Op name: UNSET dimension mismatch,output shape is wrong, the given shape is:(n=1, c=6,h=1,w=1, d=0, t=0, data in array:{1, 1, 1, 6, } , but the expected shape is:(n=2, c=3,h=1,w=1, d=0, t=0, data in array:{2, 1, 1, 3, }

2023-04-12 14:27:03.064116: [cnmlError] Internal type: MLU::concat_byshape, Op name: UNSET, Op update tensor shape failed

[ERROR][/pytorch/catch/torch_mlu/csrc/aten/operators/cnml/internal/concat_internal.cpp][line:135][cnml_concat_internal][thread:139925537765184][process:1663]:

CNML error: CNML_STATUS_INVALIDPARAM

[WARNING][/pytorch/catch/torch_mlu/csrc/aten/operators/op_methods.cpp][line:2289][cat][thread:139925537765184][process:1663]:

cat Op cannot run on MLU device, start running on CPU!

2023-04-12 14:27:03.657976: [cnmlError] Internal type: MLU::dyadic_all, Op name: UNSET dimension mismatch,output shape is wrong, the given shape is:(n=1, c=216,h=1,w=1, d=0, t=0, data in array:{1, 1, 1, 216, } , but the expected shape is:(n=216, c=1,h=1,w=1, d=0, t=0, data in array:{216, 1, 1, 1, }

2023-04-12 14:27:03.658102: [cnmlError] Internal type: MLU::dyadic_all, Op name: UNSET, Op update tensor shape failed

[ERROR][/pytorch/catch/torch_mlu/csrc/aten/operators/cnml/internal/eq_internal.cpp][line:35][cnml_eq_internal][thread:139925537765184][process:1663]:

CNML error: CNML_STATUS_INVALIDPARAM

[WARNING][/pytorch/catch/torch_mlu/csrc/aten/operators/op_methods.cpp][line:1217][eq][thread:139925537765184][process:1663]:

eq Op cannot run on MLU device, start running on CPU!

2023-04-12 14:27:03.660598: [cnmlError] Internal type: MLU::unary, Op name: UNSET dimension mismatch,output shape is wrong, the given shape is:(n=1, c=216,h=1,w=1, d=0, t=0, data in array:{1, 1, 1, 216, } , but the expected shape is:(n=216, c=1,h=1,w=1, d=0, t=0, data in array:{216, 1, 1, 1, }

2023-04-12 14:27:03.660675: [cnmlError] Internal type: MLU::unary, Op name: UNSET, Op update tensor shape failed

[ERROR][/pytorch/catch/torch_mlu/csrc/aten/operators/cnml/internal/abs_internal.cpp][line:30][cnml_abs_internal][thread:139925537765184][process:1663]:

CNML error: CNML_STATUS_INVALIDPARAM

[WARNING][/pytorch/catch/torch_mlu/csrc/aten/operators/op_methods.cpp][line:424][abs][thread:139925537765184][process:1663]:

abs Op cannot run on MLU device, start running on CPU!

2023-04-12 14:27:03.686801: [cnmlError] Internal type: MLU::dyadic_all, Op name: UNSET, Op should follow these rules: input1_n == input2_n, now, input1_n=216, input2_n=1op_id:926

2023-04-12 14:27:03.686933: [cnmlError] Internal type: MLU::dyadic_all, Op name: UNSET, Op dimension mismatch

[ERROR][/pytorch/catch/torch_mlu/csrc/aten/operators/cnml/internal/ne_internal.cpp][line:38][cnml_ne_internal][thread:139925537765184][process:1663]:

CNML error: CNML_STATUS_INVALIDPARAM

[WARNING][/pytorch/catch/torch_mlu/csrc/aten/operators/op_methods.cpp][line:459][ne][thread:139925537765184][process:1663]:

ne Op cannot run on MLU device, start running on CPU!

[WARNING][/pytorch/catch/torch_mlu/csrc/aten/operators/op_methods.cpp][line:3291][masked_select][thread:139925537765184][process:1663]:

masked_select Op cannot run on MLU device, start running on CPU!

Traceback (most recent call last):

  File "evaluation.py", line 323, in <module>

    use_boundary_2=False, use_boundary_4=False, use_boundary_8=True, use_boundary_16=False)

  File "evaluation.py", line 144, in evaluatev0

    mIOU = single_scale(net, dl, 19)

  File "evaluation.py", line 83, in __call__

    print(pred)

  File "/torch/venv3/pytorch/lib/python3.6/site-packages/torch/tensor.py", line 123, in __repr__

    return torch._tensor_str._str(self)

  File "/torch/venv3/pytorch/lib/python3.6/site-packages/torch/_tensor_str.py", line 311, in _str

    tensor_str = _tensor_str(self, indent)

  File "/torch/venv3/pytorch/lib/python3.6/site-packages/torch/_tensor_str.py", line 209, in _tensor_str

    formatter = _Formatter(get_summarized_data(self) if summarize else self)

  File "/torch/venv3/pytorch/lib/python3.6/site-packages/torch/_tensor_str.py", line 87, in __init__

    nonzero_finite_vals = torch.masked_select(tensor_view, torch.isfinite(tensor_view) & tensor_view.ne(0))

RuntimeError: Expected of scalar type Bool but got scalar type Float for argument #2 'mask' in call to _th_masked_select_bool


版权所有 © 2024 寒武纪 Cambricon.com 备案/许可证号:京ICP备17003415号-1
关闭