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

Possible to run inference purely sequentially and not have onnx pin a thread #11347

Closed
brettfazio opened this issue Apr 25, 2022 · 3 comments
Closed

Comments

@brettfazio
Copy link

If you want to run onnx cpu on a single thread using SEQUENTIAL - is it possible to do so without onnx pinning a new thread?

Presently I looked at the issue here and did the same solution of options = ort.SessionOptions() options.intra_op_num_threads = 1 options.inter_op_num_threads = 1 - but that pins a new thread?
Is it possible to just run inference in the same thread that onnx gets called from and have onnx pin no threads? In the case where one is doing external cpu pinning.

@snnn
Copy link
Member

snnn commented Apr 25, 2022

but that pins a new thread?

I don't think so. Did you see a new thread got started? If you set both of values to 1, I think ONNX Runtime should not create any thread pool.

@snnn
Copy link
Member

snnn commented Apr 25, 2022

The code is there:
https://github.com/microsoft/onnxruntime/blob/master/onnxruntime/core/util/thread_utils.cc#L18

If the size is 1, then the function directly returns.

@brettfazio
Copy link
Author

Got it, thanks

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

2 participants