通过 Java API 在 Windows 上使用来自 Tensorflow.contrb 的操作 [英] Using ops from Tensorflow.contrb on Windows via Java API
问题描述
我想从 tf.contrib
加载一个 op
,特别是_beam_search_ops".我使用来自 Maven 的 Tensorflow 1.6.
I would like to load an op
from tf.contrib
, specifically "_beam_search_ops". I use Tensorflow 1.6 from Maven.
按照 问题中的答案进行操作在使用 estimators 在 java 中加载/提供 tensorflow 模型时,我可以在 Ubuntu 17.10 上这样做.
Following the answer at Issue while loading/serving tensorflow model in java using estimators , I'm able to do so on Ubuntu 17.10.
代码如下:
TensorFlow.loadLibrary("_beam_search_ops.so");
然后我尝试在 Windows 10 中用代码做同样的事情
Then I try to do the same in Windows 10 with code
TensorFlow.loadLibrary("_beam_search_ops.dll");
它失败了
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)
这是什么原因呢?
推荐答案
在我撰写和研究问题时,我偶然发现了解决方案.
While I was writing and researching the question, I've stumbled on the solution.
为了解决这个问题,需要将一个_pywrap_tensorflow_internal.pyd
文件复制到_beam_search_ops.dll
所在的文件夹中.我知道这也是某种 dll
,但不明白为什么 Windows 需要它而不是 Ubuntu.如果有人碰巧知道,请赐教.
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.
我庆祝得太快了.有了这个答案,一个库无一例外地被加载,但模型似乎无法使用它,失败了
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)
应继续搜索答案.
这篇关于通过 Java API 在 Windows 上使用来自 Tensorflow.contrb 的操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!