tensorflow: graph.pb.h missing

The issue is quite simple: I downloaded and built TF from source, but the include files like tensorflow/core/public/session.h reference non-existing files. One culprit is tensorflow/core/framework/graph.pb.h. Attempted compilation produces the following error:

22:31:27 **** Build of configuration Debug for project hello_world **** make all make: Warning: File `objects.mk’ has modification time 1,8e+02 s in the future Building file: …/src/hello_world.cpp Invoking: GCC C++ Compiler g++ -I/home/sander/tensorflow -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/hello_world.d" -MT"src/hello_world.d" -o “src/hello_world.o” “…/src/hello_world.cpp” In file included from …/src/hello_world.cpp:8:0: /home/sander/tensorflow/tensorflow/core/public/session.h:22:48: fatal error: tensorflow/core/framework/graph.pb.h: No such file or directory #include “tensorflow/core/framework/graph.pb.h” ^ compilation terminated.

I cannot rule out a mistake on my part, but I’ve tried a bunch of things to no avail. Either a file is missing or there may be a linking issue. Any help would be greatly appreciated.

Environment info

Operating System: Ubuntu 14.04

Installed version of CUDA and cuDNN: None

If installed from binary pip package, provide:

  1. Which pip package you installed. I followed these steps:

1 git clone --recurse-submodules https://github.com/tensorflow/tensorflow

2 run ./configure

3 bazel build -c opt //tensorflow/tools/pip_package:build_pip_package

4 bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

5 pip install /tmp/tensorflow_pkg/tensorflow-0.7.1-py2-none-linux_x86_64.whl

  1. The output from python -c “import tensorflow; print(tensorflow.version)”. 0.7.1

If installed from sources, provide the commit hash: not sure, retrieved on 11 april from terminal: $ git clone --recurse-submodules https://github.com/tensorflow/tensorflow

Steps to reproduce

  1. The error occurs simply when any file from TF is included in c++ example: #include “tensorflow/core/public/session.h”

What have you tried?

  1. Reinstall/upgrade: pip, bazel, tensorflow, gcc/g++, add additional include paths

Logs or other output that would be helpful

(If logs are large, please upload as attachment).

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 31 (4 by maintainers)

Most upvoted comments

@SanderDalm After you created the bazel-gen files, what did you do for your application to build? Did you add the bazel-gen files in your include path? Did it work after that? How did you avoid rebuilding TF again?

I have a C++ project that contains several subfolders of *.h and *.cpp files. I think that creating a BUILD file for such a project will not be the fastest way to solve the issue. @mrry

tensorflow/core/framework/graph.pb.h is a generated file: it should be produced in the bazel-genfiles/tensorflow/core/framework directory when you build TensorFlow using Bazel.

Building from source without using Bazel is not fully supported right now, but you could try adding -I/home/sander/tensorflow/bazel-genfiles to your g++ arguments (assuming you have previously build TF from source).

@jkravanja This is some bash code I use to copy the necessary files for compiling a separate project (after having built tensorflow):

cp -r $TENSORFLOW_DIR/tensorflow include/third_party
cp -r $TENSORFLOW_DIR/bazel-genfiles/tensorflow include/third_party
cp -r $TENSORFLOW_DIR/bazel-tensorflow/../../external/protobuf/src/google include/third_party
cp -r $TENSORFLOW_DIR/third_party/eigen3 include/third_party
cp -r $TENSORFLOW_DIR/bazel-tensorflow/../../external/eigen_archive/. include/third_party/eigen3
cp -r include/third_party/eigen3/Eigen include/third_party

where TENSORFLOW_DIR is the directory where you cloned the tensorflow repository (for example /opt/tensorflow), and include/third_party is the directory to include when compiling your project (-I include/third_party). This script probably copies a lot more files than the strictly necessary, but it works for me.

@SanderDalm @YorksonChang @mrry

This is a simple Neural Network I created using C++ Tensorflow. I also created a makefile for compiling the source code via (g++); I think that this makefile will be helpful for you to understand how to build the code. simpleNetwork.zip

Because I inserted absolute paths, you need to insert your own paths in the makefile.

Best of luck and let me know if you have more questions!

PS: I extended the following tutorial: https://medium.com/jim-fleming/loading-a-tensorflow-graph-with-the-c-api-4caaff88463f