PatWie/tensorflow-cmake

Undefined References

goncamateus opened this issue · 3 comments

Hey PatWie!
I'm facing a problem building any c/c++ code.
For example, when I run make in infereces/cc, it returns to me:

/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::DeviceMgr::DeviceMgr(std::unique_ptr<tensorflow::Device, std::default_delete<tensorflow::Device> >)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::data::model::MakeAsyncKnownRatioNode(tensorflow::data::model::Node::Args, double, std::vector<std::shared_ptr<tensorflow::data::model::Parameter>, std::allocator<std::shared_ptr<tensorflow::data::model::Parameter> > >)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::lookup::LookupInterface::CheckKeyTensorForRemove(tensorflow::Tensor const&)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::data::model::MakeUnknownNode(tensorflow::data::model::Node::Args)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::data::FunctionHandleCache::FunctionHandleCache(tensorflow::FunctionLibraryRuntime*)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::FunctionLibraryDefinition::ReachableDefinitions(tensorflow::FunctionDef const&) const'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::data::model::MakeParameter(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::shared_ptr<tensorflow::data::model::SharedState>, long long, long long)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::Placer::Placer(tensorflow::Graph*, tensorflow::DeviceSet const*, tensorflow::SessionOptions const*, tensorflow::Device const*)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::kernel_factory::OpKernelRegistrar::InitInternal(tensorflow::KernelDef const*, absl::string_view, std::unique_ptr<tensorflow::kernel_factory::OpKernelFactory, std::default_delete<tensorflow::kernel_factory::OpKernelFactory> >)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::Node::set_name(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::data::model::MakeAsyncInterleaveManyNode(tensorflow::data::model::Node::Args, std::vector<std::shared_ptr<tensorflow::data::model::Parameter>, std::allocator<std::shared_ptr<tensorflow::data::model::Parameter> > >)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::NodeDebugInfo::NodeDebugInfo(tensorflow::NodeDef const&)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::data::FunctionHandleCache::Instantiate(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, tensorflow::AttrSlice, tensorflow::FunctionLibraryRuntime::InstantiateOptions, unsigned long long*)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to google::protobuf::internal::DestroyMessage(void const*)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::shape_inference::InferenceContext::ExpandOutputs(int)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::OpKernel::DeviceNumaNode(tensorflow::DeviceBase const*)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::NodeDebugInfo::NodeDebugInfo(tensorflow::Node const&)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::NodeBuilder::NodeBuilder(absl::string_view, absl::string_view, tensorflow::OpRegistryInterface const*, tensorflow::NodeDebugInfo const*)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::data::GetAllocatedBytes(std::vector<tensorflow::Tensor, std::allocator<tensorflow::Tensor> > const&)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::data::FunctionHandleCache::~FunctionHandleCache()'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to stream_executor::dnn::TensorDescriptorProto::clear_layout_oneof()'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to stream_executor::dnn::AlgorithmProto::InternalSwap(stream_executor::dnn::AlgorithmProto*)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to stream_executor::dnn::AlgorithmProto::AlgorithmProto()'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::MergeDebugInfo(tensorflow::NodeDef const&, tensorflow::NodeDef*)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::StatusGroup::as_status() const'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to stream_executor::dnn::AlgorithmProto::AlgorithmProto(stream_executor::dnn::AlgorithmProto const&)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::DeviceFactory::AddDevices(tensorflow::SessionOptions const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<std::unique_ptr<tensorflow::Device, std::default_delete<tensorflow::Device> >, std::allocator<std::unique_ptr<tensorflow::Device, std::default_delete<tensorflow::Device> > > >*)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::FunctionLibraryDefinition::ReachableDefinitions(tensorflow::GraphDef const&) const'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::Tensor::HostScalarTensorBufferBase::FillAllocationDescription(tensorflow::AllocationDescription*) const'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::DumpGraphDefToFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, tensorflow::GraphDef const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::Device::Sync(std::function<void (tensorflow::Status const&)> const&)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to stream_executor::StreamExecutor::createRnnSequenceTensorDescriptor(int, int, int, absl::Span<int const> const&, stream_executor::dnn::DataType)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::MergeDebugInfo(tensorflow::NodeDebugInfo const&, tensorflow::NodeDef*)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to stream_executor::dnn::AlgorithmProto::~AlgorithmProto()'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::data::DatasetBase::DatasetGraphDefBuilder::AddInputDataset(tensorflow::data::SerializationContext*, tensorflow::data::DatasetBase const*, tensorflow::Node**)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to stream_executor::dnn::TensorDescriptorProto::~TensorDescriptorProto()'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::KernelDefBuilder::Priority(int)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::data::model::MakeSourceNode(tensorflow::data::model::Node::Args)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::NodeBuilder::XlaCluster(absl::string_view)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to google::protobuf::internal::OnShutdownRun(void (*)(void const*), void const*)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::data::model::MakeUnknownRatioNode(tensorflow::data::model::Node::Args)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to stream_executor::dnn::AlgorithmProto::CopyFrom(stream_executor::dnn::AlgorithmProto const&)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::SupportedDeviceTypesForNode(std::vector<tensorflow::DeviceType, std::allocator<tensorflow::DeviceType> > const&, tensorflow::NodeDef const&, absl::InlinedVector<std::pair<tensorflow::DeviceType, int>, 4ul, std::allocator<std::pair<tensorflow::DeviceType, int> > >*)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::NodeDefBuilder::NodeDefBuilder(absl::string_view, absl::string_view, tensorflow::NodeDebugInfo const&)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::NodeDefBuilder::NodeDefBuilder(absl::string_view, absl::string_view, tensorflow::OpRegistryInterface const*, tensorflow::NodeDebugInfo const*)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::DeviceMgr::DeviceMgr(std::vector<std::unique_ptr<tensorflow::Device, std::default_delete<tensorflow::Device> >, std::allocator<std::unique_ptr<tensorflow::Device, std::default_delete<tensorflow::Device> > > >)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::shape_inference::SparseReduceShapeFn(tensorflow::shape_inference::InferenceContext*)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::cpu_allocator(int)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::Node::UpdateProperties()'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::StatusGroup::Update(tensorflow::Status const&)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::thread::ThreadPool::ThreadPool(tensorflow::Env*, tensorflow::ThreadOptions const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, bool, Eigen::Allocator*)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::data::model::MakeInterleaveManyNode(tensorflow::data::model::Node::Args)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::MergeDebugInfo(tensorflow::NodeDebugInfo const&, tensorflow::Node*)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to vtable for tensorflow::data::model::Model'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to tensorflow::data::model::MakeKnownRatioNode(tensorflow::data::model::Node::Args, double)'
/home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so: undefined reference to typeinfo for tensorflow::Tensor::HostScalarTensorBufferBase'
collect2: error: ld returned 1 exit status
CMakeFiles/inference_cc.dir/build.make:96: recipe for target 'inference_cc' failed
make[2]: *** [inference_cc] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/inference_cc.dir/all' failed
make[1]: *** [CMakeFiles/inference_cc.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

I checked This issue but it doesn't to seem my problem. Both python's .so and c++'s .so commands returns the same thing.
I wonder if there's something wrong while linking the libtensorflow_cc.so, or something wrong on bazel build.
Cmake returns this:

-- Reuse cached information from TensorFlow 1.12.0 
-- [WARNING] The TensorFlow version  has a bug (see #22766). We disable asserts using -DNDEBUG=True 
-- TensorFlow-CC-LIBRARY is /home/mateus/tensorflow/tensorflow_dist/libtensorflow_cc.so
-- TensorFlow-SOURCE-DIRECTORY is /home/mateus/tensorflow
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mateus/tensorflow-cmake/inference/cc

Also, I'm using POP!OS 18.04, a variant of Ubuntu 18.04;CUDA 10.0; CUDNN 7.4.2.
Thank you for your time!
Sorry about the large issue :/

It seems all these symbols are missing and I am not sure how I can help. This is clearly a linking issue. Do you have the build log of TensorFlow? Does the TensorFlow pip package work?
Did you check your *.so file via nm -C lib.so | grep <query>

Where can I find the build log?
pip package works fine, but my packages are beeing installed in ~/.local/lib/python3.6/site-packages; is that ok?
I checked via these cmds:
1.

nm -C ~/tensorflow/tensorflow/tensorflow_dist/libtensorflow_cc.so | grep requested_device

nm -g ~/tensorflow/tensorflow/tensorflow_dist/libtensorflow_cc.so | grep requested_device

nm -C ~/.local/lib/python3.6/site-packages/tensorflow/libtensorflow_framework.so | grep requested_device

nm -g ~/.local/lib/python3.6/site-packages/tensorflow/libtensorflow_framework.so | grep requested_device

and they returned:
1.

             U tensorflow::Node::requested_device[abi:cxx11]() const
            U tensorflow::OpKernel::requested_device[abi:cxx11]() const
             U _ZNK10tensorflow4Node16requested_deviceB5cxx11Ev
           U _ZNK10tensorflow8OpKernel16requested_deviceB5cxx11Ev

00000000006558a0 T tensorflow::Node::set_requested_device(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)
0000000000651d20 T tensorflow::Node::requested_deviceabi:cxx11 const
00000000005fec80 T tensorflow::OpKernel::requested_deviceabi:cxx11 const

00000000006558a0 T _ZN10tensorflow4Node20set_requested_deviceERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
0000000000651d20 T _ZNK10tensorflow4Node16requested_deviceB5cxx11Ev
00000000005fec80 T _ZNK10tensorflow8OpKernel16requested_deviceB5cxx11Ev

Is this OK?

Just found the problem!
I compiled python's lib checking out tensorflow's branch to r1.12. I just realized that I was on master.
Thank you for answering!