Why do I get error 'unrecognized command line option '-fuse-ld=--enable-gold=default' when building Tensorflow? - tensorflow

I am trying to build Tensorflow from source as described at: https://www.tensorflow.org/install/source
I have Bazel 0.29.1 and Python available. I do:
module load bazeltest/0.29.1
module load pythontest/gcc6.3.0/3.7.5tensorflow
./configure
I choose all default options in configure, then:
bazel build //tensorflow/tools/pip_package:build_pip_package
The build proceeds for a while, but fails at:
INFO: Analyzed target //tensorflow/tools/pip_package:build_pip_package (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: /gpfs01/home/cczcb/.cache/bazel/_bazel_cczcb/f0a4604cf88277481621943e2a61f102/external/swig/BUILD.bazel:5:1: Linking of rule '#swig//:swig' failed (Exit 1)
gcc: error: unrecognized command line option '-fuse-ld=--enable-gold=default'
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: 18.642s, Critical Path: 10.57s
INFO: 125 processes: 125 local.
FAILED: Build did NOT complete successfully
I have also tried:
bazel build --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" //tensorflow/tools/pip_package:build_pip_package
as I am using GCC 6.3.0 here. The result is the same, as it is when I use GCC 4.9.3.
My O/S is Centos 7.4.
Can anyone advise what might be amiss ?
thanks,
Colin

Related

Bazel can't find g++ despite both MSYS2 and native shell supporting it

I have installed Bazel through Chocolatey on Windows and MSYS2 to have access to bash.exe.
A script I am trying to build uses g++ which I installed through pacman in MSYS2 and also added to PATH. I am able to run g++ --version in both the MSYS2 shell and my native Powershell.
But somehow it seems as if MSYS2 can't run g++ when I am running it through Bazel.
C:/<censored>> bazel build //kernels:rasterize_triangles_kernel
INFO: Analyzed target //kernels:rasterize_triangles_kernel (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: C:/<censored>/kernels/BUILD:20:8: Executing genrule //kernels:rasterize_triangles_kernel failed: (Exit 127): bash.exe failed: error executing command (from target //kernels:rasterize_triangles_kernel) C:\msys64\usr\bin\bash.exe -c ... (remaining 1 argument skipped)
/usr/bin/bash: line 1: g++: command not found
Target //kernels:rasterize_triangles_kernel failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 4.883s, Critical Path: 4.80s
INFO: 2 processes: 2 internal.
FAILED: Build did NOT complete successfully

Problems with absl dependencies in TensorFlow print_selective_registration_header building

I'm trying to build //tensorflow/python/tools:print_selective_registration_header and get following output:
$ bazel build --copt="-DUSE_GEMM_FOR_CONV" tensorflow/python/tools:print_selective_registration_header
...
INFO: Analyzed target //tensorflow/python/tools:print_selective_registration_header (377 packages loaded, 24256 targets configured).
INFO: Found 1 target...
INFO: Deleting stale sandbox base /private/var/tmp/_bazel_glebdavydov/01d4cf1f69cd2606674d307a7a455e95/sandbox
ERROR: /Users/glebdavydov/Downloads/tensorflow-master/tensorflow/c/BUILD:372:1: undeclared inclusion(s) in rule '//tensorflow/c:ops':
this rule is missing dependency declarations for the following files included by 'tensorflow/c/ops.cc':
'tensorflow/contrib/makefile/downloads/absl/absl/strings/string_view.h'
'tensorflow/contrib/makefile/downloads/absl/absl/types/optional.h'
Target //tensorflow/python/tools:print_selective_registration_header failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 54.737s, Critical Path: 13.10s
INFO: 4 processes: 4 local.
FAILED: Build did NOT complete successfully
How can I fix this?
I fixed that issue by installing version of bazel corresponding to this build configurations.

How to build tensorflow benchmark tool

Following https://github.com/tensorflow/tensorflow/tree/master/tensorflow/tools/benchmark
bazel build -c opt --crosstool_top=//external:android/crosstool --cpu=armeabi-v7a --host_crosstool_top=#bazel_tools//tools/cpp:toolchain --config monolithic tensorflow/tools/benchmark:benchmark_model
I get
WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files:
/Users/user/external_projects/tensorflow/tools/bazel.rc
INFO: Options provided by the client:
Inherited 'common' options: --isatty=1 --terminal_columns=176
ERROR: Config value monolithic is not defined in any .rc file
How to fix it?
bazel version
WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files:
/Users/user/external_projects/tensorflow/tools/bazel.rc
Build label: 0.23.1
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Mon Mar 4 10:40:32 2019 (1551696032)
Build timestamp: 1551696032
Build timestamp as int: 1551696032
Update:
For fresh tensorflow master I get:
INFO: Analysed target //tensorflow/tools/benchmark:benchmark_model (71 packages loaded, 4664 targets configured).
INFO: Found 1 target...
ERROR: /private/var/tmp/_bazel_user/144c1461f36cde95de1693452c235294/external/com_google_absl/absl/types/BUILD.bazel:178:1: C++ compilation of rule '#com_google_absl//absl/types:bad_optional_access' failed (Exit 1)
clang: error: unknown argument: '-m<platform_for_version_min>-version-min=10.14'
Target //tensorflow/tools/benchmark:benchmark_model failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 98.302s, Critical Path: 18.67s
INFO: 399 processes: 399 local.
FAILED: Build did NOT complete successfully
Update 2:
On Ubuntu 16 and fresh tensorflow master:
bazel version
INFO: Invocation ID: 34e40dab-96b2-45ef-b549-dab45a2738bc
Build label: 0.22.0
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Mon Jan 28 12:58:08 2019 (1548680288)
Build timestamp: 1548680288
Build timestamp as int: 1548680288
Output:
WARNING: /data/user_data/external_projects/tensorflow/tensorflow/core/BUILD:1794:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/distributed_runtime:server_lib.h' directly. You should either move the file to this package or depend on an appropriate rule there
INFO: Analysed target //tensorflow/tools/benchmark:benchmark_model (72 packages loaded, 4809 targets configured).
INFO: Found 1 target...
INFO: From Compiling external/snappy/snappy-sinksource.cc [for host]:
cc1plus: warning: command line option '-Wno-implicit-function-declaration' is valid for C/ObjC but not for C++
INFO: From Compiling external/snappy/snappy-stubs-internal.cc [for host]:
cc1plus: warning: command line option '-Wno-implicit-function-declaration' is valid for C/ObjC but not for C++
INFO: From Compiling external/snappy/snappy.cc [for host]:
cc1plus: warning: command line option '-Wno-implicit-function-declaration' is valid for C/ObjC but not for C++
ERROR: /home/user/.cache/bazel/_bazel_user/b4774fbdb8542988b4e302c9e073f145/external/com_google_absl/absl/container/BUILD.bazel:529:1: C++ compilation of rule '#com_google_absl//absl/container:raw_hash_set' failed (Exit 1)
Target //tensorflow/tools/benchmark:benchmark_model failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 59.522s, Critical Path: 11.24s
INFO: 456 processes: 456 local.
FAILED: Build did NOT complete successfully
Which version of the NDK are you using? I used the following command line and it worked:
$ bazel build -c opt \
--crosstool_top=//external:android/crosstool \
--cpu=armeabi-v7a \
--host_crosstool_top=#bazel_tools//tools/cpp:toolchain \
--config monolithic \
--cxxopt=-std=c++11 \
tensorflow/tools/benchmark:benchmark_model
This is with Bazel 0.23.2 and NDK r17c on https://github.com/tensorflow/tensorflow/commit/7bd86377dedaf459d22b68363a0a2d4580180379.

Compile TensorFlow v1.8.0 cuda/include/cublas_v2.h: No such file or directory

When I compile TensorFlow v1.8
ERROR: /work/tensorflow/tensorflow/stream_executor/BUILD:52:1: C++ compilation of rule '//tensorflow/stream_executor:cuda_platform' failed (Exit 1)
tensorflow/stream_executor/cuda/cuda_blas.cc:16:36: fatal error: cuda/include/cublas_v2.h: No such file or directory
compilation terminated.
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: 119.973s, Critical Path: 43.00s
INFO: 3322 processes, local.
FAILED: Build did NOT complete successfully
I find /usr/local/cuda/include don't have this file. How can get it?
Running bazel clean --expunge and then compiling again seems to have fixed it for me.
Compiling tensorflow 1.12.3 with bazel 0.15.2

error bazel build in tensorflow

At first, I would like to use bazel to help me run tensorflow with SSE and avx so I tried this within work space:
bazel build -c opt --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-mfpmath=both --copt=-msse4.2 --config=cuda -k //tensorflow/tools/pip_package:build_pip_package
but it gives me a new error like following, I wonder what is wrong and what should I do? Thanks for help.
WARNING: Config values are not defined in any .rc file: cuda
ERROR: Skipping '//tensorflow/tools/pip_package:build_pip_package': no such package 'tensorflow/tools/pip_package': BUILD file not found on package path
WARNING: Target pattern parsing failed.
INFO: Analysed 0 targets (2 packages loaded).
INFO: Found 0 targets...
ERROR: command succeeded, but there were errors parsing the target pattern
INFO: Elapsed time: 2.727s, Critical Path: 0.02s
FAILED: Build did NOT complete successfully
You probably have an outdated bazel. I am not sure but you can try to use --config=opt instead of -c opt for initial versions.
You have to run ./configure. That will create a .bazelrc and .tf_configure.bazel file in your Tensorflow workspace.
The --config=cuda Bazel flag refers to entries in those two files (they are both text files). The entries typically look like this: build:cuda --some_bazel_flag.
It was answered here