TensorFlow does not work in debug mode

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

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

However, if the assembly fails, the error is lower:

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

cc1: all warnings are treated as errors

Target // tensorflow / python / kernel_tests: crash sparse_matmul_op_test build

We tried the following options to solve this problem:

  • created 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

  • I tried commenting on the flag compiler from third_party / gpus / crosstool / CROSSTOOL.tpl

What is the correct way to suppress these warnings to continue building?

We are using gcc v5.4.0.

+4
source share
2 answers

I had the same issue recently. It was solved by adding commands --copt=-Oand -c optto build a team.

Example:

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

@BernardoGO's solution does not work when the CUDA build is enabled:

$ 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".

It works only if it --copt=-Ois replaced by --copt=-O1, but -O1too much for convenient debugging.

0

Source: https://habr.com/ru/post/1660368/


All Articles