caffe2 icon indicating copy to clipboard operation
caffe2 copied to clipboard

Build error with up-to-date commit number again.

Open leemgs opened this issue 9 years ago • 4 comments

When I try to build Caffe2 source with up-to-date commit number on Ubuntu 16.04 LTS 64bit, the make -j $(nproc) command can not run successfully. With v0.7.0, the build is okay. I could not fix the existing issue with $ sudo apt-get install libpthread-stubs0-dev libc-dev. It seems that this build error results from incorrect POSIX thread library. Until now, there are three options in Linux distributions.

  • First, is -pthread temporaily before moving LinuxThread to NPTL(Native POSIX Thread Library).
  • Second, is -lpthread as POSIX.
  • Third, is -lpthreads as non-POSIX.
/usr/lib/icecc/bin/cc   -DCHECK_FUNCTION_EXISTS=pthread_create    CMakeFiles/cmTC_dbaed.dir/CheckFunctionExists.c.o  -o cmTC_dbaed -rdynamic -lpthreads 
/usr/bin/ld: cannot find -lpthreads

As we can see the above information, It seems that this issue is generated by incorrect option such as -lpthreads.

Here is screenshot.

  • commit number that I used.
$ git log 
commit 437897b638a3a43006c9dbf71a203c08f205015d
Author: Yangqing Jia <[email protected]>
Date:   Fri Jun 23 22:25:54 2017 -0700
    fix clip_op bug    
    Summary: ajtulloch caught me. This fixes the min() bug - should be lowest().    
    Reviewed By: xianjiec, dzhulgakov    
    Differential Revision: D5316406    
    fbshipit-source-id: 76c13e8eddc4233b40f99a801910fbf7a1ef6b28
  • pthread.h related error message:
$ make all 

Determining if the pthread_create exist failed with the following output:
Change Dir: /work/sdc/caffe2-upstream/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_508db/fast"
make[1]: Entering directory '/work/sdc/caffe2-upstream/build/CMakeFiles/CMakeTmp'
/usr/bin/make -f CMakeFiles/cmTC_508db.dir/build.make CMakeFiles/cmTC_508db.dir/build
make[2]: Entering directory '/work/sdc/caffe2-upstream/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_508db.dir/CheckSymbolExists.c.o
/usr/lib/icecc/bin/cc     -o CMakeFiles/cmTC_508db.dir/CheckSymbolExists.c.o   -c /work/sdc/caffe2-upstream/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c
Linking C executable cmTC_508db
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_508db.dir/link.txt --verbose=1
/usr/lib/icecc/bin/cc       CMakeFiles/cmTC_508db.dir/CheckSymbolExists.c.o  -o cmTC_508db -rdynamic 
CMakeFiles/cmTC_508db.dir/CheckSymbolExists.c.o: In function `main':
CheckSymbolExists.c:(.text+0x16): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_508db.dir/build.make:97: recipe for target 'cmTC_508db' failed
make[2]: *** [cmTC_508db] Error 1
make[2]: Leaving directory '/work/sdc/caffe2-upstream/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_508db/fast' failed
make[1]: *** [cmTC_508db/fast] Error 2
make[1]: Leaving directory '/work/sdc/caffe2-upstream/build/CMakeFiles/CMakeTmp'

File /work/sdc/caffe2-upstream/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <pthread.h>

int main(int argc, char** argv)
{
  (void)argv;
#ifndef pthread_create
  return ((int*)(&pthread_create))[argc];
#else
  (void)argc;
  return 0;
#endif
}

Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /work/sdc/caffe2-upstream/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_dbaed/fast"
make[1]: Entering directory '/work/sdc/caffe2-upstream/build/CMakeFiles/CMakeTmp'
/usr/bin/make -f CMakeFiles/cmTC_dbaed.dir/build.make CMakeFiles/cmTC_dbaed.dir/build
make[2]: Entering directory '/work/sdc/caffe2-upstream/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_dbaed.dir/CheckFunctionExists.c.o
/usr/lib/icecc/bin/cc    -DCHECK_FUNCTION_EXISTS=pthread_create   -o CMakeFiles/cmTC_dbaed.dir/CheckFunctionExists.c.o   -c /usr/share/cmake-3.5/Modules/CheckFunctionExists.c
Linking C executable cmTC_dbaed
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_dbaed.dir/link.txt --verbose=1
/usr/lib/icecc/bin/cc   -DCHECK_FUNCTION_EXISTS=pthread_create    CMakeFiles/cmTC_dbaed.dir/CheckFunctionExists.c.o  -o cmTC_dbaed -rdynamic -lpthreads 
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_dbaed.dir/build.make:97: recipe for target 'cmTC_dbaed' failed
make[2]: *** [cmTC_dbaed] Error 1
make[2]: Leaving directory '/work/sdc/caffe2-upstream/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_dbaed/fast' failed
make[1]: *** [cmTC_dbaed/fast] Error 2
make[1]: Leaving directory '/work/sdc/caffe2-upstream/build/CMakeFiles/CMakeTmp'

leemgs avatar Jun 24 '17 10:06 leemgs

i meet the same error........T_T.......can anybody solve this problem?please~~~

ibeilinGX avatar Jul 07 '17 01:07 ibeilinGX

@ibeilinGX , could you tell me the below information to me?

  • operating system: e.g. ubuntu 16.04.5 x64
  • commit number ( that you used):
  • graphics:

leemgs avatar Jul 07 '17 01:07 leemgs

I got similar error messages. A recursive clone of caffe2 should fix it:

git clone --recursive https://github.com/caffe2/caffe2.git && cd caffe2

stefan-it avatar Sep 18 '17 23:09 stefan-it

@stefan-it Thank you for sharing your experience. Does it mean that we have to download sub-modules simultaneously with --recursive in case of up-to-date commit version of Caffe2?

Git submodule now supports the --recursive option (Git1.6.5 and more). If --recursive is specified, this command will recurse into the registered submodules, and update any nested submodules within.

leemgs avatar Sep 19 '17 01:09 leemgs