PaddleOCR icon indicating copy to clipboard operation
PaddleOCR copied to clipboard

predictor->Run()在多线程下崩溃问题

Open GamePlayerScript opened this issue 3 years ago • 5 comments

2.2版本,c++使用paddleOcr, 创建多个线程,每个线程参考c++示例,同时识别多张图片,发现predictor->Run()这个函数经常崩溃,加锁后恢复正常,这个有人遇到过吗

GamePlayerScript avatar Jan 13 '22 07:01 GamePlayerScript

请问你有解决问题了嘛

lrjj avatar Jan 15 '22 12:01 lrjj

你有解决问题了嘛

我这边想到的就只是加锁

GamePlayerScript avatar Jan 26 '22 09:01 GamePlayerScript

我改的多线程也崩溃了,请问需要在代码哪个地方加锁啊?

lgbest123 avatar Feb 09 '22 08:02 lgbest123

我改的多线程也崩溃了,请问需要在代码哪个地方加锁啊?

崩溃的地方加锁,predictor->Run()前后

GamePlayerScript avatar Feb 09 '22 10:02 GamePlayerScript

您好,请教一下我这样加锁对吗?为什么我加了仍然会在这附近卡住挂掉
mutex mu_Run_Predictor;
mu_Run_Predictor.lock();
std::cout << "In -- this->predictor_->Run()  " << std::endl;
this->predictor_->Run();
mu_Run_Predictor.unlock();

FoneMobius avatar Sep 20 '22 06:09 FoneMobius

您好,请教一下我这样加锁对吗?为什么我加了仍然会在这附近卡住挂掉
mutex mu_Run_Predictor;
mu_Run_Predictor.lock();
std::cout << "In -- this->predictor_->Run()  " << std::endl;
this->predictor_->Run();
mu_Run_Predictor.unlock();

我把锁包住了前面获取input handle到后面获取output handle并copy,整个用到preditor的地方都包住就不crash了

hanliangwei avatar Jul 18 '23 08:07 hanliangwei