【发布时间】:2016-11-06 16:14:45
【问题描述】:
对于脚本:
import tensorflow as tf;
class ZeroOutTest(tf.test.TestCase):
def testZeroOut(self):
zero_out_module = tf.load_op_library('/Users/sahilsingla/tensorflow/bazel-bin/tensorflow/core/user_ops/zero_out.so')
with self.test_session():
result = zero_out_module.zero_out([5, 4, 3, 2, 1])
value = result.eval()
self.assertAllEqual(value, [5, 0, 0, 0, 0])
if name == "main":
tf.test.main()
这与 tensorflow 文档“创建新操作”中给出的脚本相同,https://www.tensorflow.org/versions/r0.11/how_tos/adding_an_op/index.html
当我运行时:bazel test tensorflow/python/kernel_tests:zero_out_op_test
我收到错误:tensorflow.python.framework.errors.NotFoundError: dlopen(zero_out.so, 6): image not found.
有趣的是,当我这样做时,它确实会加载:
python -c "import tensorflow as tf;
zero_out_module = tf.load_op_library('/Users/sahilsingla/tensorflow/bazel-bin/tensorflow/core/user_ops/zero_out.so')"
但不加载 bazel 测试。
谁能建议我做错了什么?如何消除此错误?
【问题讨论】:
-
“正确”的做法是使用相对路径,并在
BUILD文件中添加依赖项以确保zero_out.so可用。但是奇怪的是绝对路径不起作用....您可以使用strace -Ttf -e trace=open bazel test运行以查看它试图打开的文件 -
现已解决。我不得不更改构建规则。
-
@YaroslavBulatov:虽然它不适用于相对路径。我必须指定 zero_out.so 的绝对路径才能让它工作。知道如何让它工作吗?
标签: testing tensorflow bazel