-
Notifications
You must be signed in to change notification settings - Fork 214
Unary VariantDecodeFn for type_name: tensorflow::data::WrappedDatasetVariant already registered #226
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
Comments
I think we probably can't have the TF native library loaded twice into the same process. TF-Java and TF-Python will by necessity use slightly different builds of the native library (as it's compiled and released separately). What's your use case for having both of them loaded in the same process? |
Can't we have the TF native library loaded twice into the same process even if we use the same TF version like java 0.2.0 and python 2.3.1 described here? About the use case:
|
They are compiled separately and potentially with different options (e.g. MKL, GPUs, x86_64 features), leading to a conflict. It might be possible to persuade TF-Java to only load the JNI binding and not libtensorflow, but if you did hit native library issues we wouldn't support such a configuration. @saudet are there some flags on the JavaCPP loader which will enable this? With 0.2.0 and the upcoming 0.3.0 release you should be able to train models in TF-Java (though not all operations have gradients available yet as they aren't all present in the native layer). |
TF Core keeps a global state. The only way to get this working is by compiling a version of TF Core that supports both Java and Python APIs. I did that for TF 1.x and it works, but we would need to port this to TF 2.x and then we could maintain this here: |
Thank you for your replies and the reference link! @saudet You mean that you will compile a version of TF Core that supports both Java and Python APIs for TF 2.x in the near future, right? |
I don't plan to do it myself, no, because we have no build machines that have enough power to complete the Python build anyway. If you have questions though, feel free to ask and I will help! |
Then, are there any ways to build the java artifact for TF 2.x? I need the artifact that works in the same python process simultaneously |
@akiou, fwiw, I'm having a hybrid setup where I train in Python but do all the pre/post processing and inference in Java, and I did not had the kind of issues you are mentioning here, The way I do it is when the Python script starts for training, I use JPype to launch the JVM and load the Java library doing all of the stuff I've mentioned before, and invoke the Java classes directly from Python. It really worked great in my case, if you are interested I can share with you more details to help you set it up that way. |
@karllessard Perhaps, you might have made a misunderstanding. Also in my case, I did not get an exception just executing a model in TF java invoked from a Python process. |
You will need to perform the build as per this script when EXTENSION=-python |
@saudet I'd like to confirm one thing about the build with extension=-python. The build enables us to run a python script from a Java process like https://github.com/bytedeco/javacpp-presets/blob/master/tensorflow/samples/KerasMNIST.java#L32-L49, right? If so, I think the javacpp build with extension=-python cannot realize what I want to do. What I want to do is not invoke TF python 2.x from java but invoke TF java from a python process that already imports TF 2.x. This is because I'd like the usecase described in #226 (comment). |
Sure, that's possible too. You'll need a way to use JNI from Python, but that's easily doable with tools like jpype, pyjnius, etc. |
Thank you! $ mvn clean install --projects .,tensorflow -Djavacpp.platform.extension=-python then, some jars are generated in Additionally, I tried to replace the tensorflow version with |
Yes, the same class is available in that JAR file:
That's what I keep telling you: Someone will need to work on updating that for TF 2.x. |
I see, then the jar for TF 2.x that can be invoked from a python process already importing TF 2.x is not available until someone works on updating that for TF2.x if my understanding is correct. |
Additionally, I have another question (sorry for a lot of questions)
I tried to insert a statement
|
Make sure that |
I was able to load the model by using |
@akiou Since building TF Core is quite a challenge in itself, I've been experimenting with linking and loading the @karllessard @Craigacp That would also be one way to circumvent our build issues. It would add a dependency on CPython, but it works, and it would make it possible to use both the Java and Python APIs in the same process. (To be clear, we don't need to use Python, we just need to link with the native CPython library to satisfy the undefined symbols.) |
I have meet the same issue. Any plan to upgrade TF 2.x so it can be called by Python and Java in the same process? |
Please make sure that this is a bug. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:bug_template
System information
You can collect some of this information using our environment capture script
You can also obtain the TensorFlow version with
python -c "import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)"
Describe the current behavior
I executed Python TensorFlow v2.3.1 and TensorFlow java invoked from JNI by using
pyjnius
in a Python process. Then, the following error was shown and the Python process was aborted.More details:
.pb
file.tensorflow
andpyjnius
.pyjnius
which loads the stored model by usingSavedModelBundle.load()
.Describe the expected behavior
The user should be able to execute both (python and java) from a Python process without any conflict exceptions.
Code to reproduce the issue
Provide a reproducible test case that is the bare minimum necessary to generate the problem.
I pushed a sample code into https://github.com/akiou/tf_conflict. You can reproduce this error by using the repo sample code.
Other info / logs
Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.
The error message is dependeing on the platform OS. The error message in this issue is observed inside a Linux docker container. If you run the sample code in Mac OS, then the following error message is shown instead:
The text was updated successfully, but these errors were encountered: