caffe-jacinto icon indicating copy to clipboard operation
caffe-jacinto copied to clipboard

Build with CPU

Open happy-Bobo opened this issue 6 years ago • 6 comments

Hi, Manu I know that caffe-jacinto is fork from Nvcaffe, would you please tell that caffe-jacinto does support build with cpu ? I just want to run the example-caffe-jacinto/example/cpp_classification on TI's device platform AM5728(run the example on ARM, and then, dispatch the matrix compute to the DSP through LINALG lib). So, Is this feasible? if yes, would you please give me some guidence? thanks best regards Bobo

happy-Bobo avatar Jan 08 '19 07:01 happy-Bobo

I think NVCaffe doesn't support building on CPU. So caffe-jacinto also may not build on CPU.

mathmanu avatar Jan 08 '19 07:01 mathmanu

@happy-Bobo It does support CPU build. I have build both NVCaffe as well as caffe-jacinto on my PC.

Step 1: Install all required dependencies apt-get update && apt-get install -y --no-install-recommends
build-essential
cmake
git
wget
libatlas-base-dev
libboost-all-dev
libgflags-dev
libgoogle-glog-dev
libhdf5-serial-dev
libleveldb-dev
liblmdb-dev
libopencv-dev
libprotobuf-dev
libsnappy-dev
protobuf-compiler
python-dev
python-numpy
python-pip
python-scipy &&
rm -rf /var/lib/apt/lists/*

Step 2:

git clone https://github.com/tidsp/caffe-jacinto.git

Step 3:

Install all python packages listed at this path "python/requirements.txt" Create simple shell script : for req in $(cat python/requirements.txt) pydot; do pip install $req; done

And it will install all required python packages

Step 4:

mkdir build && cd build cmake -DCPU_ONLY=1 .. make -j"$(nproc)"

This will build caffe-jacinto for CPU

sagartesla avatar Jan 10 '19 13:01 sagartesla

@sagartesla thank you so much for your help, I will try it.

happy-Bobo avatar Jan 17 '19 03:01 happy-Bobo

Hi @sagartesla, I tried to compile it using cmake and facing pthread_create error, snippet from Cmake log

-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE ,

and in the cmake error log the failure reason mentioned is:

Determining if the function pthread_create exists in the pthreads failed with the following output: Change Dir: /mnt/d/codes/caffe-jacinto/build/CMakeFiles/CMakeTmp


/usr/bin/ld: cannot find -lpthreads

Though I have pthreads already installed in the system.

chandrakantkhandelwal avatar Mar 12 '19 13:03 chandrakantkhandelwal

@chandrakantkhandelwal

I hope you followed the steps properly. As it is issue with pthread library.

You can try apt-get install build-essential

  • In this, it will try to install all required tools and packages for compilation and build
  • " libc6 ", is very important and it should be installed properly. I remember Ubuntu 16.04 has some issue with this.
  • Just check whether this installation is in order
  • Also you can try adding following line in CMakeLists.txt below cmake_minimum_required(VERSION 3.4.0) line find_package(Threads)

sagartesla avatar Mar 12 '19 17:03 sagartesla

@sagartesla Thanks for the fast response. I have already successfully installed CPU only BVLC/caffe and caffe from SSD (by weiliu). Note: I am using windows subsystem for Linux (ubuntu 16.04).

I have tried this (added in the caffe/test cmake) and tried adding pthread/pthreads in CMAKE_CXX_FLAGS.

I will add this in all the cmake files and will give it a try again. """ Also you can try adding following line in CMakeLists.txt below cmake_minimum_required(VERSION 3.4.0) line find_package(Threads)

"""

chandrakantkhandelwal avatar Mar 13 '19 06:03 chandrakantkhandelwal