Maratyszcza / caffe-nnpack

Caffe with NNPACK integration
Other
59 stars 28 forks source link

Unable to build due to error "undefined reference to `pthreadpool_destroy'" #7

Open szm-R opened 7 years ago

szm-R commented 7 years ago

Hi, Recently I came across NNPACK and decided to try it (I've been using BVLC Caffe for more than a year), I built NNPACK with the provided instructions in https://github.com/Maratyszcza/NNPACK.git, with the only differences being: 1- I installed ninja from source as the repository package is version 1.5.1 (1.7.1 is needed for NNPACK). 2- I added -fPIC flag to cflags in build.ninja because not doing so results in relocation error (in building
Caffe).

For building this Caffe, I first merged it with BVLC Caffe via following commands: cd caffe-nnpack git remote add caffe https://github.com/BVLC/caffe.git git fetch caffe git merge -X theirs caffe/master

And then removed self_.attr("phase") = staticcast(this->phase); from include/caffe/layers/python_layer.hpp after merging. I did this because building this branch alone resulted in "cudnnNanPropagation_t" error.

I also added set (CMAKE_CXX_STANDARD 11) to CMakeLists.txt because I got an error about nested template argument list.

After all this, I ran the following commands: mkdir build && cd build cmake .. make

Which resulted in the error mentioned in the title: ../lib/libcaffe.so.1.0.0: undefined reference to `pthreadpool_destroy'

I did as suggested in https://github.com/tiny-dnn/tiny-dnn/issues/829 meaning I added FIND_LIBRARY(NNPACK_THREADPOOL_LIB NAMES pthreadpool PATHS ${NNPACK_LIB_SEARCH_PATHS}) to FindNNPACK.cmake and list(APPEND REQUIRED_LIBRARIES ${NNPACK_LIB} ${NNPACK_THREADPOOL_LIB}) to CMakeLists.txt, but it didn't solve the problem.

I also tried to build Caffe in CPU_ONLY mode (so that there would be no need for merging) but that too resulted in the same error.

Thank you in advance for your help.

Surmeh commented 7 years ago

Hello, I was getting the same error and updated the FindNNPACK.cmake with both the lines you've mentioned, i.e FIND_LIBRARY(NNPACK_THREADPOOL_LIB NAMES pthreadpool PATHS ${NNPACK_LIB_SEARCH_PATHS}) list(APPEND REQUIRED_LIBRARIES ${NNPACK_LIB} ${NNPACK_THREADPOOL_LIB})

szm-R commented 7 years ago

And it solved your problem? You mean you added both of these lines to FindNNPACK.cmake? I did this like the following: FIND_PATH(NNPACK_INCLUDE_DIR NAMES nnpack.h PATHS ${NNPACK_INCLUDE_SEARCH_PATHS}) FIND_LIBRARY(NNPACK_LIB NAMES nnpack PATHS ${NNPACK_LIB_SEARCH_PATHS}) FIND_LIBRARY(NNPACK_THREADPOOL_LIB NAMES pthreadpool PATHS ${NNPACK_LIB_SEARCH_PATHS})

list(APPEND REQUIRED_LIBRARIES ${NNPACK_LIB} ${NNPACK_THREADPOOL_LIB})

Added the two lines after line 24 of the file FindNNPACK.cmake and the error still persists

szm-R commented 7 years ago

Also in Maratyszcza/NNPACK it's mentioned that this integration of nnpack with Caffe is unmaintained and instead one should refer to Maratyszcza/caffe , but I also had trouble building that one and I get this error: Caffe/nnpack-caffe/src/caffe/layers/nnpack_relu_layer.cpp:10:21: error: expected initializer before ‘<’ token void NNPackReLULayer::Forward_cpu(const vector<Blob*>& bottom,

Abd there is no issue tab there to ask for advice! ...

Surmeh commented 7 years ago

Yea it did solve my problem. Also I've used the new Caffe with NNPACK and it builds fine.

szm-R commented 7 years ago

Could you please post your FindNNPACK.cmake file? I really don't understand the problem! here is my build summary for this integration of Caffe with NNPACK:

-- Caffe Configuration Summary -- General: -- Version : 1.0.0 -- Git : 1.0-31-gcf398b0-dirty -- System : Linux -- C++ compiler : /usr/bin/c++ -- Release CXX flags : -O3 -DNDEBUG -fPIC -Wall -Wno-sign-compare -Wno-uninitialized -- Debug CXX flags : -g -fPIC -Wall -Wno-sign-compare -Wno-uninitialized -- Build type : Release -- -- BUILD_SHARED_LIBS : ON -- BUILD_python : ON -- BUILD_matlab : OFF -- BUILD_docs : ON -- CPU_ONLY : OFF -- USE_OPENCV : ON -- USE_LEVELDB : ON -- USE_LMDB : ON -- USE_NCCL : OFF -- ALLOW_LMDB_NOLOCK : OFF -- -- Dependencies: -- BLAS : Yes (Atlas) -- Boost : Yes (ver. 1.58) -- glog : Yes -- gflags : Yes -- protobuf : Yes (ver. 3.4.0) -- lmdb : Yes (ver. 0.9.17) -- LevelDB : Yes (ver. 1.18) -- Snappy : Yes (ver. 1.1.3) -- OpenCV : Yes (ver. 3.2.0) -- CUDA : Yes (ver. 8.0) -- -- NVIDIA CUDA: -- Target GPU(s) : Auto -- GPU arch(s) : sm_20 sm_21 sm_30 sm_35 sm_50 sm_60 sm_61 -- cuDNN : Yes (ver. 6.0.21) -- -- Python: -- Interpreter : /usr/bin/python2.7 (ver. 2.7.12) -- Libraries : /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.12) -- NumPy : /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.11.0) -- -- Documentaion: -- Doxygen : No -- config_file : -- -- Install: -- Install path : /home/gpuserver/Moosavi/Caffe/caffe-nnpack/build/install -- -- Configuring done

On Thu, Aug 31, 2017 at 3:16 PM, Surmeh notifications@github.com wrote:

Yea it did solve my problem. Also I've used the new Caffe with NNPACK and it builds fine.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Maratyszcza/caffe-nnpack/issues/7#issuecomment-326259543, or mute the thread https://github.com/notifications/unsubscribe-auth/APaJX2nLBhY-lAH_npHJhG7earDx5EfFks5sdo8egaJpZM4PE3Qa .