You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
By clicking “Sign up for GitHub”, you agree to our
terms of service
and
privacy statement
. We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
c++ 推理错误 NotFoundError: Operator (transpose2) does not have kernel for data_type[double]:data_layout
#6638
c++ 推理错误 NotFoundError: Operator (transpose2) does not have kernel for data_type[double]:data_layout
dtiny
opened this issue
Jun 20, 2022
· 3 comments
训练算法:starnet_r34_vd_tps_bilstm_ctc.yml
训练语言:python
模型导出:参考python3 tools/export_model.py -c configs/rec/rec_r34_vd_tps_bilstm_ctc.yml -o Global.pretrained_model=./rec_r34_vd_tps_bilstm_ctc_v2.0_train/best_accuracy Global.save_inference_dir=./inference/rec_starnet
不同点在于我训练的时候使用图片输入尺寸为[3,24,192],可以不报异常导出模型参数。
python推理测试:使用导出模型参数可以正确得到推理结果。
c++推理:按照demo,更改了输入尺寸为[3,24,192],模型的初始化,数据处理都正常,但在执行this->predictor_->Run()这句时候保存。错误信息如下:
C++ Traceback (most recent call last):
0 paddle::AnalysisPredictor::ZeroCopyRun()
1 paddle::framework::NaiveExecutor::Run()
2 paddle::framework::OperatorBase::Run(paddle::framework::Scope const&, paddle::platform::Place const&)
3 paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, paddle::platform::Place const&) const
4 paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, paddle::platform::Place const&, paddle::framework::RuntimeContext*) const
5 paddle::framework::OperatorWithKernel::ChooseKernel(paddle::framework::RuntimeContext const&, paddle::framework::Scope const&, paddle::platform::Place const&) const
6 paddle::platform::EnforceNotMet::EnforceNotMet(paddle::platform::ErrorSummary const&, char const*, int)
7 paddle::platform::GetCurrentTraceBackString[abi:cxx11]
NotFoundError: Operator (transpose2) does not have kernel for data_type[double]:data_layout[ANY_LAYOUT]:place[CPUPlace]:library_type[PLAIN].
[Hint: Expected kernel_iter != kernels.end(), but received kernel_iter == kernels.end().] (at /paddle/paddle/fluid/framework/operator.cc:1236)
[operator < transpose2 > error]
Aborted (core
dumped)
另外,官方文档说支持转onnx,但是实际测试下来,rec_r34_vd_none_bilstm_ctc_v2.0是成功的,但是rec_r34_vd_tps_bilstm_ctc_v2.0在转换的时候也是失败的,转换命令和错误信息如下:
命令:paddle2onnx --model_dir ./pp_models/rec_r34_vd_tps_bilstm_ctc_v2.0_train
--model_filename pp_models/rec_r34_vd_tps_bilstm_ctc_v2.0_train/inference.pdmodel
--params_filename pp_models/rec_r34_vd_tps_bilstm_ctc_v2.0_train/inference.pdiparams
--save_file ./pp_models/rec_r34_vd_tps_bilstm_ctc_v2.0_train/model.onnx
--opset_version 10
--input_shape_dict="{'x':[-1,3,-1,-1]}"
--enable_onnx_checker True
2022-06-16 16:02:39 [WARNING] [Deprecated]
paddle2onnx.command.program2onnx
will be deprecated in the future version, the recommended usage is
paddle2onnx.export
Traceback (most recent call last):
File "/root/anaconda3/envs/paddle_det/bin/paddle2onnx", line 8, in
sys.exit(main())
File "/root/anaconda3/envs/paddle_det/lib/python3.8/site-packages/paddle2onnx/command.py", line 214, in main
program2onnx(
File "/root/anaconda3/envs/paddle_det/lib/python3.8/site-packages/paddle2onnx/command.py", line 145, in program2onnx
return program2onnx(model_dir, save_file, model_filename, params_filename,
File "/root/anaconda3/envs/paddle_det/lib/python3.8/site-packages/paddle2onnx/legacy/command.py", line 199, in program2onnx
program.blocks[0].ops[i].desc.infer_shape(program.blocks[0].desc)
ValueError: (InvalidArgument) Dims of all Inputs(X) must be the same, but received input 1 dim is:10 not equal to input 0 dim:-1.
[Hint: Expected input_dims[i] == input_dims[0], but received input_dims[i]:10 != input_dims[0]:-1.] (at /paddle/paddle/phi/infermeta/multiary.cc:1803)
[operator < stack > error]