tensorflow / ngraph-bridge

TensorFlow-nGraph bridge
Other
137 stars 64 forks source link

Building ngraph-bridge with GCC 4.8.5 and using TensorFlow v1.15.x. fails due to "c++14" api calls by MLIR. #492

Closed ashahba closed 4 years ago

ashahba commented 4 years ago

While working on upgrading TensorFlow to v1.15.0 I noticed any attempt to build TF on GCC 4.8.5 failed with:

cc1plus: warning: command line option '-Wno-implicit-function-declaration' is valid for C/ObjC but not for C++ [enabled by default]
cc1plus: warning: unrecognized command line option "-Wno-shift-negative-value" [enabled by default]
ERROR: /root/.cache/bazel/_bazel_root/b2507dc3eab2b61a24c0cd86dae84c09/external/local_config_mlir/BUILD:1508:1: C++ compilation of rule '@local_config_mlir//:TableGen' failed (Exit 1)
gcc: error: unrecognized command line option '-std=c++14'
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 15.813s, Critical Path: 1.53s
INFO: 359 processes: 359 local.
FAILED: Build did NOT complete successfully
Traceback (most recent call last):
  File "build_tf.py", line 87, in <module>
    main()
  File "build_tf.py", line 68, in main
    False)
  File "/root/ngraph-bridge/tools/build_utils.py", line 231, in build_tensorflow
    command_executor(cmd)
  File "/root/ngraph-bridge/tools/build_utils.py", line 60, in command_executor
    raise Exception("Error running command: " + cmd)
Exception: Error running command: bazel build --config=opt --config=noaws --config=nohdfs --config=noignite --config=nokafka --config=nonccl //tensorflow/tools/pip_package:build_pip_package

This indicates that there are clearly c++14 calls during TF build which is not supported by GCC 4.8.5.

A quick scan of the TensorFlow r1.15 branch shows that:

tensorflow/compiler/mlir
tensorflow/compiler/mlir/lite
tensorflow/compiler/mlir/lite/python
tensorflow/compiler/mlir/lite/quantization
tensorflow/compiler/mlir/tensorflow
tensorflow/compiler/mlir/xla
third_party/mlir
third_party/mlir/test
third_party/toolchains/clang6

All need to be compiled with copts = ["-std=c++14"] which is not available on GCC 4.8.5 Here is one example: https://github.com/tensorflow/tensorflow/blob/r1.15/tensorflow/compiler/mlir/BUILD#L25

Surprisingly enough, for TF 2.0 branch they don’t have that option set anywhere, but it’s globally set in master now for all platforms going forward: https://github.com/tensorflow/tensorflow/blob/master/.bazelrc#L254

So chances are TensorFlow v1.15.x and TensorFlow v2.1.x can only be used with GCC 5 and newer.

ashahba commented 4 years ago

As of now with TF v1.15.0 buildkite runs for centos would fail due to the GCC requirement.

ashahba commented 4 years ago

The decision was to remove c++11 support as TensorFlow v2.x has done and upgrade to c++14 i.e GCC 7.x.