TensorFlow不使用调试模式构建 [英] TensorFlow doesnt build with debug mode

查看:337
本文介绍了TensorFlow不使用调试模式构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试构建带有调试标志的TensorFlow测试用例:

We are trying to build a TensorFlow test case with debug flag:

bazel build -c dbg //tensorflow/python/kernel_tests:sparse_matmul_op_test

bazel build -c dbg //tensorflow/python/kernel_tests:sparse_matmul_op_test

但是构建失败并出现以下错误:

However the build is failing with below error:

/usr/include/features.h:330:4:错误:#warning _FORTIFY_SOURCE 需要进行优化(-O)编译[-Werror = cpp]
警告_FORTIFY_SOURCE需要进行优化编译(-O)

/usr/include/features.h:330:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp]
warning _FORTIFY_SOURCE requires compiling with optimization (-O)

cc1:将所有警告视为错误

cc1: all warnings being treated as errors

目标//tensorflow/python/kernel_tests:sparse_matmul_op_test失败 建立

Target //tensorflow/python/kernel_tests:sparse_matmul_op_test failed to build

我们尝试了以下选项来解决此问题:

We have tried below options to resolve this:

  1. 通过将导出CFLAGS和CXXFLAGS导出到"-Wno-error"来构建

  1. built by exporting export CFLAGS and CXXFLAGS to "-Wno-error"

bazel build -c dbg --cxxopt =-Wno-all" --cxxopt =-Wno-error"//tensorflow/python/kernel_tests:sparse_matmul_op_test

bazel build -c dbg --cxxopt="-Wno-all" --cxxopt="-Wno-error" //tensorflow/python/kernel_tests:sparse_matmul_op_test

尝试注释来自third_party/gpus/crosstool/CROSSTOOL.tpl的compiler_flag

Tried commenting compiler_flag from third_party/gpus/crosstool/CROSSTOOL.tpl

抑制这些警告以继续进行构建的正确方法是什么?

What is the correct way to suppress these warnings for the build to proceed?

我们正在使用gcc v5.4.0.

We are using gcc v5.4.0.

推荐答案

我最近遇到了同样的问题.通过在构建命令中添加--copt=-O-c opt可以解决此问题.

I've had the same issue recently. It got solved by adding --copt=-O and -c opt to the build command.

示例:

bazel build --copt=-O -c dbg -c opt //tensorflow/python/kernel_tests:sparse_matmul_op_test

这篇关于TensorFlow不使用调试模式构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆