Git Product home page Git Product logo

Comments (8)

ygean avatar ygean commented on July 22, 2024

@HuangXingBo

from pemja.

HuangXingBo avatar HuangXingBo commented on July 22, 2024

Yes. This is a very typical way of using Pemja.

from pemja.

HuangXingBo avatar HuangXingBo commented on July 22, 2024

@zhouyuangan Have you started integration with pemja yet? Do you encounter any problems?

from pemja.

285220927 avatar 285220927 commented on July 22, 2024

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.

HuangXingBo avatar HuangXingBo commented on July 22, 2024

@285220927 Why not create multiple PythonInterpreters ? Multiple thread (each thread has a PythonInterpreter) or Multiple PythonInterpreter instances in one thread

from pemja.

285220927 avatar 285220927 commented on July 22, 2024

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.

HuangXingBo avatar HuangXingBo commented on July 22, 2024

@285220927 Do you mean that [a Java thread -> a Python Interpreter -> an inference engine -> multiple python threads ] ?

from pemja.

285220927 avatar 285220927 commented on July 22, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.