Skip to content

Infer multi-threads API Demo and UT#11247

Merged
tensor-tang merged 9 commits intoPaddlePaddle:developfrom
tensor-tang:infer_api
Jun 7, 2018
Merged

Infer multi-threads API Demo and UT#11247
tensor-tang merged 9 commits intoPaddlePaddle:developfrom
tensor-tang:infer_api

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 requested a review from Superjomn June 6, 2018 11:45
@tensor-tang tensor-tang changed the title Infer 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预测问题等

2 participants