-
Notifications
You must be signed in to change notification settings - Fork 214
TensorFlow.loadLibrary not working on Windows #404
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
It is strange indeed that Windows binaries are The result of this is that you'll end up having a single TensorFlow binary on Windows ( I know that on Linux and MacOS, tensorflow-text binaries links to If that's the case, we need to understand how it is possible to load it then on Python or maybe try to build Windows TF binaries as non-monolithic as well (though this setting comes from the TensorFlow itself, not TensorFlow-Java, and I bet there is a good reason for it). |
Thanks for the quick reply. If I understand the TensorFlow source correctly, the |
Unfortunately I don't have a Windows setup available. It could be very helpful if you can dump out the list of dependencies of one of the dll/so and share it with us, here are some suggestions on how to do it: https://stackoverflow.com/questions/7378959/how-to-check-for-dll-dependency |
Thanks, that was actually very insightful. I ran
All of the DLLs depend on
If I put a So the problem isn't in the java binding for TensorFlow but rather in the way TensorFlow-Text is compiled for Python on Windows. Interestingly enough, the
Any ideas on how to proceed? |
@lucaro It is possible to link the binaries distributed for Python with the JNI wrappers, see issue #226 (comment). On Windows, since I don't think we can hack this with symbolic links, we probably need to build from source after patching the presets here: |
I'm not sure I understand what you mean. When I try to load
It certainly does something as indicated by the warning about missing cuda, which does not appear otherwise, but crashes afterward. Does this go into the direction of what you had in mind? |
It doesn't work because that way it tries to load both tensorflow_cc.dll and _pywrap_tensorflow_internal.pyd. We can't do that. We can only load a single version of TF Core in the same process. |
Is there a way I can prevent tensorflow_cc.dll from being loaded? |
Yes, like I'm saying for the third time now, by linking with _pywrap_tensorflow_internal.pyd. How many more times do you need to be told? :) |
I'm sorry for missing the point here. This would require changing the line you indicated and then rebuilding TensorFlow Java, right? This would not be something I could do quickly since I don't have the build environment setup, so far only having used the maven artifacts you so graciously provide. I was hoping there was a way to do such modifications for testing purposes without having to rebuild such complex dependencies. Any guidance on how to check this in the most efficient way would be greatly appreciated. |
Thanks for the dependency dump @lucaro , yes looks like it is Like @saudet suggested (supposedly many times ;) ), we can try building artifacts that links directly to this binary instead of the TensorFlow build we distribute. If that works, we could distribute that artifact as a new platform for TensorFlow Java (e.g. I understand you are not setup for building it, so we can probably create an additional setup in our CI build to test it out, but if you are eager to try it out now, you can look at this page for more guidance on how to prepare your environment to do it: https://github.com/tensorflow/java/blob/master/CONTRIBUTING.md Please let me know if you plan to try it, thanks! |
Hey @karllessard, thanks a lot for this clarification. Having TensorFlow-Text working on Linux is sufficient for my purposes for the time being and I don't currently have the capacity to get into the whole build process on Windows. I might tinker with it if I find some time, but I don't know when that's going to be. I think the idea of @saudet to link against the python binary is great though and if you ever add such a build to your CI, I'd be happy to help with beta-testing if that should be useful. |
@lucaro Yes, it requires rebuilding from source, but since this repository uses GitHub Actions to perform the builds, anyone can very easily create a fork to perform their own custom builds. @karllessard One thing we could do is rename |
Given that we don't expose the same set of symbols as the pywrap file does, won't renaming it cause more trouble in the long run when people wonder why there are two completely different files with the same name? |
Well, if you want to try and convince TF Core maintainers that they should give better more consistent names to their libraries, be my guest :) Like I said, PyTorch does that right. There's no reason TF couldn't either. |
At this point, I'm fine with @saudet suggestion and simply rename the DLL to match Python's one. It is hacky for sure but it's better than not supporting ops libraries like tensorflow-text on Windows. I like though the idea of allowing users to link directly to the binaries distributed by the Python wheels. I'm wondering if we can give that option to the user, using let say an environment variable (or maybe that already works by setting the |
When the names of the libraries match, it works with the binaries from the wheels, yes, see issue #226 (comment). |
System information
java -version
): 11Describe the current behavior
I'm trying to use models which contain ops from tensorflow-text. To get them to work on Linux, I just took the
.so
files from the pip wheel and loaded them usingTensorFlow.loadLibrary()
. When I run the same code on Windows, using the binary files from the Windows pip wheel extracted in the same way (which are also.so
files for some reason), they cannot be loaded. The example code below uses the universal-sentence-encoder-multilingual-large and works as expected when run from within the WSL2 Ubuntu 20.04 environment on my Windows 10 machine. Is there something else that needs to be done to get the libraries to load on Windows?Describe the expected behavior
Code to reproduce the issue
Other info / logs
Output from WSL2 Ubuntu 20.04
Output from Windows
The text was updated successfully, but these errors were encountered: