Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

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

capi sequence方式调用出core #3590

Closed
fty8788 opened this issue Aug 21, 2017 · 8 comments
Closed

capi sequence方式调用出core #3590

fty8788 opened this issue Aug 21, 2017 · 8 comments

Comments

@fty8788
Copy link

fty8788 commented Aug 21, 2017

仿照Paddle/paddle/capi/examples/model_inference/sequence/main.c的代码,改成DSSM模型的预测程序,input是两个ids:

CHECK(paddle_arguments_resize(in_args, 2));

  // Create input ids.
  int sentence_ids[] = {83, 48, 20, 84, 394, 853, 64, 53, 94};

  paddle_ivector sentence0 = paddle_ivector_create(
      sentence_ids, sizeof(sentence_ids) / sizeof(int), false, false);
  paddle_ivector sentence1 = paddle_ivector_create(
      sentence_ids, sizeof(sentence_ids) / sizeof(int), false, false);
  CHECK(paddle_arguments_set_ids(in_args, 0, sentence0));
  CHECK(paddle_arguments_set_ids(in_args, 1, sentence1));

  int seq_pos_array[] = {0, sizeof(sentence_ids) / sizeof(int)};

  paddle_ivector seq_pos0 = paddle_ivector_create(
      seq_pos_array, sizeof(seq_pos_array) / sizeof(int), false, false);
  paddle_ivector seq_pos1 = paddle_ivector_create(
      seq_pos_array, sizeof(seq_pos_array) / sizeof(int), false, false);

  CHECK(paddle_arguments_set_sequence_start_pos(in_args, 0, 0, seq_pos0));
  CHECK(paddle_arguments_set_sequence_start_pos(in_args, 1, 0, seq_pos1));

  paddle_arguments out_args = paddle_arguments_create_none();
  CHECK(paddle_gradient_machine_forward(machine,
                                        in_args,
                                        out_args,
                                        /* isTrain */ false));

运行出core:
F0821 11:17:06.300724 25829 Matrix.cpp:3273] Check failed: dynamic_cast<CpuIVector*>(&label)
*** Check failure stack trace: ***
    @     0x7ffff6cee87d  google::LogMessage::Fail()
    @     0x7ffff6cf232c  google::LogMessage::SendToLog()
    @     0x7ffff6cee3a3  google::LogMessage::Flush()
    @     0x7ffff6cf383e  google::LogMessageFatal::~LogMessageFatal()
    @     0x7ffff6c47899  paddle::CpuMatrix::oneHotCrossEntropy()
    @     0x7ffff6abc475  paddle::CostLayer::forward()
    @     0x7ffff6b65530  paddle::NeuralNetwork::forward()
    @     0x7ffff6a1c4e6  paddle_gradient_machine_forward
    @           0x401774  main
    @     0x7ffff6483bd5  __libc_start_main
    @           0x4011b9  (unknown)
    @              (nil)  (unknown)

Program received signal SIGABRT, Aborted.
0x00007ffff64973f7 in raise () from /opt/compiler/gcc-4.8.2/lib/libc.so.6
(gdb) bt
#0  0x00007ffff64973f7 in raise () from /opt/compiler/gcc-4.8.2/lib/libc.so.6
#1  0x00007ffff64987d8 in abort () from /opt/compiler/gcc-4.8.2/lib/libc.so.6
#2  0x00007ffff6cf7715 in google::DumpStackTraceAndExit() () from /home/yanchunwei/third_party/tengfei/Paddle/paddle/capi/examples/model_inference/usr/local/lib/libpaddle_capi_shared.so
#3  0x00007ffff6cee87d in google::LogMessage::Fail() () from /home/yanchunwei/third_party/tengfei/Paddle/paddle/capi/examples/model_inference/usr/local/lib/libpaddle_capi_shared.so
#4  0x00007ffff6cf232c in google::LogMessage::SendToLog() () from /home/yanchunwei/third_party/tengfei/Paddle/paddle/capi/examples/model_inference/usr/local/lib/libpaddle_capi_shared.so
#5  0x00007ffff6cee3a3 in google::LogMessage::Flush() () from /home/yanchunwei/third_party/tengfei/Paddle/paddle/capi/examples/model_inference/usr/local/lib/libpaddle_capi_shared.so
#6  0x00007ffff6cf383e in google::LogMessageFatal::~LogMessageFatal() () from /home/yanchunwei/third_party/tengfei/Paddle/paddle/capi/examples/model_inference/usr/local/lib/libpaddle_capi_shared.so
#7  0x00007ffff6c47899 in paddle::CpuMatrix::oneHotCrossEntropy(paddle::Matrix&, paddle::VectorT<int>&) () at /home/yuyang/BuildAgent3/work/d55918cf60d51073/paddle/math/Matrix.cpp:3273
#8  0x00007ffff6abc475 in paddle::CostLayer::forward(paddle::enumeration_wrapper::PassType) () at /home/yuyang/BuildAgent3/work/d55918cf60d51073/paddle/gserver/layers/CostLayer.cpp:50
#9  0x00007ffff6b65530 in paddle::NeuralNetwork::forward(std::vector<paddle::Argument, std::allocator<paddle::Argument> > const&, std::vector<paddle::Argument, std::allocator<paddle::Argument> >*, paddle::enumeration_wrapper::PassType) () at /home/yuyang/BuildAgent3/work/d55918cf60d51073/paddle/gserver/gradientmachines/NeuralNetwork.cpp:250
#10 0x00007ffff6a1c4e6 in paddle_gradient_machine_forward () at /home/yuyang/BuildAgent3/work/d55918cf60d51073/paddle/capi/gradient_machine.cpp:81
#11 0x0000000000401774 in main ()
@luotao1
Copy link
Contributor

luotao1 commented Aug 21, 2017

capi 模型文件要为infernce的而不是train的模型。
从core中看,CostLayer::forward()表示有cost层,这是train的模型。

@PaddlePaddle PaddlePaddle deleted a comment from fty8788 Aug 21, 2017
@fty8788
Copy link
Author

fty8788 commented Aug 21, 2017

@luotao1
Copy link
Contributor

luotao1 commented Aug 21, 2017

@Superjom 能请你看一下么, @fty8788 设置了is_infer=True也是一样的错误

@luotao1
Copy link
Contributor

luotao1 commented Aug 21, 2017

DSSM 模型已更新,修改见 PaddlePaddle/models#212 。可用最新模型试一下。

@Superjomn
Copy link
Contributor

模型在非 capi 状态下,应该是 train/infer 没问题的吧? @fty8788
如果是这样,主要看下 capi 是否有问题吧

@fty8788
Copy link
Author

fty8788 commented Aug 21, 2017

@luotao1 一样的错误

@fty8788
Copy link
Author

fty8788 commented Aug 21, 2017

@Superjom python版本没有问题,capi的问题

@fty8788
Copy link
Author

fty8788 commented Aug 22, 2017

删掉配置中的cost层就可以了,即使不返回,也不能存在

@fty8788 fty8788 closed this as completed Aug 22, 2017
heavengate pushed a commit to heavengate/Paddle that referenced this issue Aug 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants