Comments (8)
from pemja.
Yes. This is a very typical way of using Pemja.
from pemja.
@zhouyuangan Have you started integration with pemja yet? Do you encounter any problems?
from pemja.
Yes, this is a good project, but we encountered a problem: in a class in python, the init method needs to initialize the inference engine, which is a very time-consuming operation, but the execution of the inference function is fast, so In java, we use a static code block to initialize the python class to get a python object. This step will initialize the python inference engine, so in the java web, each request does not need to initialize the inference engine. But in python, the initialization function and the inference function must be called in the same thread, so in java we can only use "Executors.newSingleThreadExecutor()" to put the initialization method and inference method in the same thread to call python, may i ask is there a better way or optimization?
from pemja.
@285220927 Why not create multiple PythonInterpreter
s ? Multiple thread (each thread has a PythonInterpreter
) or Multiple PythonInterpreter
instances in one thread
from pemja.
It takes a lot of GPU resources to initialize an inference engine, so we want to create only one PythonInterpreter, we are looking for a way to use pemja to call python concurrently within the same thread
from pemja.
@285220927 Do you mean that [a Java thread -> a Python Interpreter
-> an inference engine -> multiple python threads ] ?
from pemja.
@285220927 Do you mean that [a Java thread -> a
Python Interpreter
-> an inference engine -> multiple python threads ] ?
We want [multiple Java thread -> a Python Interpreter -> an inference engine -> a python threads ]
We want python to always be inside the same thread no matter how many times it is called with pemja. We found by printing the python thread id: java calls within the same thread => python is always in a thread; java multi-threaded calls => python is not in the same thread
from pemja.
Related Issues (20)
- Recursive callbacks cause a deadlock HOT 12
- Please create an offiical Conda install package HOT 5
- Comparison vs DL4J / java-cpp HOT 3
- Incompatible with Official Python Docker Images: Failed to find libpython HOT 1
- Unknown Number class int. HOT 3
- Generic invokeMethod HOT 1
- Issue with Thread mode in Flink 1.16 and M1 HOT 1
- MainInterpreter implements Serializable but has non-serializable fields
- Can not import 'findClass' HOT 3
- Failed to find the function after exec HOT 1
- Can't install with python 3.10 HOT 3
- How to return a python numpy array to the Java side? The return type is java.util.List HOT 2
- Will you try to integrate Codon? HOT 1
- Is there a way to trigger a call from Python? HOT 1
- Failed to use pemja in Flink DataStream API
- Support Python 3.11 HOT 2
- 0.4.0 release has missing pom from maven central HOT 1
- Can pemja support JVM scheduling through PVM?
- Build pemja for arm64
- For developers, what tools can be used to develop multi-language projects like "pemja" on Mac?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pemja.