Replies: 2 comments
-
Hi @VirArman - this question came up before (in #13 for example) and basically spacy-cpp does not support multi-threading (unless using a single spacy instance and mutex protecting accesses to it), the reason is that spacy-cpp only has a single Python run-time. If more parallelism is needed I'm afraid you'll need to use multiple processes. I should probably add a note about this in the README FAQ section, will look into that.. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks for quick response, I will try the solution you offered |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When I tried to create spacy object in multiple threads a segmentation fault occurred.
The fallowing is my code, can someone tell what is the possible issue or suggest a solution for this problem
void spacy_call() {
Spacy::Spacy spacy;
auto nlp = spacy.load("en_core_web_sm");
auto doc0 = nlp.parse("he fire his house");
for (auto& token : doc0.tokens())
{
std::cout << token.text() << " [" << token.pos_() << "],";
std::cout << "[" << token.lemma_() << "]," << "\n";
}
std::cout << std::endl;
}
int main()
{
std::thread spacy_first(spacy_call);
std::thread spacy_second(spacy_call);
spacy_first.join();
spacy_second.join();
}
Beta Was this translation helpful? Give feedback.
All reactions