【问题标题】:TensorFlow doesnt build with debug modeTensorFlow 不使用调试模式构建
【发布时间】:2016-11-10 04:49:20
【问题描述】:

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

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

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

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

cc1:所有警告都被视为错误

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

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

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

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

  3. 尝试从 third_party/gpus/crosstool/CROSSTOOL.tpl 评论 compiler_flag

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

我们正在使用 gcc v5.4.0。

【问题讨论】:

    标签: gcc tensorflow gcc-warning


    【解决方案1】:

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

    例子:

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

    【讨论】:

      【解决方案2】:

      启用 CUDA 构建时@BernardoGO 的解决方案不起作用:

      $ bazel build --copt=-O -c opt --config cuda -c dbg --strip=never //tensorflow/tools/pip_package:build_pip_package -s
      
      /usr/include/c++/6/bits/stl_pair.h(327): error: calling a __host__ function("std::_Rb_tree_const_iterator< ::tensorflow::NcclManager::NcclStream *> ::_Rb_tree_const_iterator") from a __device__ function("std::pair< ::std::_Rb_tree_const_iterator< ::tensorflow::NcclManager::NcclStream *> , bool> ::pair< ::std::_Rb_tree_iterator< ::tensorflow::NcclManager::NcclStream *>  &, bool &, (bool)1> ") is not allowed
      
      /usr/include/c++/6/bits/stl_pair.h(327): error: identifier "std::_Rb_tree_const_iterator< ::tensorflow::NcclManager::NcclStream *> ::_Rb_tree_const_iterator" is undefined in device code
      
      /usr/include/c++/6/bits/stl_algobase.h(1009): error: calling a __host__ function("__builtin_clzl") from a __device__ function("std::__lg") is not allowed
      
      3 errors detected in the compilation of "/tmp/tmpxft_00007abb_00000000-6_nccl_manager.cpp1.ii".
      

      仅当--copt=-O 替换为--copt=-O1 时才有效,但-O1 对于舒适的调试来说太多了。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-09-25
        • 1970-01-01
        • 1970-01-01
        • 2011-10-23
        • 1970-01-01
        • 2016-09-01
        相关资源
        最近更新 更多