Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Compile Caffe2 #1597

Closed
YangBain opened this issue Dec 9, 2017 · 13 comments
Closed

Compile Caffe2 #1597

YangBain opened this issue Dec 9, 2017 · 13 comments
Labels

Comments

@YangBain
Copy link

YangBain commented Dec 9, 2017

When I install the caffe2, the following errors occurred, so anyone who knows the solution. Thank you very much. (gcc version 5.4.1, Protoc version 3.4.0)

make[3]: Leaving directory /home/beans/caffe2/build' make[3]: Entering directory /home/beans/caffe2/build'
[ 87%] Building CXX object caffe2/CMakeFiles/blob_gpu_test.dir/core/blob_gpu_test.cc.o
Linking CXX executable ../bin/blob_gpu_test
../lib/libcaffe2.so: undefined reference to google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)' ../lib/libcaffe2.so: undefined reference to google::protobuf::internal::ArenaImpl::AllocateAlignedAndAddCleanup(unsigned long, void ()(void))'
../lib/libcaffe2.so: undefined reference to google::protobuf::io::CodedOutputStream::WriteStringWithSizeToArray(std::string const&, unsigned char*)' ../lib/libcaffe2.so: undefined reference to google::protobuf::io::CodedInputStream::DecrementRecursionDepthAndPopLimit(int)'
../lib/libcaffe2.so: undefined reference to google::protobuf::internal::WireFormatLite::UInt32Size(google::protobuf::RepeatedField<unsigned int> const&)' ../lib/libcaffe2.so: undefined reference to google::protobuf::internal::OnShutdownDestroyMessage(void const*)'
../lib/libcaffe2.so: undefined reference to google::protobuf::internal::AssignDescriptors(std::string const&, google::protobuf::internal::MigrationSchema const*, google::protobuf::Message const* const*, unsigned int const*, google::protobuf::MessageFactory*, google::protobuf::Metadata*, google::protobuf::EnumDescriptor const**, google::protobuf::ServiceDescriptor const**)' ../lib/libcaffe2.so: undefined reference to google::protobuf::internal::WireFormatLite::WriteFloatArray(float const*, int, google::protobuf::io::CodedOutputStream*)'
../lib/libcaffe2.so: undefined reference to google::protobuf::io::CodedInputStream::ReadVarint64Fallback()' ../lib/libcaffe2.so: undefined reference to google::FlagRegisterer::FlagRegisterer(char const*, char const*, char const*, long*, long*)'
../lib/libcaffe2.so: undefined reference to google::protobuf::internal::WireFormat::ReadPackedEnumPreserveUnknowns(google::protobuf::io::CodedInputStream*, unsigned int, bool (*)(int), google::protobuf::UnknownFieldSet*, google::protobuf::RepeatedField<int>*)' ../lib/libcaffe2.so: undefined reference to google::protobuf::io::CodedInputStream::IncrementRecursionDepthAndPushLimit(int)'
../lib/libcaffe2.so: undefined reference to google::FlagRegisterer::FlagRegisterer<bool>(char const*, char const*, char const*, bool*, bool*)' ../lib/libcaffe2.so: undefined reference to google::protobuf::internal::WireFormatLite::Int32Size(google::protobuf::RepeatedField const&)'
../lib/libcaffe2.so: undefined reference to google::protobuf::internal::OnShutdownDestroyString(std::string const*)' ../lib/libcaffe2.so: undefined reference to google::protobuf::io::CodedInputStream::ReadVarint32Fallback(unsigned int)'
../lib/libcaffe2.so: undefined reference to google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)' ../lib/libcaffe2.so: undefined reference to google::protobuf::io::CodedOutputStream::WriteVarint64SlowPath(unsigned long)'
../lib/libcaffe2.so: undefined reference to google::protobuf::internal::RegisterAllTypes(google::protobuf::Metadata const*, int)' ../lib/libcaffe2.so: undefined reference to google::protobuf::io::CodedOutputStream::WriteVarint32SlowPath(unsigned int)'
../lib/libcaffe2.so: undefined reference to google::protobuf::internal::InitProtobufDefaults()' ../lib/libcaffe2.so: undefined reference to google::protobuf::Message::SpaceUsedLong() const'
../lib/libcaffe2.so: undefined reference to google::protobuf::io::CodedInputStream::SkipFallback(int, int)' ../lib/libcaffe2.so: undefined reference to google::protobuf::Arena::OnArenaAllocation(std::type_info const*, unsigned long) const'
../lib/libcaffe2.so: undefined reference to google::protobuf::internal::ArenaImpl::AllocateAligned(unsigned long)' ../lib/libcaffe2.so: undefined reference to google::protobuf::internal::WireFormatLite::WriteDoubleArray(double const*, int, google::protobuf::io::CodedOutputStream*)'
../lib/libcaffe2.so: undefined reference to google::protobuf::internal::ArenaImpl::AddCleanup(void*, void (*)(void*))' ../lib/libcaffe2.so: undefined reference to google::protobuf::io::CodedInputStream::BytesUntilTotalBytesLimit() const'
../lib/libcaffe2.so: undefined reference to google::protobuf::io::CodedInputStream::ReadVarintSizeAsIntFallback()' ../lib/libcaffe2.so: undefined reference to google::protobuf::io::CodedInputStream::ReadTagFallback(unsigned int)'
../lib/libcaffe2.so: undefined reference to google::protobuf::internal::fixed_address_empty_string' ../lib/libcaffe2.so: undefined reference to google::protobuf::internal::RepeatedPtrFieldBase::InternalExtend(int)'
../lib/libcaffe2_gpu.so: undefined reference to google::FlagRegisterer::FlagRegisterer<std::string>(char const*, char const*, char const*, std::string*, std::string*)' ../lib/libcaffe2.so: undefined reference to google::FlagRegisterer::FlagRegisterer(char const*, char const*, char const*, int*, int*)'
collect2: error: ld returned 1 exit status
make[3]: *** [bin/blob_gpu_test] Error 1
make[3]: Leaving directory /home/beans/caffe2/build' make[2]: *** [caffe2/CMakeFiles/blob_gpu_test.dir/all] Error 2 make[2]: Leaving directory /home/beans/caffe2/build'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/beans/caffe2/build'
make: *** [all] Error 2

@pietern
Copy link
Contributor

pietern commented Dec 10, 2017

Can you please post the CMake summary output? There is likely a mismatch of some sorts with the protobuf library that is compiled against and the protobuf library that is loaded at runtime.

@pietern pietern self-assigned this Dec 10, 2017
@pietern pietern added the build label Dec 10, 2017
@YangBain
Copy link
Author

@pietern I attach the these files as follows. Thank you very much.
CMakeOutput.log
CMakeError.log

@pjh5
Copy link
Contributor

pjh5 commented Jan 8, 2018

What instructions are you following to install? Are you using anaconda?

This looks like a problem with conflicting protobuf versions on your machine. I've seen this before when trying to install with conda's latest protobuf version while system libprotobuf-dev or protobuf-compiler versions where installed.

Can you run
find / -name libprotobuf* 2>/dev/null
and
which protoc

@YangBain
Copy link
Author

YangBain commented Jan 10, 2018

@pjh5 I am install Caffe2 based on the official instructions. I use the anaconda since I also work on caffe1.
After running what you said, I got the following results:
#############################
beans@Beans:~/caffe2$ find / -name libprotobuf* 2>/dev/null
/var/lib/dpkg/info/libprotobuf8:amd64.postrm
/var/lib/dpkg/info/libprotobuf8:amd64.shlibs
/var/lib/dpkg/info/libprotobuf8:amd64.list
/var/lib/dpkg/info/libprotobuf-lite8:amd64.list
/var/lib/dpkg/info/libprotobuf-dev:amd64.md5sums
/var/lib/dpkg/info/libprotobuf-lite8:amd64.shlibs
/var/lib/dpkg/info/libprotobuf8:amd64.md5sums
/var/lib/dpkg/info/libprotobuf8:amd64.postinst
/var/lib/dpkg/info/libprotobuf-lite8:amd64.postinst
/var/lib/dpkg/info/libprotobuf-lite8:amd64.md5sums
/var/lib/dpkg/info/libprotobuf-dev:amd64.list
/var/lib/dpkg/info/libprotobuf-lite8:amd64.postrm
/home/beans/caffe2/third_party/protobuf/cmake/libprotobuf.cmake
/home/beans/caffe2/third_party/protobuf/cmake/libprotobuf-lite.cmake
/home/beans/anaconda2/conda-meta/libprotobuf-3.4.0-0.json
/home/beans/anaconda2/lib/libprotobuf.so
/home/beans/anaconda2/lib/libprotobuf-lite.so.14.0.0
/home/beans/anaconda2/lib/libprotobuf-lite.so
/home/beans/anaconda2/lib/libprotobuf-lite.la
/home/beans/anaconda2/lib/libprotobuf.so.14
/home/beans/anaconda2/lib/libprotobuf-lite.so.14
/home/beans/anaconda2/lib/libprotobuf.so.14.0.0
/home/beans/anaconda2/lib/libprotobuf.a
/home/beans/anaconda2/lib/libprotobuf.la
/home/beans/anaconda2/lib/libprotobuf-lite.a
/home/beans/anaconda2/pkgs/libprotobuf-3.4.0-0
/home/beans/anaconda2/pkgs/libprotobuf-3.4.0-0/lib/libprotobuf.so
/home/beans/anaconda2/pkgs/libprotobuf-3.4.0-0/lib/libprotobuf-lite.so.14.0.0
/home/beans/anaconda2/pkgs/libprotobuf-3.4.0-0/lib/libprotobuf-lite.so
/home/beans/anaconda2/pkgs/libprotobuf-3.4.0-0/lib/libprotobuf-lite.la
/home/beans/anaconda2/pkgs/libprotobuf-3.4.0-0/lib/libprotobuf.so.14
/home/beans/anaconda2/pkgs/libprotobuf-3.4.0-0/lib/libprotobuf-lite.so.14
/home/beans/anaconda2/pkgs/libprotobuf-3.4.0-0/lib/libprotobuf.so.14.0.0
/home/beans/anaconda2/pkgs/libprotobuf-3.4.0-0/lib/libprotobuf.a
/home/beans/anaconda2/pkgs/libprotobuf-3.4.0-0/lib/libprotobuf.la
/home/beans/anaconda2/pkgs/libprotobuf-3.4.0-0/lib/libprotobuf-lite.a
/home/beans/anaconda2/pkgs/libprotobuf-3.4.0-0.tar.bz2
/usr/lib/x86_64-linux-gnu/libprotobuf.so
/usr/lib/x86_64-linux-gnu/libprotobuf-lite.so.8.0.0
/usr/lib/x86_64-linux-gnu/libprotobuf-lite.so
/usr/lib/x86_64-linux-gnu/libprotobuf.so.8.0.0
/usr/lib/x86_64-linux-gnu/libprotobuf.so.8
/usr/lib/x86_64-linux-gnu/libprotobuf-lite.so.8
/usr/lib/x86_64-linux-gnu/libprotobuf.a
/usr/lib/x86_64-linux-gnu/libprotobuf-lite.a
/usr/share/doc/libprotobuf8
/usr/share/doc/libprotobuf-dev
/usr/share/doc/libprotobuf-lite8
/usr/local/MATLAB/R2016a/toolbox/compiler_sdk/mps_clients/c/glnxa64/lib/libprotobuf.so
/usr/local/MATLAB/R2016a/toolbox/compiler_sdk/mps_clients/c/glnxa64/lib/libprotobuf.so.8.0.0
/usr/local/MATLAB/R2016a/toolbox/compiler_sdk/mps_clients/c/glnxa64/lib/libprotobuf.so.8
/usr/local/MATLAB/R2016a/bin/glnxa64/libprotobuf.so.8.0.0
/usr/local/MATLAB/R2016a/bin/glnxa64/libprotobuf.so.8

beans@Beans:~/caffe2$ which protoc
/home/beans/anaconda2/bin/protoc
##########################################
So could you give me some further suggestions. Thank you very much.

@pjh5
Copy link
Contributor

pjh5 commented Jan 10, 2018

Your installation is being confused by the multiple versions of protobuf (similar to the problem here https://stackoverflow.com/questions/7752609/cmake-ordering-of-include-directories-how-to-mix-system-and-user-based-includ ).

The best thing to do would be to uninstall all of the protobufs except for the one you want, and then reinstalling any other versions of protobuf you need after caffe2 is installed. The instructions have been updated recently for Anaconda on mac; that process may work for you too.

@pjh5 pjh5 self-assigned this Jan 10, 2018
@pjh5
Copy link
Contributor

pjh5 commented Jan 11, 2018

A change just merged which should make this earlier.

If you remove your build directory to remove any cached files, pull the latest caffe2 from github, and then call cmake with -DCMAKE_PREFIX_PATH=<path/to/your/anaconda/env>, then cmake should use Anaconda's protobuf throughout the entire installation

@pjh5 pjh5 closed this as completed Jan 11, 2018
@YangBain
Copy link
Author

@pjh5 Okay, I will try it. Thank you very much.

@qwert1337
Copy link

I still have the same issue on centos 7 using anaconda and having installed multiple versions of protobuf. -DCMAKE_PREFIX_PATH doesn't help.

@fliman
Copy link

fliman commented Mar 9, 2018

have the same problem, have to use protobuf in the thirdparty folder

@fliman
Copy link

fliman commented Mar 9, 2018

protobuf issue is resolved, but now I got ../lib/libcaffe2_gpu.so: undefined reference to google::FlagRegisterer::FlagRegisterer<std::string>(char const*, char const*, char const*, std::string*, std::string*)' ../lib/libcaffe2_gpu.so: undefined reference to google::base::CheckOpMessageBuilder::NewString()'
../lib/libcaffe2.so: undefined reference to `google::SetUsageMessage(std::string const&)'

@pjh5
Copy link
Contributor

pjh5 commented Mar 9, 2018

@fliman your problem is #1980 .

@qwert1337 can you use https://caffe2.ai/docs/getting-started.html?platform=mac&configuration=compile#anaconda-install-path , it should still work on centos.

@fliman
Copy link

fliman commented Mar 10, 2018

@pjh5 thanks for your reply, I tried your solution as in #1980 by adding flags in cmake call
-DCMAKE_CXX_FLAGS=-D__GLIBCXX_USE_CXX11_ABI=0
I still got a lot errors like this

../lib/libcaffe2.so: undefined reference to google::protobuf::Message::InitializationErrorString() const' ../lib/libcaffe2.so: undefined reference to google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)'
../lib/libcaffe2.so: undefined reference to google::protobuf::io::CodedOutputStream::WriteStringWithSizeToArray(std::string const&, unsigned char*)' ../lib/libcaffe2.so: undefined reference to google::protobuf::Message::GetTypeName() const'
../lib/libcaffe2.so: undefined reference to google::protobuf::internal::AssignDescriptors(std::string const&, google::protobuf::internal::MigrationSchema const*, google::protobuf::Message const* const*, unsigned int const*, google::protobuf::MessageFactory*, google::protobuf::Metadata*, google::protobuf::EnumDescriptor const**, google::protobuf::ServiceDescriptor const**)' ../lib/libcaffe2.so: undefined reference to google::protobuf::MessageLite::SerializeToString(std::string*) const'
../lib/libcaffe2.so: undefined reference to google::protobuf::TextFormat::ParseFromString(std::string const&, google::protobuf::Message*)' ../lib/libcaffe2_gpu.so: undefined reference to google::base::CheckOpMessageBuilder::NewString()'
../lib/libcaffe2.so: undefined reference to google::protobuf::Message::DebugString() const' ../lib/libcaffe2_gpu.so: undefined reference to google::protobuf::MessageLite::ParseFromString(std::string const&)'
../lib/libcaffe2_gpu.so: undefined reference to google::protobuf::Message::ShortDebugString() const' ../lib/libcaffe2_gpu.so: undefined reference to google::protobuf::MessageLite::SerializeAsString() const'
../lib/libcaffe2_gpu.so: undefined reference to `google::protobuf::internal::ParseNamedEnum(google::protobuf::EnumDescriptor const*, std::string const&, int*)'

@pjh5
Copy link
Contributor

pjh5 commented Mar 12, 2018

@filman try using protobuf 3.4.0 from conda

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants