我在tensorflow文档中显示: https://www.tensorflow.org/how_tos/adding_an_op/#attrs
zero_out.cc
tensorflow/core/user_ops/
个文件
BUILD
tensorflow/core/user_ops/
个文件
$ bazel build -c opt //tensorflow/core/user_ops:zero_out.so
信息:找到1个目标......
目标//tensorflow/core/user_ops:zero_out.so最新:
巴泽尔斌/ tensorflow /核心/ user_ops中/ zero_out.so
信息:经过时间:0.125s,关键路径:0.00s
但是当我在python中运行以下代码时,出现错误:
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcurand.so locally
>>> zero_out_module = tf.load_op_library('zero_out.so')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/yc/tfenv/local/lib/python2.7/site-packages/tensorflow/python/framework/load_library.py", line 64, in load_op_library
None, None, error_msg, error_code)
tensorflow.python.framework.errors_impl.NotFoundError: zero_out.so: cannot open shared object file: No such file or directory
答案 0 :(得分:0)
Bazel会将op库生成到bazel-bin
文件夹中。
当你使用bazel构建ot时,你应该尝试从那里加载它:
zero_out_module = tf.load_op_library('bazel-bin/tensorflow/user_ops/zero_out.so')