-
Notifications
You must be signed in to change notification settings - Fork 24.3k
8000 [libtorch] Loading in Java two differente libtorch_cpu.so from different versions fails #70191
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
Loading two versions of Can you please run something like the following in your environment, and let me know if it works for you:
|
Thanks for your answer @malfet ! I guess you meant that it is not supported, didnt you? |
HEllo back again. I have done some more tests and it seems that libtorch_cpu.so leaves something open. In windows I am able to load and unload .dlls from different versions with no problem but in Linux I always get the error: |
I also want to mention that this issue only happens in Linux as in Windows I am perfectly able to load and unload. |
This is the program that I used to test it in Linux. Regard that this same thing can be done with no error in Windows:
The first dlopen loads libtorch corresponding to pytorch 1.8.1 and the second libtorch corresponding to Pytorch 1.9.0. |
Uh oh!
There was an error while loading. Please reload this page.
🐛 Describe the bug
Hello, I am creating an application in Java that allows loading different Pytorch versions to make inference. For that I have to dynamically load different versions of libtorch_cpu.so. However, it is not possible as the program crashes with different error messages depending on the version. I am loading the native libraries using JNIs loaded on dynamically created classloaders but even after being garbage collected, the native library is not unloaded. Some of the errors produced when trying to dynamically laod a different libtorch_cpu.so are:
Exception in thread "main" Unknown device: 51. If you have recently updated the caffe2.proto file to add a new device type, did you forget to update the DeviceTypeName() function to reflect such recent changes?
The following JVM fatal error
or
Caused by: java.lang.UnsatisfiedLinkError: /home/carlos/.djl.ai/pytorch/1.8.1-cpu-linux-x86_64/libtorch_cpu.so: /home/carlos/.djl.ai/pytorch/1.8.1-cpu-linux-x86_64/libtorch_cpu.so: undefined symbol: _ZNK3c1010TensorImpl23shallow_copy_and_detachERKNS_15VariableVersionEb
Looking at the already existing issues I have found something similar in:
#60341
#13541
Versions
For every version I have tried: 1.7.0, 1.7.1, 1.8.1, 1.9.0 and 1.9.1
cc @ezyang @seemethere @malfet
The text was updated successfully, but these errors were encountered: