Sharing model across threads #164
Answered
by
decahedron1
patcollis34
asked this question in
Q&A
-
Are there any good example codebases that share ORT session or environments across threads? I'm guessing I want to load the session or environment into struct on startup and then pass that struct to the threads. seems like I may need to do something with threadpool configs on the session as well? |
Beta Was this translation helpful? Give feedback.
Answered by
decahedron1
Feb 27, 2024
Replies: 1 comment 2 replies
-
There are 2 main ways to do this:
I don't think there's a need for threadpool if you're only ever using one session (shared between threads or not) at a time. |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
patcollis34
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There are 2 main ways to do this:
Session
in anArc
.Session
isSend + Sync
so you can just wrap it in anArc
and send that to different threads.Though if you plan to use GPU acceleration, I've had issues where using a session in multiple threads with CUDA & DirectML on Windows would cause a segfault. This might have been fixed by #160 (which you'll need to add
ort
as a git dependency to use) but I haven't tested it.I don't think there's a need for threadpool if you're only ever using one session (shared bet…