【问题标题】:add new op to tensorflow on google colab在 google colab 上向 tensorflow 添加新操作
【发布时间】:2019-01-08 08:59:38
【问题描述】:

我正在尝试在 google colab 上编译一些 .cc 文件(如图所示 herehere)但我找不到要包含的 op.h 文件 编译时出现以下错误:

word2vec_ops.cc:16:10: fatal error: tensorflow/core/framework/op.h: No such file or directory
#include "tensorflow/core/framework/op.h"
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
word2vec_kernels.cc:16:10: fatal error: tensorflow/core/framework/op.h: No such file or directory
#include "tensorflow/core/framework/op.h"
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

【问题讨论】:

  • 头文件在“/usr/local/lib/python3.6/dist-packages/tensorflow/include/”中,但它们相互引用了很多次!改变所有这些都无济于事

标签: tensorflow word2vec google-colaboratory embedding


【解决方案1】:

您可以使用以下 gcc 命令在 google colab 上编译 .cc 文件:

$ gcc -Wl,-R/path/to/lib -I/path/to/include -L/path/to/lib -o myAppName mycode.c -llibapp2

通过

找到你的库包含路径
import tensorflow as tf
tf.sysconfig.get_include()

例子:

!g++ -std=c++11 -I /usr/local/lib/python3.6/dist-packages/tensorflow_core/include -shared word2vec_ops.cc word2vec_kernels.cc -o word2vec_ops.so -fPIC ${TF_CFLAGS[@]} ${TF_LFLAGS[@]} -O2```

【讨论】:

    猜你喜欢
    • 2020-05-08
    • 2020-11-28
    • 1970-01-01
    • 1970-01-01
    • 2018-10-09
    • 2014-02-18
    • 1970-01-01
    • 1970-01-01
    • 2020-03-15
    相关资源
    最近更新 更多