【问题标题】:Error while trying to use tensorflow's C++ API尝试使用 tensorflow 的 C++ API 时出错
【发布时间】:2016-08-29 17:29:26
【问题描述】:

我在使用 TensorFlow 时遇到了一点问题。我必须将使用 TF 的代码集成到已经存在的项目(使用 Makefile)中。所以这就是我所做的。

我从源头获得了 TF 并按照on the TF site. 的描述安装了它

然后我建立了一个共享库:

bazel build //tensorflow:libtensorflow.so

完成此操作后,我将以下行添加到 Makefile:

CFLAGS += -I/home/alpy/tensorflow/bazel-genfiles
CFLAGS += -I/home/alpy/tensorflow/
CFLAGS += -I/home/alpy/tensorflow/third_party/eigen3

LDFLAGS += -L/home/alpy/tensorflow/bazel-bin/tensorflow
LDFLAGS += -ltensorflow 

当我尝试成功时,我得到了这个奇妙的错误:link

编辑:我忘了解释一些东西。我在 Linux 上,所以编译器应该区分大小写。我检查了我的文件和 TF 文件,它们似乎都有#ifndef 保护。

编辑:根据我的建议,我将错误直接添加到帖子中:

In file included from /home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1:0,
                 from /home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1,
                 from /home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1,
                 from /home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1,
                 from /home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1,
                 from /home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1,
                 from /home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1,
                 from /home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1,
                 from /home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1,
[...]

  from /home/alpy/tensorflow/tensorflow/core/public/session.h:23,
                 from ../src/conversion.h:11,
                 from ../src/detect_fast_C.cpp:43:
/home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1:42: error: #include nested too deeply
In file included from /home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1:0,
                 from /home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1,
                 from /home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1,
                 from /home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1,
                 from /home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1,
[...]
             from /home/alpy/tensorflow/tensorflow/core/framework/types.h:23,
                 from /home/alpy/tensorflow/tensorflow/core/framework/type_traits.h:22,
                 from /home/alpy/tensorflow/tensorflow/core/framework/allocator.h:25,
                 from /home/alpy/tensorflow/tensorflow/core/framework/tensor.h:21,
                 from /home/alpy/tensorflow/tensorflow/core/public/session.h:23,
                 from ../src/conversion.h:11,
                 from ../src/detect_fast_C.cpp:43:
/home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1:42: error: #include nested too deeply

(这会持续一段时间)

【问题讨论】:

    标签: c++ makefile tensorflow bazel


    【解决方案1】:

    我认为您不应该添加所有这些 -I 包括

    您可以查看 bazel 构建系统中的参考 C++ 示例。

    cc_binary。 https://github.com/tensorflow/tensorflow/blob/master/tensorflow/cc/BUILD#L264

    标志: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/tensorflow.bzl#L111

    您可以使用-s 选项运行bazel build,以查看为构建目标而发出的实际命令。

    【讨论】:

    • 当我避免 -I 包含时,我会收到以下错误:t ensorflow/core/public/session.h: No such file or directory
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-01
    • 2021-02-24
    • 1970-01-01
    • 2018-04-14
    • 1970-01-01
    • 2022-06-27
    相关资源
    最近更新 更多