将新操作添加到google colab上的tensorflow

问题描述 投票:0回答:1

我正在尝试在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.
tensorflow word2vec google-colaboratory embedding
1个回答
0
投票

您可以使用以下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```
© www.soinside.com 2019 - 2024. All rights reserved.