【问题标题】:bazel test failing for tensorflow new op on MAC OS XMAC OS X 上 tensorflow 新操作的 bazel 测试失败
【发布时间】: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


【解决方案1】:

对于那些面临同样问题的人,我建议尝试使用
bazel build -c opt //tensorflow/g3doc/how_tos/adding_an_op:zero_out_op_kernel_1.so
bazel test //tensorflow/g3doc/how_tos/adding_an_op:zero_out_1_test
而不是 tensorflow 文档中给出的方式。
你会知道如何让它发挥作用。

【讨论】:

    猜你喜欢
    • 2013-11-28
    • 1970-01-01
    • 2015-07-10
    • 2013-09-20
    • 1970-01-01
    • 1970-01-01
    • 2013-02-12
    • 1970-01-01
    • 2012-04-26
    相关资源
    最近更新 更多