Compile tensorflow 2.14 with clang16.0.2, cannot link the standard C++ library

71 Views Asked by At

I am trying to build the most simple tensorflow 2.14(CPU only) with clang 16.0.2(from the official repo) based on docker and ubuntu 22.04. I have successfully built tensorflow r2.12 and r2.13 but not r2.14

I followed the official tutorial to use the bazelisk with the command bazel clean --expunge && bazel build -c opt --cxxopt=-D_GLIBCXX_USE_CXX11_ABI=1 //tensorflow/tools/pip_package:build_pip_package

However, it keeps warning me that it cannot find the standard library:

ERROR: /root/.cache/bazel/_bazel_root/f3e6cea3d5621cddee645150a95a9495/external/llvm-project/llvm/BUILD.bazel:191:11: Compiling llvm/lib/Demangle/Demangle.cpp [for tool] failed: (Exit 1): clang failed: error executing command (from target @llvm-project//llvm:Demangle) /usr/lib/llvm-16/bin/clang -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics -fno-omit-frame-pointer -g0 ... (remaining 70 arguments skipped)
In file included from external/llvm-project/llvm/lib/Demangle/Demangle.cpp:13:
external/llvm-project/llvm/include/llvm/Demangle/Demangle.h:12:10: fatal error: 'cstddef' file not found
#include <cstddef>
         ^~~~~~~~~
1 error generated.
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: 0.324s, Critical Path: 0.12s
INFO: 39 processes: 36 internal, 3 local.
FAILED: Build did NOT complete successfully
1

There are 1 best solutions below

0
Xuxinyi On

Solution: If the Dockerfile has cuda installed then this error(building tensorflow-cpu) will happen.

Solved using tensorflow_build/tensorflow_runtime_dockerfiles.