-
Notifications
You must be signed in to change notification settings - Fork 751
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
Running two numpy thread application in same one JVM,all will down!!! #817
Comments
CPython isn't thread-safe by default. There's information about this here in their documentation: |
I have the same problem, @penetest did you find a solution to this problem? |
@CristianPi we built some wrappers on top of this that might be useful for you to give a shot: https://deeplearning4j.konduit.ai/python4j/tutorials/quickstart Please do let me know if you find it useful. |
@agibsonccc thanks! for sure it's nicer, but still does not solve the problem, or im i wrong? On the api side of spring i just put synchronized for now and it works, i can spawn more small (256 MB ram)containers if i want parallelism. |
@CristianPi no we actually do the context management Sam mentioned above. You can spawn multiple interpreters if you want. This was built with that use case in mind. That's just the hello world quickest way to run python code. We introduce the GIL abstraction for handling when code is running python code. No matter what you'd need to do that. Feel free to ask more questions on the forums if you want to pursue this. Underneath it's still the same bindings anyways :) |
@CristianPi For that purpose you'll need to look into doing "multiprocessing": |
What @saudet mentioned is definitely the safe way to do it. We've had success with different interpreters in different threads. Usually we just manage the variables in java and translate them as needed (this is usually a zero copy process) with python being mainly a compute example. If you're trying to do numpy arrays without an additional layer it's very doable but requires some setup. |
Running two numpy thread application in same one JVM,all will down!!!
show some error:
The text was updated successfully, but these errors were encountered: