You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When attempting to create a multithreaded REST API using Rocket to serve a model, I've run into the following error.
double free or corruption (fasttop)
This is all the error I receive and I presume it's coming from the underlying libtorch library. I've seen other GitHub issues on both this crate and the tch-rs crate talking about how tensors are Send but not Sync, so I wrapped a SentenceEmbeddingsModel in a Mutex on the server start up and then passed it to each method in the API. I assumed this would keep the model safely wrapped, but it doesn't appear so as I get the same error.
I've noticed on the tch-rs crate there was a similar double-free error that was patched a while ago: LaurentMazare/tch-rs#475. I've also reported an issue there.
I understand this may be an issue for the tch-rs crate instead, but hoping there's a more sensible way I can wrap the model up for use across threads? I'm only using the encode method to
struct SbertModel(Arc<Mutex<SentenceEmbeddingsModel>>);
...
let sbert_model = SbertModel(Arc::new(Mutex::new(
SentenceEmbeddingsBuilder::remote(SentenceEmbeddingsModelType::AllMiniLmL6V2)
.create_model()
.unwrap())));
...
let my_model = model.0.lock().await;
let encoding = my_model.encode(&[some_string])?;
drop(my_model); // Have tried both manually dropping and letting it go out of scope.
The text was updated successfully, but these errors were encountered:
When attempting to create a multithreaded REST API using Rocket to serve a model, I've run into the following error.
double free or corruption (fasttop)
This is all the error I receive and I presume it's coming from the underlying libtorch library. I've seen other GitHub issues on both this crate and the
tch-rs
crate talking about how tensors areSend
but notSync
, so I wrapped aSentenceEmbeddingsModel
in a Mutex on the server start up and then passed it to each method in the API. I assumed this would keep the model safely wrapped, but it doesn't appear so as I get the same error.I've noticed on the
tch-rs
crate there was a similar double-free error that was patched a while ago: LaurentMazare/tch-rs#475. I've also reported an issue there.I understand this may be an issue for the
tch-rs
crate instead, but hoping there's a more sensible way I can wrap the model up for use across threads? I'm only using theencode
method toThe text was updated successfully, but these errors were encountered: