使用CPU 进行inference 报错
Created by: dancingpipi
1)PaddlePaddle版本:fluid 1.4 2)CPU:Intel(R) Xeon(R) Gold 5117 CPU @ 2.00GHz 3)GPU:P4 4)系统环境:Ubuntu16.04 -预测信息 1)C++预测: GIT COMMIT ID: ef02d060 WITH_MKL: OFF WITH_MKLDNN: OFF WITH_GPU: ON CUDA version: 8.0 CUDNN version: v7
2)CMake包含路径的完整命令:
cmake -DFLUID_INFERENCE_INSTALL_DIR=$PADDLE_ROOT
-DCMAKE_BUILD_TYPE=Release
-DWITH_FLUID_ONLY=ON
-DWITH_PYTHON=OFF
-DWITH_MKL=OFF
-DWITH_MKLDNN=OFF
-DWITH_GPU=ON
-DON_INFER=ON
..
3)API信息(如调用请提供): config.DisableGpu();
4)预测库来源:docker镜像,源码编译
config.EnableUseGpu(1000, 0 /*gpu_id*/);
进行inference的时候能得到正确的结果,当使用CPU模式:
config.DisableGpu();
会发生错误:
terminate called after throwing an instance of 'paddle::platform::EnforceNotMet'
what(): Enforce failed. Expected static_cast<int>(ins[i]->numel() / x_dims[0]) == w, but received static_cast<int>(ins[i]->numel() / x_dims[0]):256 != w:1024.
Width of all inputs should be equal. at [/home/paddle_tensorrt/Paddle/paddle/fluid/operators/fused/fusion_seqpool_concat_op.cc:111]
PaddlePaddle Call Stacks:
0 0x7ff404a6b7ffp void paddle::platform::EnforceNotMet::Init<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, char const*, int) + 1519
1 0x7ff404a6cee7p paddle::platform::EnforceNotMet::EnforceNotMet(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int) + 183
2 0x7ff404eef8e3p paddle::operators::FusionSeqPoolConcatKernel<float>::Compute(paddle::framework::ExecutionContext const&) const + 5299
3 0x7ff404ef01efp std::_Function_handler<void (paddle::framework::ExecutionContext const&), paddle::framework::OpKernelRegistrarFunctor<paddle::platform::CPUPlace, false, 0ul, paddle::operators::FusionSeqPoolConcatKernel<float>, paddle::operators::FusionSeqPoolConcatKernel<double> >::operator()(char const*, char const*, int) const::{lambda(paddle::framework::ExecutionContext const&)#1}>::_M_invoke(std::_Any_data const&, paddle::framework::ExecutionContext const&) + 47
4 0x7ff40659eac7p paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, boost::variant<paddle::platform::CUDAPlace, paddle::platform::CPUPlace, paddle::platform::CUDAPinnedPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&, paddle::framework::RuntimeContext*) const + 983
5 0x7ff40659f9d3p paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, boost::variant<paddle::platform::CUDAPlace, paddle::platform::CPUPlace, paddle::platform::CUDAPinnedPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&) const + 339
6 0x7ff4065991eep paddle::framework::OperatorBase::Run(paddle::framework::Scope const&, boost::variant<paddle::platform::CUDAPlace, paddle::platform::CPUPlace, paddle::platform::CUDAPinnedPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&) + 318
7 0x7ff404be58fap paddle::framework::NaiveExecutor::Run() + 234
8 0x7ff404a7ee9cp paddle::AnalysisPredictor::Run(std::vector<paddle::PaddleTensor, std::allocator<paddle::PaddleTensor> > const&, std::vector<paddle::PaddleTensor, std::allocator<paddle::PaddleTensor> >*, int) + 300
9 0x402d93p
10 0x403592p
11 0x7ff403360830p __libc_start_main + 240
12 0x401c59p
4、尝试过以 以下方式重新编译paddle inference c++库:
- cmake信息
GIT COMMIT ID: ef02d06055c79ae9ee11ea9b89520d7185e53482
WITH_MKL: ON
WITH_MKLDNN: ON
WITH_GPU: OFF
结果
terminate called after throwing an instance of 'paddle::platform::EnforceNotMet'
what(): Enforce failed. Expected static_cast<int>(ins[i]->numel() / x_dims[0]) == w, but received static_cast<int>(ins[i]->numel() / x_dims[0]):256 != w:1024.
Width of all inputs should be equal. at [/home/paddle_tensorrt/Paddle/paddle/fluid/operators/fused/fusion_seqpool_concat_op.cc:111]
PaddlePaddle Call Stacks:
0 0x7f0c191e293fp void paddle::platform::EnforceNotMet::Init<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, char const*, int) + 1519
1 0x7f0c191e4027p paddle::platform::EnforceNotMet::EnforceNotMet(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int) + 183
2 0x7f0c1956259ep paddle::operators::FusionSeqPoolConcatKernel<float>::Compute(paddle::framework::ExecutionContext const&) const + 2302
3 0x7f0c1956308fp std::_Function_handler<void (paddle::framework::ExecutionContext const&), paddle::framework::OpKernelRegistrarFunctor<paddle::platform::CPUPlace, false, 0ul, paddle::operators::FusionSeqPoolConcatKernel<float>, paddle::operators::FusionSeqPoolConcatKernel<double> >::operator()(char const*, char const*, int) const::{lambda(paddle::framework::ExecutionContext const&)#1}>::_M_invoke(std::_Any_data const&, paddle::framework::ExecutionContext const&) + 47
4 0x7f0c1a16bb31p paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, boost::variant<paddle::platform::CUDAPlace, paddle::platform::CPUPlace, paddle::platform::CUDAPinnedPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&, paddle::framework::RuntimeContext*) const + 753
5 0x7f0c1a16cb83p paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, boost::variant<paddle::platform::CUDAPlace, paddle::platform::CPUPlace, paddle::platform::CUDAPinnedPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&) const + 339
6 0x7f0c1a16640bp paddle::framework::OperatorBase::Run(paddle::framework::Scope const&, boost::variant<paddle::platform::CUDAPlace, paddle::platform::CPUPlace, paddle::platform::CUDAPinnedPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&) + 267
7 0x7f0c193872fap paddle::framework::NaiveExecutor::Run() + 234
8 0x7f0c191f4eccp paddle::AnalysisPredictor::Run(std::vector<paddle::PaddleTensor, std::allocator<paddle::PaddleTensor> > const&, std::vector<paddle::PaddleTensor, std::allocator<paddle::PaddleTensor> >*, int) + 300
9 0x402ff3p
10 0x4037f2p
11 0x7f0c180fc830p __libc_start_main + 240
12 0x401eb9p
- cmake信息
GIT COMMIT ID: ef02d06055c79ae9ee11ea9b89520d7185e53482
WITH_MKL: ON
WITH_MKLDNN: ON
WITH_GPU: ON
CUDA version: 8.0
CUDNN version: v7
结果:同上
- cmake信息
GIT COMMIT ID: ef02d06055c79ae9ee11ea9b89520d7185e53482
WITH_MKL: OFF
WITH_MKLDNN: OFF
WITH_GPU: OFF
结果:
/home/paddle_tensorrt/fluid_inference_1.4_rebuild_gpu_off_mkl_off/paddle/lib/libpaddle_fluid.so: undefined reference to `dlsym'
/home/paddle_tensorrt/fluid_inference_1.4_rebuild_gpu_off_mkl_off/paddle/lib/libpaddle_fluid.so: undefined reference to `dlopen'
/home/paddle_tensorrt/fluid_inference_1.4_rebuild_gpu_off_mkl_off/paddle/lib/libpaddle_fluid.so: undefined reference to `dlerror'
/home/paddle_tensorrt/fluid_inference_1.4_rebuild_gpu_off_mkl_off/paddle/lib/libpaddle_fluid.so: undefined reference to `dladdr'
collect2: error: ld returned 1 exit status
CMakeFiles/attention_lstm.dir/build.make:94: recipe for target 'attention_lstm' failed
make[2]: *** [attention_lstm] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/attention_lstm.dir/all' failed
make[1]: *** [CMakeFiles/attention_lstm.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
请问如何能够正确的进行CPU的inference?