pytorch / tensorpipe

A tensor-aware point-to-point communication primitive for machine learning
Other
248 stars 77 forks source link

undefined reference to `pthread_create' #451

Open baoleai opened 2 years ago

baoleai commented 2 years ago

Hi, when I build as follows

$ cd tensorpipe
$ mkdir build
$ cd build
$ cmake ../ -GNinja -DTP_BUILD_TESTING=ON
$ ninja

I got the following errors:

FAILED: tensorpipe/test/channel/cma/tensorpipe_channel_cma_probe tensorpipe/libtensorpipe.a(context_impl.cc.o): In function std::thread::thread<void (tensorpipe::channel::cma::ContextImpl::*)(), tensorpipe::channel::cma::ContextImpl*>(void (tensorpipe::channel::cma::ContextImpl::*&&)(), tensorpipe::channel::cma::ContextImpl*&&)': context_impl.cc:(.text._ZNSt6threadC2IMN10tensorpipe7channel3cma11ContextImplEFvvEJPS4_EEEOT_DpOT0_[_ZNSt6threadC5IMN10tensorpipe7channel3cma11ContextImplEFvvEJPS4_EEEOT_DpOT0_]+0x33): undefined reference topthread_create' tensorpipe/libtensorpipe.a(system.cc.o): In function tensorpipe::setThreadName(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)': system.cc:(.text+0x1aa2): undefined reference topthread_setname_np' collect2: error: ld returned 1 exit status

My env is glibc 2.27 and g++ 7.5.

baoleai commented 2 years ago

Fixed this problem by adding pthread in https://github.com/pytorch/tensorpipe/blob/main/tensorpipe/test/channel/cma/CMakeLists.txt#L12