mathmanu / caffe-jacinto

This repository has moved. The new link can be obtained from https://github.com/TexasInstruments/jacinto-ai-devkit
116 stars 35 forks source link

Build with CPU #30

Open happy-Bobo opened 5 years ago

happy-Bobo commented 5 years ago

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

mathmanu commented 5 years ago

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

sagartesla commented 5 years ago

@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

happy-Bobo commented 5 years ago

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

chandrakantkhandelwal commented 5 years ago

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.

sagartesla commented 5 years ago

@chandrakantkhandelwal

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

You can try apt-get install build-essential

chandrakantkhandelwal commented 5 years ago

@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)

"""