"freeze_graph.py编译时出现错误"

2024-06-28 20:06:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我在试着冷冻_图形.py如自述部分所述:

bazel build tensorflow/python/tools:freeze_graph && \ bazel-bin/tensorflow/python/tools/freeze_graph \ --input_graph=some_graph_def.pb \ --input_checkpoint=model.ckpt-8361242 \ --output_graph=/tmp/frozen_graph.pb --output_node_names=softmax

https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/freeze_graph.py

但是在第一个命令之后,它抛出了以下错误:

ERROR: /home/bernardo/.cache/bazel/_bazel_bernardo/6ec3db0a5b478824b301f4851c10d381/external/boringssl/BUILD:91:1: C++ compilation of rule '@boringssl//:crypto' failed: gcc failed: error executing command /usr/bin/gcc -U_FORTIFY_SOURCE '-D_FORTIFY_SOURCE=1' -fstack-protector -Wall -Wl,-z,-relro,-z,now -B/usr/bin -B/usr/bin -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-canonical-system-headers ... (remaining 42 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1. In file included from /usr/include/stdint.h:25:0, from /usr/lib/gcc/x86_64-pc-linux-gnu/6.2.1/include/stdint.h:9, from external/boringssl/src/include/openssl/base.h:60, from external/boringssl/src/include/openssl/chacha.h:18, from external/boringssl/src/crypto/chacha/chacha.c:17: /usr/include/features.h:331:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp] # warning _FORTIFY_SOURCE requires compiling with optimization (-O) ^~~~~~~ cc1: all warnings being treated as errors Target //tensorflow/python/tools:freeze_graph failed to build Use --verbose_failures to see the command lines of failed build steps. INFO: Elapsed time: 0.485s, Critical Path: 0.24s [bernardo@foobar-pc tensorflow]$

我试着运行它来创建一个新的.pb文件来导入Android项目。在


Tags: frombuildsourcebinincludeusrtensorflowtools
2条回答

从错误中可以看出,它希望您使用“-O”选项进行bazel构建以获得优化的构建。在

我通过在build命令中添加 copt=-O解决了这个问题。在

用于构建冻结图形的整个命令是:

bazel build  copt=-O  config=cuda  tensorflow/python/tools:freeze_graph

相关问题 更多 >