Search code examples
tensorflowcpux86-64bazel

When running with Bazel, where should I save .pb graphs for Tensorflow?


Directory structure:

~/tensorflow/tensorflow/cc/dnnops/
├── BUILD
├── graph.pb
└── main.cc

The failing code line from main.cc: status = ReadBinaryProto(tf::Env::Default(), "graph.pb", &graph_def);. Full code can be found here.

Bazel output:

WARNING: /home//.cache/bazel/_bazel_rd1/4ab077b6e1a2076b6ea9f23b417088a6/external/protobuf_archive/WORKSPACE:1: Workspace name in /home//.cache/bazel/bazel/4ab077b6e1a2076b6ea9f23b417088a6/external/protobuf_archive/WORKSPACE (@com_google_protobuf) does not match the name given in the repository's definition (@protobuf_archive); this will cause a build error in future versions INFO: Analysed target //tensorflow/cc/dnnops:dnnops (0 packages loaded). INFO: Found 1 target... Target //tensorflow/cc/dnnops:dnnops up-to-date: bazel-bin/tensorflow/cc/dnnops/dnnops INFO: Elapsed time: 5.378s, Critical Path: 5.04s INFO: 2 processes, local. INFO: Build completed successfully, 3 total actions

INFO: Running command line: bazel-bin/tensorflow/cc/dnnops/dnnops Not found: graph.pb; No such file or directory ERROR: Non-zero return code '1' from command: Process exited with status 1

What I tried

Copy the same graph file inside bazel-bin/tensorflow/cc/dnnops. Still fails with same output from Bazel.

Question

How should I expose the graph file location to Tensorflow/Bazel?


Solution

  • Silly oversight... I entered the full path. From this:

    status = ReadBinaryProto(tf::Env::Default(), "graph.pb", &graph_def);

    To this:

    status = ReadBinaryProto(tf::Env::Default(), "/home/<user>/path/to/graph.pb", &graph_def);