TensorFlow freeze_graph找不到.runfiles

时间:2018-01-03 16:53:49

标签: tensorflow tensorflow-serving

我使用Bazel从源代码构建了TensorFlow,但是,当我尝试运行freeze_graph脚本时,我收到了请求.runfiles的错误

这是我的跑步命令

python /home/olu/TensorFlow_Source/tensorflow/bazel-bin/tensorflow/python/tools/freeze_graph --input_graph=graph.pbtx --input_checkpoint=model.ckpt-0.data-00000-of-00001 --input_binary=false --output_graph=../frozen_graph/frozen_graph.pb --output_node_names=ArgMax

这是它产生的错误:

Traceback (most recent call last):
File "/home/olu/TensorFlow_Source/tensorflow/bazel-bin/tensorflow/python/tools/freeze_graph", line 172, in <module>
Main()
File "/home/olu/TensorFlow_Source/tensorflow/bazel-bin/tensorflow/python/tools/freeze_graph", line 111, in Main
module_space = FindModuleSpace()
File "/home/olu/TensorFlow_Source/tensorflow/bazel-bin/tensorflow/python/tools/freeze_graph", line 86, in FindModuleSpace
raise AssertionError('Cannot find .runfiles directory for %s' % sys.argv[0])
AssertionError: Cannot find .runfiles directory for /home/olu/TensorFlow_Source/tensorflow/bazel-bin/tensorflow/python/tools/freeze_graph

知道我可能做错了吗?

2 个答案:

答案 0 :(得分:1)

如果你使用bazel来构建freeze_graph,那么bazel-bin包含你的编译的 freeze_graph代码。这意味着您不需要使用python调用freeze_graph,您可以像这样运行它:

./home/olu/TensorFlow_Source/tensorflow/bazel-bin/tensorflow/python/tools/freeze_graph  ...

您可以通过调用:

来运行python文件目录
python /path/to/freeze_graph.py ...

希望有所帮助!

答案 1 :(得分:1)

对于我来说,我遇到了同样的错误,我需要构建Frozen_graph 1st:

bazel build tensorflow/python/tools:freeze_graph

此后,您可以通过以下方式运行它:

bazel-bin/tensorflow/python/tools/freeze_graph \ --input_graph=/tmp/inception_v3_inf_graph.pb \ --input_checkpoint=/tmp/checkpoints/inception_v3.ckpt \ --input_binary=true --output_graph=/tmp/frozen_inception_v3.pb \ --output_node_names=InceptionV3/Predictions/Reshape_1

大卫