-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[Bug]: ov::InferRequest::infer() not thread safe when having multiple models #24509
Comments
I can reproduce the similar issue in master branch with above test code. The race condition occurred during one thread doing infer() and another thread doing create_infer_request(). Further to narrow down into |
great, thank you! |
@daaguirre could you have a try this PR? #24562 |
thank you! I'll give it a try tomorrow and let you know. |
Likely async API also faces the similar problem. |
Hi! sorry the late response, I already tried the PR and it is working now! thank you! what is the plan to release this fix? |
It will be in 24.2 release, do you need port it back to 23.3? |
### Details: - *I lost code `t_stream_count_map[(void*)this] = item.first;` in #19832* - *the thread safe issue happen in below workflow* - create thread A call CustomThreadLocal:local() in thread A -> create stream A (the count of stream A is 2) destory thread A (the count of stream A is 1) create thread B (same thread id with thread A) call CustomThreadLocal:local() in thread B -> use stream A(the count of stream A is 1, so it's broken) - *add testcase, also fix https://github.com/openvinotoolkit/openvino/pull/19986/files#r1332774754* ### Tickets: - Closes #24509 --------- Signed-off-by: HU Yuan2 <[email protected]> Co-authored-by: Wanglei Shen <[email protected]>
oh yes please, could we have a patch of 23.3?, thank you! |
…t#24562) - *I lost code `t_stream_count_map[(void*)this] = item.first;` in - *the thread safe issue happen in below workflow* - create thread A call CustomThreadLocal:local() in thread A -> create stream A (the count of stream A is 2) destory thread A (the count of stream A is 1) create thread B (same thread id with thread A) call CustomThreadLocal:local() in thread B -> use stream A(the count of stream A is 1, so it's broken) - *add testcase, also fix https://github.com/openvinotoolkit/openvino/pull/19986/files#r1332774754* - Closes openvinotoolkit#24509 --------- Signed-off-by: HU Yuan2 <[email protected]> Co-authored-by: Wanglei Shen <[email protected]>
### Details: - *port PR #24562 to release 2023.3* - *add support for InferAPI1 and api_version* ### Tickets: - *[issue-24509](#24509 --------- Signed-off-by: HU Yuan2 <[email protected]> Co-authored-by: Wanglei Shen <[email protected]>
OpenVINO Version
2023.3.0
Operating System
Ubuntu 20.04 (LTS)
Device used for inference
CPU
Framework
None
Model used
No response
Issue description
When running concurrently multiple inferences of multiple models with OpenVino 2023.3.0 the call to method
ov::InferRequest::infer()
is not thread safe. However, in the previous version 2023.0.0, this method is thread safe.It's importantant to point out that to trigger the error any model must be run first in a parent thread, later from parent thread if we spawn more threads for running same/different models concurrently the crash happens. So if commenting out the for loop marked with comment
comment out below for loop to prevent crash
the crash won't happen in attached code snippet.Note that this crash is random and it does not happen on all executions, that's why provided code snippet is wrapped in a for loop to force the error.
Step-by-step reproduction
The following code snippet crashes with a segfault when linked to 2023.3.0 and works correctly with 2023.0.0.
The error can be reproduced with any generic model:
efficientnet: https://drive.google.com/file/d/1a7AoEi165ZF1dJNfD_OklQVs_QpsHcA2/view?usp=sharing
googlenet: https://drive.google.com/file/d/15lxSLWmM4EUrc63ReGD-Kwj6DlcEl6a-/view?usp=sharing
Relevant log output
Issue submission checklist
The text was updated successfully, but these errors were encountered: