pytorch -> onnx ->paddle 在AIStudio中无法运行报错 Error: op conv2d does not have kernel for data_type
Created by: iceriver97
我想知道是哪一步出了问题,万分感谢你们能帮助我! 导出模型:
# solver为自己的模型,log01_dink34.th 为之前训练的文件;
solver = TTAFrame(DinkNet34)
solver.load('weights/log01_dink34.th')
# 我不太确定这里dummy_input 是否设置正确:训练的图片为1024*1024的彩色图
dummy_input = torch.randn(1, 3, 1024, 1024)
torch.onnx.export(solver, dummy_input, "deepG.onnx", verbose=True)
这里是权重文件: 链接:https://pan.baidu.com/s/1f5w0Av27603KyjJ7g7ga5A 提取码:f4nv 这里是模型文件: 链接:https://pan.baidu.com/s/1afHPHTAn5l5o_rj7PhS6zw 提取码:f52u
AIStudio中的代码为:
infer_save_path = "/home/aistudio/work/DeepG_model/pd_model"
# place = fluid.CUDAPlace(0)
place = fluid.CPUPlace()
exe = fluid.Executor(place)
[inference_program, feed_target_names, fetch_targets] = fluid.io.load_inference_model(dirname=infer_save_path, executor=exe, model_filename=None, params_filename='__params__')
img = cv2.imread("/home/aistudio/dataset/test/666005_sat.jpg")
origin = img
img = np.array(img)
output = exe.run(inference_program,
feed={feed_target_names[0]: img},
fetch_list=fetch_targets)
output = output[0][0]
output = output.transpose(1, 2, 0)
cv2.imwrite('origin.jpg', origin)
cv2.imwrite('result.jpg', output)
print("运行结束,origin为预测图片,result为分割后的图片")
运行信息如下: Traceback (most recent call last): File "infer.py", line 17, in fetch_list=fetch_targets) File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/executor.py", line 1071, in run six.reraise(*sys.exc_info()) File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/six.py", line 703, in reraise raise value File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/executor.py", line 1066, in run return_merged=return_merged) File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/executor.py", line 1154, in _run_impl use_program_cache=use_program_cache) File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/executor.py", line 1229, in _run_program fetch_var_name) paddle.fluid.core_avx.EnforceNotMet:
C++ Call Stacks (More useful to developers):
0 std::string paddle::platform::GetTraceBackStringstd::string(std::string&&, char const*, int) 1 paddle::platform::EnforceNotMet::EnforceNotMet(paddle::platform::ErrorSummary const&, char const*, int) 2 paddle::framework::OperatorWithKernel::ChooseKernel(paddle::framework::RuntimeContext const&, paddle::framework::Scope const&, paddle::platform::Place const&) const 3 paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, paddle::platform::Place const&, paddle::framework::RuntimeContext*) const 4 paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, paddle::platform::Place const&) const 5 paddle::framework::OperatorBase::Run(paddle::framework::Scope const&, paddle::platform::Place const&) 6 paddle::framework::Executor::RunPartialPreparedContext(paddle::framework::ExecutorPrepareContext*, paddle::framework::Scope*, long, long, bool, bool, bool) 7 paddle::framework::Executor::RunPreparedContext(paddle::framework::ExecutorPrepareContext*, paddle::framework::Scope*, bool, bool, bool) 8 paddle::framework::Executor::Run(paddle::framework::ProgramDesc const&, paddle::framework::Scope*, int, bool, bool, std::vector<std::string, std::allocatorstd::string > const&, bool, bool)
Python Call Stacks (More useful to users):
File "d:\anaconda\envs\py35-pp\lib\site-packages\paddle\fluid\framework.py", line 2610, in append_op attrs=kwargs.get("attrs", None)) File "d:\anaconda\envs\py35-pp\lib\site-packages\paddle\fluid\layer_helper.py", line 43, in append_op return self.main_program.current_block().append_op(*args, **kwargs) File "d:\anaconda\envs\py35-pp\lib\site-packages\paddle\fluid\layers\nn.py", line 2938, in conv2d "data_format": data_format, File "pd_model\model_with_code\model.py", line 273, in x2paddle_net x2paddle_629 = fluid.layers.conv2d(x2paddle_0, num_filters=64, padding=[3, 3], dilation=[1, 1], bias_attr=False, param_attr='x2paddle_firstconv_weight', name='x2paddle_629', groups=1, filter_size=[7, 7], stride=[2, 2]) File "d:\anaconda\envs\py35-pp\lib\site-packages\x2paddle\core\op_mapper.py", line 142, in save_inference_model inputs, outputs = model.x2paddle_net() File "d:\anaconda\envs\py35-pp\lib\site-packages\x2paddle\convert.py", line 191, in onnx2paddle mapper.save_inference_model(save_dir, params_merge) File "d:\anaconda\envs\py35-pp\lib\site-packages\x2paddle\convert.py", line 268, in main onnx2paddle(args.model, args.save_dir, params_merge) File "D:\Anaconda\envs\py35-pp\Scripts\x2paddle.exe_main_.py", line 9, in sys.exit(main()) File "d:\anaconda\envs\py35-pp\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "d:\anaconda\envs\py35-pp\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec)
Error Message Summary:
Error: op conv2d does not have kernel for data_type[uint8_t]:data_layout[ANY_LAYOUT]:place[CPUPlace]:library_type[PLAIN] at (/paddle/paddle/fluid/framework/operator.cc:1081) [operator < conv2d > error]