compilation error: undefined reference to 'void tensorflow::ConcatCPU<tensorflow::bfloat16>...
I have been trying to install tensorflow-serving on Rasberry Pi 3 from source code. However, I got the following compilation error:
ERROR: /root/serving/tensorflow_serving/servables/hashmap/BUILD:39:1: Linking of rule '//tensorflow_serving/servables/hashmap:hashmap_source_adapter_test' failed (Exit 1)
bazel-out/arm-opt/bin/external/org_tensorflow/tensorflow/core/kernels/_objs/list_kernels/external/org_tensorflow/tensorflow/core/kernels/list_kernels.o:list_kernels.cc:function tensorflow::TensorListStack<Eigen::ThreadPoolDevice, tensorflow::bfloat16>::Compute(tensorflow::OpKernelContext*): error: undefined reference to 'void tensorflow::ConcatCPU<tensorflow::bfloat16>(tensorflow::DeviceBase*, std::vector<std::unique_ptr<tensorflow::TTypes<tensorflow::bfloat16, 2, int>::ConstMatrix, std::default_delete<tensorflow::TTypes<tensorflow::bfloat16, 2, int>::ConstMatrix> >, std::allocator<std::unique_ptr<tensorflow::TTypes<tensorflow::bfloat16, 2, int>::ConstMatrix, std::default_delete<tensorflow::TTypes<tensorflow::bfloat16, 2, int>::ConstMatrix> > > > const&, tensorflow::TTypes<tensorflow::bfloat16, 2, int>::Matrix*)'
The system information of pi 3 is Linux version 4.14.30-v7+ (dc4@dc4-XPS13-9333) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611)) #1102 SMP Mon Mar 26 16:45:49 BST 2018
and bazel version is 0.11.1- (@non-git).
Is there anyone who know how to solve this problem? Thanks in advance!
I have the same problem
Me too.
Looks like there is a solution here. I am trying it now.
I solved this problem. I used bazel 0.5.1 (the 0.5.2+ releases ends with an error) to build tensorflow 1.3
I also faced the same problem.
I face the same problem with Bazel 0.15.2 and Tensorflow 1.9. The issue is closed, but I can't find out the solution, please, does anybody know it?.
Since it's failing to build TensorFlow, you might want to try: https://github.com/tensorflow/tensorflow/issues/17790#issuecomment-392185433
@gautamvasudevan Could you please give us clear message? Does tensorflow/tensorflow#17790 (comment) solve undefined symbol error for ConcatCPU?
Yes, I would follow those instructions for fixing the issue. That said, we don't (yet) officially support Tensorflow Serving on Raspberry Pi, so your mileage may vary.
A quick update for people who has similar problem. When RASPBERRY_PI or ARM_NON_MOBILE is defined, ConcatCPU template is instantiated for tensorflow::bfloat16 explicitly. If both RASPBERRY_PI and ARM_NON_MOBILE are not defined, IS_MOBILE_PLATFORM is defined, and ConcatCPU template is instantiated for types except tensorflow::bfloat16 and some other types in ./tensorflow/core/framework/register_types.h.
The correct solution is to define the macro in the build command. However, I found out that the bazel build does not take the defined macro as expected using command line provided by tensorflow/tensorflow#17790. But if I comment out all places where IS_MOBILE_PLATFORM defined, the compilation is successful. However, it is not correct way of doing it. I am still trying to figure out why bazel build command has problem.
I saw this building TensorFlow 1.13.1 with Bazel 0.21.0 for Python 3.7.3.
A local workaround for this error is edit tensorflow/core/kernels/concat_lib_cpu.cc to explicitly instantiate the ConcatCPU template for the bfloat16 type (diff below). The advantage being that your build can continue without causing unintended effects or rebuilding many files.
Note that removing the definition of IS_MOBILE_PLATFORM will work, per @gittripley, but may cause the instantiation for many types, such as complex128, that you may or may not want for your embedded build (see the first #if in tensorflow/core/framework/register_types.h) -- a variant of that approach might be to leave IS_MOBILE_PLATFORM defined, but include more non-empty #defines for the corresponding #else branch in register_types.h.
diff --git a/tensorflow/core/kernels/concat_lib_cpu.cc b/tensorflow/core/kernels/concat_lib_cpu.cc
index 547a7b40b9..04436da24d 100644
--- a/tensorflow/core/kernels/concat_lib_cpu.cc
+++ b/tensorflow/core/kernels/concat_lib_cpu.cc
@@ -73,6 +73,7 @@ REGISTER(qint8)
REGISTER(quint16)
REGISTER(qint16)
REGISTER(qint32)
+REGISTER(tensorflow::bfloat16)
#if defined(IS_MOBILE_PLATFORM) && !defined(SUPPORT_SELECTIVE_REGISTRATION) && \
!defined(__ANDROID_TYPES_FULL__)
Alternative search terms (I experienced this error at link time, not compile time): _ZN10tensorflow9ConcatCPUINS_8bfloat16EEEvPNS_10DeviceBaseERKSt6vectorISt10unique_ptrINS_6TTypesIT_Li2EiE11ConstMatrixESt14default_deleteIS9_EESaISC_EEPNS8_6MatrixE