Loading two different Tensorflow versions with different classloaders
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 928
- Forks
- 227
- PR merge metrics
- No merged PRs in 30d
Description
Hello, I am creating a program that makes inference with already trained models and I want to allow changing the tensorflow versions on runtime. For that I am loading dynamically the JARS needed to run Inference with TF Java in a separate classloader. These JARs are not in the classpath of the main program. I expected that when the ClassLoader is garbage collected, the native libraries loaded by that classloader were going to be unloaded too. However that is not the case and I am not able to load two different versions of Tensorflow in the same run time one after the other. The error I get when I try to execute a command with the JARs corresponding to the second TF version loaded is :
2021-12-21 14:47:11.121313: F external/org_tensorflow/tensorflow/core/framework/variant_op_registry.cc:46] Check failed: existing == nullptr (0x7ff35a2acc38 vs. nullptr)Unary VariantDecodeFn for type_name: tensorflow::data::WrappedDatasetVariant already registered
Is this behaviour expected? Is there any way I can do what I want?
regards,
Carlos
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no repository file, test, or entry point. Start by tracing TensorFlow Java's native library loading and classloader handling, then reproduce the sequential loading of two TensorFlow versions using the reported variant-op registration failure. Done means documenting whether unloading is supported and identifying a validated way to load versions separately, if one exists.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, tensorflow
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100