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

Infer multi-threads API Demo and UT #11247

Merged
merged 9 commits into from
Jun 7, 2018

Conversation

tensor-tang
Copy link
Contributor

@tensor-tang tensor-tang commented Jun 6, 2018

  • Demo
  • UT
    • word2vec
    • image_classification

@tensor-tang tensor-tang added the 预测 原名Inference,包含Capi预测问题等 label Jun 6, 2018
@tensor-tang tensor-tang changed the title Infer API Demo and UT Infer multi-threads API Demo and UT Jun 6, 2018
@tensor-tang
Copy link
Contributor Author

[Step 1/1] make[2]: *** [paddle/fluid/inference/analysis/test_dfg_graphviz_draw_pass] Error 1

https://paddleci.ngrok.io/viewLog.html?tab=buildLog&logTab=tree&filter=debug&expand=all&buildId=58&_focus=5046

for (int tid = 0; tid < num_threads; ++tid) {
threads.emplace_back([&, tid]() {
// 1. clone a predictor which shares the same parameters
auto predictor = main_predictor->Clone();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The clone should be outside the thread:

for (int tid = 0; tid < num_threads; ++tid) {
  auto predictor = main_predictor->Clone();
  std::thread t([&]{
    predictor->xxx
  });
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid it's better to be inside thread.

}
}

void MainThreads(int num_threads) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need a config use_gpu to ensure GPU can also be called with multi-threads.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure~

Copy link
Contributor

@Superjomn Superjomn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tensor-tang tensor-tang merged commit 80e882a into PaddlePaddle:develop Jun 7, 2018
@tensor-tang tensor-tang deleted the infer_api branch June 7, 2018 13:31
@tensor-tang tensor-tang restored the infer_api branch June 15, 2018 06:32
@tensor-tang tensor-tang deleted the infer_api branch June 15, 2018 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
预测 原名Inference,包含Capi预测问题等
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants