-
Notifications
You must be signed in to change notification settings - Fork 100
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
Session thread safety #38
Comments
I remember asking myself a similar question last summer. I can't recall if it was about the session though, maybe it was 🤔 . The issue was that I could not see anything that was proving me that the session was threadsafe. Being paranoid and rust-spoiled, I did not opt-in to mark it Send+Sync. I guess the session can be wrapped in a |
I was about to open a similar issue, and came across this issue.
Fwiw, At the moment, the following fails to compile fn main() {
let environment = Environment::builder()
.build()?;
let mut session = environment
.new_session_builder()?
.with_model_from_file("squeezenet1.0-8.onnx")?;
foo(&session);
}
fn foo<T: Sync> (s: &T) {
...
} with an error like
So you'd need to explicitly add |
That seems pretty clear to me 🤷, but maybe the other operations on Session should not be called from multiple threads, in which case perhaps some other type (like |
I'm trying to use lazy_static! {
static ref ENVIRONMENT: Environment = Environment::builder().with_name("env").build().unwrap();
static ref SESSION: Session<'static> = JAVA_ENVIRONMENT.new_session_builder().unwrap().
.with_optimization_level(GraphOptimizationLevel::Basic).unwrap().
.with_number_threads(2).unwrap().
.with_model_from_file("/Users/haobogu/Projects/rust/mymodel.onnx").unwrap();
} I got a complier error:
It seems a similar situation. @marshallpierce @krlohnes do you have any ideas? |
Looks like the same core issue. I wish I had a week or two to dedicate to this library. Ah well... |
Any news? |
1 similar comment
Any news? |
Thanks for the handy library, first of all.
My read of https://github.com/microsoft/onnxruntime/blob/master/docs/InferenceHighLevelDesign.md#key-design-decisions is that a session is thread safe. Should
onnxruntime::session::Session
therefore be Send and Sync?The text was updated successfully, but these errors were encountered: