Skip to content

Duplicate #136 code and meet make errors #293

@lancelot-ch

Description

@lancelot-ch

I copied #136 codes and revised as Floop suggested that put 3 lines right below
Scope root = Scope::NewRootScope();
And I have many make errors.
If anyone could help I will be much appreciated.

I am running on the following conditions:
Freshly built Ubuntu 20.04LTS
CUDA 10.7
CuDnn 8.4.0
Bazel 5.1.1
GCC 9.4.0
make 4.2.1
tensoflow_cc build on 20-05-27, using tensorflow 2.9.0

I am using a PC with an Intel CPU, an Intel GPU and an NVidia T600.

I compiled tensorflow_cc with default CMakeLists file except for putting REQUIRE_CUDA ON, and make is successful.

Then I copied 136 codes:

#include "tensorflow/cc/client/client_session.h"
#include "tensorflow/cc/ops/standard_ops.h"
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/graph/default_device.h"

int main() {
using namespace tensorflow;
using namespace tensorflow::ops;
Scope root = Scope::NewRootScope();
GraphDef def;
TF_CHECK_OK(root.ToGraphDef(&def));

graph::SetDefaultDevice(false ? "/device:GPU:0" : "/cpu:0", &def);
// Matrix A = [3 2; -1 0]
auto A = Const(root, { {3.f, 2.f}, {-1.f, 0.f} });
// Vector b = [3 5]
auto b = Const(root, { {3.f, 5.f} });
// v = Ab^T
auto v = MatMul(root.WithOpName("v"), A, b, MatMul::TransposeB(true));

for (auto &node: *def.mutable_node()) {
node.set_device("/cpu:0");
std::cout << node.name() << " = '" << node.device() <<"'"<< std::endl;
}
std::cout << "=======================\n";

std::vector outputs;
ClientSession session(root);
// Run and fetch v
TF_CHECK_OK(session.Run({v}, &outputs));
// Expect outputs[0] == [19; -3]
LOG(INFO) << outputs[0].matrix();
return 0;
}

I have following make errors:

[ 50%] Building CXX object CMakeFiles/example.dir/example2.cpp.o
[100%] Linking CXX executable example
/usr/bin/ld: CMakeFiles/example.dir/example2.cpp.o: in function google::protobuf::Arena::AllocHook(std::type_info const*, unsigned long) const': example2.cpp:(.text._ZNK6google8protobuf5Arena9AllocHookEPKSt9type_infom[_ZNK6google8protobuf5Arena9AllocHookEPKSt9type_infom]+0x41): undefined reference to google::protobuf::Arena::OnArenaAllocation(std::type_info const*, unsigned long) const'
/usr/bin/ld: CMakeFiles/example.dir/example2.cpp.o: in function google::protobuf::internal::ArenaStringPtr::CreateInstance(google::protobuf::Arena*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*)': example2.cpp:(.text._ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x60): undefined reference to google::protobuf::internal::LogMessage::LogMessage(google::protobuf::LogLevel, char const*, int)'
/usr/bin/ld: example2.cpp:(.text._ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x78): undefined reference to google::protobuf::internal::LogMessage::operator<<(char const*)' /usr/bin/ld: example2.cpp:(.text._ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x8d): undefined reference to google::protobuf::internal::LogFinisher::operator=(google::protobuf::internal::LogMessage&)'
/usr/bin/ld: example2.cpp:(.text._ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x9d): undefined reference to google::protobuf::internal::LogMessage::~LogMessage()' /usr/bin/ld: example2.cpp:(.text._ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x221): undefined reference to google::protobuf::internal::ArenaImpl::AllocateAligned(unsigned long)'
/usr/bin/ld: example2.cpp:(.text._ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x240): undefined reference to google::protobuf::internal::ArenaImpl::AllocateAlignedAndAddCleanup(unsigned long, void (*)(void*))' /usr/bin/ld: example2.cpp:(.text._ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x2d4): undefined reference to google::protobuf::internal::LogMessage::~LogMessage()'
/usr/bin/ld: CMakeFiles/example.dir/example2.cpp.o: in function google::protobuf::internal::GetEmptyStringAlreadyInited[abi:cxx11]()': example2.cpp:(.text._ZN6google8protobuf8internal27GetEmptyStringAlreadyInitedB5cxx11Ev[_ZN6google8protobuf8internal27GetEmptyStringAlreadyInitedB5cxx11Ev]+0xb): undefined reference to google::protobuf::internal::fixed_address_empty_string[abi:cxx11]'
/usr/bin/ld: CMakeFiles/example.dir/example2.cpp.o: in function tensorflow::NodeDef::set_device(char const*)': example2.cpp:(.text._ZN10tensorflow7NodeDef10set_deviceEPKc[_ZN10tensorflow7NodeDef10set_deviceEPKc]+0x4b): undefined reference to google::protobuf::internal::LogMessage::LogMessage(google::protobuf::LogLevel, char const*, int)'
/usr/bin/ld: example2.cpp:(.text._ZN10tensorflow7NodeDef10set_deviceEPKc[_ZN10tensorflow7NodeDef10set_deviceEPKc]+0x63): undefined reference to google::protobuf::internal::LogMessage::operator<<(char const*)' /usr/bin/ld: example2.cpp:(.text._ZN10tensorflow7NodeDef10set_deviceEPKc[_ZN10tensorflow7NodeDef10set_deviceEPKc]+0x75): undefined reference to google::protobuf::internal::LogFinisher::operator=(google::protobuf::internal::LogMessage&)'
/usr/bin/ld: example2.cpp:(.text._ZN10tensorflow7NodeDef10set_deviceEPKc[_ZN10tensorflow7NodeDef10set_deviceEPKc]+0x85): undefined reference to google::protobuf::internal::LogMessage::~LogMessage()' /usr/bin/ld: example2.cpp:(.text._ZN10tensorflow7NodeDef10set_deviceEPKc[_ZN10tensorflow7NodeDef10set_deviceEPKc]+0x11d): undefined reference to google::protobuf::internal::LogMessage::~LogMessage()'
/usr/bin/ld: CMakeFiles/example.dir/example2.cpp.o: in function google::protobuf::RepeatedPtrField<tensorflow::NodeDef>::TypeHandler::Type* google::protobuf::internal::RepeatedPtrFieldBase::Mutable<google::protobuf::RepeatedPtrField<tensorflow::NodeDef>::TypeHandler>(int)': example2.cpp:(.text._ZN6google8protobuf8internal20RepeatedPtrFieldBase7MutableINS0_16RepeatedPtrFieldIN10tensorflow7NodeDefEE11TypeHandlerEEEPNT_4TypeEi[_ZN6google8protobuf8internal20RepeatedPtrFieldBase7MutableINS0_16RepeatedPtrFieldIN10tensorflow7NodeDefEE11TypeHandlerEEEPNT_4TypeEi]+0x49): undefined reference to google::protobuf::internal::LogMessage::LogMessage(google::protobuf::LogLevel, char const*, int)'
/usr/bin/ld: example2.cpp:(.text._ZN6google8protobuf8internal20RepeatedPtrFieldBase7MutableINS0_16RepeatedPtrFieldIN10tensorflow7NodeDefEE11TypeHandlerEEEPNT_4TypeEi[_ZN6google8protobuf8internal20RepeatedPtrFieldBase7MutableINS0_16RepeatedPtrFieldIN10tensorflow7NodeDefEE11TypeHandlerEEEPNT_4TypeEi]+0x61): undefined reference to google::protobuf::internal::LogMessage::operator<<(char const*)' /usr/bin/ld: example2.cpp:(.text._ZN6google8protobuf8internal20RepeatedPtrFieldBase7MutableINS0_16RepeatedPtrFieldIN10tensorflow7NodeDefEE11TypeHandlerEEEPNT_4TypeEi[_ZN6google8protobuf8internal20RepeatedPtrFieldBase7MutableINS0_16RepeatedPtrFieldIN10tensorflow7NodeDefEE11TypeHandlerEEEPNT_4TypeEi]+0x73): undefined reference to google::protobuf::internal::LogFinisher::operator=(google::protobuf::internal::LogMessage&)'
/usr/bin/ld: example2.cpp:(.text._ZN6google8protobuf8internal20RepeatedPtrFieldBase7MutableINS0_16RepeatedPtrFieldIN10tensorflow7NodeDefEE11TypeHandlerEEEPNT_4TypeEi[_ZN6google8protobuf8internal20RepeatedPtrFieldBase7MutableINS0_16RepeatedPtrFieldIN10tensorflow7NodeDefEE11TypeHandlerEEEPNT_4TypeEi]+0x83): undefined reference to google::protobuf::internal::LogMessage::~LogMessage()' /usr/bin/ld: example2.cpp:(.text._ZN6google8protobuf8internal20RepeatedPtrFieldBase7MutableINS0_16RepeatedPtrFieldIN10tensorflow7NodeDefEE11TypeHandlerEEEPNT_4TypeEi[_ZN6google8protobuf8internal20RepeatedPtrFieldBase7MutableINS0_16RepeatedPtrFieldIN10tensorflow7NodeDefEE11TypeHandlerEEEPNT_4TypeEi]+0xb1): undefined reference to google::protobuf::internal::LogMessage::LogMessage(google::protobuf::LogLevel, char const*, int)'
/usr/bin/ld: example2.cpp:(.text._ZN6google8protobuf8internal20RepeatedPtrFieldBase7MutableINS0_16RepeatedPtrFieldIN10tensorflow7NodeDefEE11TypeHandlerEEEPNT_4TypeEi[_ZN6google8protobuf8internal20RepeatedPtrFieldBase7MutableINS0_16RepeatedPtrFieldIN10tensorflow7NodeDefEE11TypeHandlerEEEPNT_4TypeEi]+0xc9): undefined reference to google::protobuf::internal::LogMessage::operator<<(char const*)' /usr/bin/ld: example2.cpp:(.text._ZN6google8protobuf8internal20RepeatedPtrFieldBase7MutableINS0_16RepeatedPtrFieldIN10tensorflow7NodeDefEE11TypeHandlerEEEPNT_4TypeEi[_ZN6google8protobuf8internal20RepeatedPtrFieldBase7MutableINS0_16RepeatedPtrFieldIN10tensorflow7NodeDefEE11TypeHandlerEEEPNT_4TypeEi]+0xdb): undefined reference to google::protobuf::internal::LogFinisher::operator=(google::protobuf::internal::LogMessage&)'
/usr/bin/ld: example2.cpp:(.text._ZN6google8protobuf8internal20RepeatedPtrFieldBase7MutableINS0_16RepeatedPtrFieldIN10tensorflow7NodeDefEE11TypeHandlerEEEPNT_4TypeEi[_ZN6google8protobuf8internal20RepeatedPtrFieldBase7MutableINS0_16RepeatedPtrFieldIN10tensorflow7NodeDefEE11TypeHandlerEEEPNT_4TypeEi]+0xeb): undefined reference to google::protobuf::internal::LogMessage::~LogMessage()' /usr/bin/ld: example2.cpp:(.text._ZN6google8protobuf8internal20RepeatedPtrFieldBase7MutableINS0_16RepeatedPtrFieldIN10tensorflow7NodeDefEE11TypeHandlerEEEPNT_4TypeEi[_ZN6google8protobuf8internal20RepeatedPtrFieldBase7MutableINS0_16RepeatedPtrFieldIN10tensorflow7NodeDefEE11TypeHandlerEEEPNT_4TypeEi]+0x12e): undefined reference to google::protobuf::internal::LogMessage::~LogMessage()'
/usr/bin/ld: example2.cpp:(.text._ZN6google8protobuf8internal20RepeatedPtrFieldBase7MutableINS0_16RepeatedPtrFieldIN10tensorflow7NodeDefEE11TypeHandlerEEEPNT_4TypeEi[_ZN6google8protobuf8internal20RepeatedPtrFieldBase7MutableINS0_16RepeatedPtrFieldIN10tensorflow7NodeDefEE11TypeHandlerEEEPNT_4TypeEi]+0x150): undefined reference to `google::protobuf::internal::LogMessage::~LogMessage()'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/example.dir/build.make:87: example] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/example.dir/all] Error 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions