Skip to content
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

Tensorflow.loadLibrary() not working on Windows #26468

Closed
saif-ellafi opened this issue Mar 8, 2019 · 20 comments
Closed

Tensorflow.loadLibrary() not working on Windows #26468

saif-ellafi opened this issue Mar 8, 2019 · 20 comments
Assignees
Labels
comp:apis Highlevel API related issues stat:awaiting response Status - Awaiting response from author type:bug Bug

Comments

@saif-ellafi
Copy link

saif-ellafi commented Mar 8, 2019

Running:

TensorFlow.loadLibrary("ner-dl/win/_lstm_ops.so")

Returns:

java.lang.UnsatisfiedLinkError: ner-dl\win\_lstm_ops.so not found
	at org.tensorflow.TensorFlow.loadLibrary(TensorFlow.java:47)

We're trying to load contrib .so files dynamically from java API. These .so files are generated on Windows by installing tensorflow through pip. Using python 3.6.8 to do so and retrieving them from the library source code. These libraries are from tensorflow.contrib, since this is what we're using on our graphs. To me, this sounds like a path resolving issue, since it's the same error than making up an invented path.

Works fine when using appropriate .so files on Linux and Mac.

Same happens if using absolute paths btw:

java.lang.UnsatisfiedLinkError: C:\Users\saifa\IdeaProjects\spark-nlp\src\main\resources\ner-dl\win\_lstm_ops.so not found
	at org.tensorflow.TensorFlow.loadLibrary(TensorFlow.java:47)

It seems this also happened to this poor guy here:
https://stackoverflow.com/questions/50115117/using-ops-from-tensorflow-contrb-on-windows-via-java-api

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow):
    TensorFlow.loadLibrary("ner-dl/win/_lstm_ops.so")
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04):
    Windows 10
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
  • TensorFlow installed from (source or binary):
    Binary from pip
  • TensorFlow version (use command below):
    b'v1.12.0-rc2-3-ga6d8ffae09' 1.12.0
  • Python version:
    Using Java API
  • Bazel version (if compiling from source):
  • GCC/Compiler version (if compiling from source):
  • CUDA/cuDNN version:
  • GPU model and memory:

Describe the current behavior
Running
TensorFlow.loadLibrary("ner-dl/win/_lstm_ops.so")
returns

java.lang.UnsatisfiedLinkError: ner-dl\win\_lstm_ops.so not found
	at org.tensorflow.TensorFlow.loadLibrary(TensorFlow.java:47)

Describe the expected behavior
Should be able to load libraries dynamically on Windows. This works fine from Linux and Mac.

Code to reproduce the issue
Provide a reproducible test case that is the bare minimum necessary to generate the problem.
TensorFlow.loadLibrary("ner-dl/win/_lstm_ops.so")

@ymodak ymodak self-assigned this Mar 12, 2019
@ymodak ymodak added comp:apis Highlevel API related issues type:bug Bug labels Mar 12, 2019
@ymodak
Copy link
Contributor

ymodak commented Mar 12, 2019

@asimshankar Can you PTAL? Thanks!

@ymodak ymodak added the stat:awaiting tensorflower Status - Awaiting response from tensorflower label Mar 12, 2019
@asimshankar
Copy link
Contributor

Unfortunately, dynamic library loading in Windows is not supported yet AFAIR.
I might be mis-remembering, but dynamically loading shared libraries doesn't work on Python on Windows either, right?

@allenlavoie @sjamesr @gunan might have more details on this and might be able to explain what needs to happen to make this possible.

@gunan
Copy link
Contributor

gunan commented Mar 14, 2019

@meteorcloudy as he helped us a lot with shared objects on windows.
I think we finally had custom ops working on windows. Were they using loadLibrary?

@tensorflowbutler tensorflowbutler removed the stat:awaiting tensorflower Status - Awaiting response from tensorflower label Mar 15, 2019
@meteorcloudy
Copy link
Member

Dynamically loading shared libraries works in Python on Windows, but I never tired using Java API so it might still be not supported.

@ymodak ymodak closed this as completed Apr 6, 2019
@saif-ellafi
Copy link
Author

saif-ellafi commented Apr 6, 2019

Hi, I am still interested on this issue. Was closed by bot. Still happening.

@asimshankar
Copy link
Contributor

I noticed that the loadLibrary call is loading a .so file. Shouldn't it be loading a .dll file? Does ner-dl\win\_lstm_ops.so exist?

@saif-ellafi
Copy link
Author

saif-ellafi commented Apr 7, 2019

Yes, the file exists. the error is the same if you make up a file name. The same code works on linux and mac. I am not sure if it should be a .dll. If so, I'd like to know where to get the lstm contrib libs for windows.

However, most likely it is a path resolution error, with slashes and backslashes, because I noticed it converts windows slashes to unix ones.

@onewhl
Copy link

onewhl commented Apr 9, 2019

Hi everyone! I faced with the same problem when I tried to load "tf.contrib" using TensorFlow Java API on Windows (for Linux Ubuntu works fine).
I found answer how to solve this : link. But there is another problem -> unable to load model.
So, how do we solve this problem?

@ymodak ymodak reopened this Apr 9, 2019
@tensorflow tensorflow deleted a comment from tensorflow-bot bot Apr 9, 2019
@ymodak
Copy link
Contributor

ymodak commented May 7, 2019

@asimshankar Can you PTAL? Thanks!

@ymodak ymodak added the stat:awaiting tensorflower Status - Awaiting response from tensorflower label May 7, 2019
@asimshankar
Copy link
Contributor

@sjamesr : Could you take a look? (I haven't been working on TensorFlow for a while now :))

@sjamesr sjamesr assigned sjamesr and unassigned ymodak May 8, 2019
@carlosuc3m
Copy link

Has there been any advance on this?

@sjamesr
Copy link
Contributor

sjamesr commented Jul 8, 2019

Will take a look, sorry for the delay.

@tensorflowbutler tensorflowbutler removed the stat:awaiting tensorflower Status - Awaiting response from tensorflower label Jul 9, 2019
@asadkhilji
Copy link

Hi, is this problem resolved ?

@onewhl
Copy link

onewhl commented Sep 3, 2019

Hi @sjamesr, any updates on the issue?

@onewhl
Copy link

onewhl commented Nov 28, 2019

@sjamesr, @asimshankar, any updates?

@saif-ellafi
Copy link
Author

Hi, this issue is no longer valid since Tensorflow 1.15, given contrib libraries are handled differently.

@Saduf2019
Copy link
Contributor

@saif-ellafi
Please confirm if we may moved this to closed status.

@Saduf2019 Saduf2019 added the stat:awaiting response Status - Awaiting response from author label Jul 14, 2020
@maziyarpanahi
Copy link

@Saduf2019 I can confirm this issue can be closed. Me and Saif work on the same project and this issue is no longer presents in 1.15.x

Many thanks.

@saif-ellafi
Copy link
Author

I confirm this can be closed. Thanks

@google-ml-butler
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:apis Highlevel API related issues stat:awaiting response Status - Awaiting response from author type:bug Bug
Projects
None yet
Development

No branches or pull requests