Using ops from Tensorflow.contrb on Windows via Java API

杀马特。学长 韩版系。学妹 提交于 2021-02-10 20:11:10

问题


I would like to load an op from tf.contrib, specifically "_beam_search_ops". I use Tensorflow 1.6 from Maven.

Following the answer at Issue while loading/serving tensorflow model in java using estimators , I'm able to do so on Ubuntu 17.10.

The code looks like so:

TensorFlow.loadLibrary("_beam_search_ops.so");

Then I try to do the same in Windows 10 with code

TensorFlow.loadLibrary("_beam_search_ops.dll");

And it fails with

java.lang.UnsatisfiedLinkError: D:\Users\ALEXAN~1\AppData\Local\Temp\deep_api_plugin\_beam_search_ops.dll not found
    at org.tensorflow.TensorFlow.loadLibrary(TensorFlow.java:47)

So what is the reason for this?


回答1:


While I was writing and researching the question, I've stumbled on the solution.

In order to resolve the problem, a _pywrap_tensorflow_internal.pyd file should be copied to the folder where _beam_search_ops.dll resides. I understand that this is also some kind of dll, but do not understand why it is necessary for Windows and not for Ubuntu. If anyone happens to know, please enlighten me.

Also I understand that this sort of additional information should be provided in a comment to the original answer, but unfortunately I do not have enough reputation to comment and thought this answer could help someone.

Edit: I was too quick to celebrate. With this answer a library is loaded without exception, but the model cannot seem to use it, failing with

Exception in thread "main" org.tensorflow.TensorFlowException: Op type not registered 'GatherTree' in binary running on DESKTOP-EB6GIDR. Make sure the Op and Kernel are registered in the binary running in this process.
    at org.tensorflow.SavedModelBundle.load(Native Method)
    at org.tensorflow.SavedModelBundle.load(SavedModelBundle.java:39)

Search for answer should continue.



来源:https://stackoverflow.com/questions/50115117/using-ops-from-tensorflow-contrb-on-windows-via-java-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!