BernardoGO
BernardoGO

Reputation: 1856

freeze_graph.py throws an error during build

I'm trying to build freeze_graph.py as specified on the readme part:

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

But after the first command, it throws this error:

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]$

I'm trying to run it to create a new .pb file to import in an Android project.

Upvotes: 0

Views: 1836

Answers (2)

BernardoGO
BernardoGO

Reputation: 1856

I have solved this issue by adding --copt=-O to the build command.

The whole command used to build freeze_graph was:

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

Upvotes: 0

David Wong
David Wong

Reputation: 748

From the error it's saying it wants you to bazel build with "-O" option to get the optimized build.

Upvotes: 0

Related Questions