Caffe: Build Caffe and pycaffe

Created on 9 Dec 2016  ·  19Comments  ·  Source: BVLC/caffe

when build caffe and pycaffe:
voole@voole-OptiPlex-3020:~/fast-rcnn/caffe-fast-rcnn$ make -j8 && make pycaffe CXX .build_release/src/caffe/proto/caffe.pb.cc CXX src/caffe/blob.cpp CXX src/caffe/data_transformer.cpp CXX src/caffe/net.cpp CXX src/caffe/solver.cpp CXX src/caffe/util/insert_splits.cpp CXX src/caffe/util/db.cpp CXX src/caffe/util/upgrade_proto.cpp In file included from .build_release/src/caffe/proto/caffe.pb.cc:5:0: .build_release/src/caffe/proto/caffe.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is #error This file was generated by a newer version of protoc which is ^ .build_release/src/caffe/proto/caffe.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update #error incompatible with your Protocol Buffer headers. Please update ^ .build_release/src/caffe/proto/caffe.pb.h:14:2: error: #error your headers. #error your headers. ^ .build_release/src/caffe/proto/caffe.pb.h:22:35: fatal error: google/protobuf/arena.h: 没有那个文件或目录 #include <google/protobuf/arena.h> ^ compilation terminated. make: *** [.build_release/src/caffe/proto/caffe.pb.o] 错误 1 make: *** 正在等待未完成的任务.... In file included from ./include/caffe/blob.hpp:9:0, from src/caffe/blob.cpp:4: .build_release/src/caffe/proto/caffe.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is #error This file was generated by a newer version of protoc which is ^ .build_release/src/caffe/proto/caffe.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update #error incompatible with your Protocol Buffer headers. Please update ^ .build_release/src/caffe/proto/caffe.pb.h:14:2: error: #error your headers. #error your headers. ^ .build_release/src/caffe/proto/caffe.pb.h:22:35: fatal error: google/protobuf/arena.h: 没有那个文件或目录 #include <google/protobuf/arena.h> ^ compilation terminated. make: *** [.build_release/src/caffe/blob.o] 错误 1 In file included from ./include/caffe/util/insert_splits.hpp:6:0, from src/caffe/util/insert_splits.cpp:8: .build_release/src/caffe/proto/caffe.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is #error This file was generated by a newer version of protoc which is ^ .build_release/src/caffe/proto/caffe.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update #error incompatible with your Protocol Buffer headers. Please update ^ .build_release/src/caffe/proto/caffe.pb.h:14:2: error: #error your headers. #error your headers. ^ .build_release/src/caffe/proto/caffe.pb.h:22:35: fatal error: google/protobuf/arena.h: 没有那个文件或目录 #include <google/protobuf/arena.h> ^ compilation terminated. make: *** [.build_release/src/caffe/util/insert_splits.o] 错误 1 In file included from src/caffe/util/upgrade_proto.cpp:9:0: .build_release/src/caffe/proto/caffe.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is #error This file was generated by a newer version of protoc which is ^ .build_release/src/caffe/proto/caffe.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update #error incompatible with your Protocol Buffer headers. Please update ^ .build_release/src/caffe/proto/caffe.pb.h:14:2: error: #error your headers. #error your headers. ^ .build_release/src/caffe/proto/caffe.pb.h:22:35: fatal error: google/protobuf/arena.h: 没有那个文件或目录 #include <google/protobuf/arena.h> ^ compilation terminated. make: *** [.build_release/src/caffe/util/upgrade_proto.o] 错误 1 In file included from ./include/caffe/blob.hpp:9:0, from ./include/caffe/net.hpp:10, from src/caffe/solver.cpp:7: .build_release/src/caffe/proto/caffe.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is #error This file was generated by a newer version of protoc which is ^ .build_release/src/caffe/proto/caffe.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update #error incompatible with your Protocol Buffer headers. Please update ^ .build_release/src/caffe/proto/caffe.pb.h:14:2: error: #error your headers. #error your headers. ^ .build_release/src/caffe/proto/caffe.pb.h:22:35: fatal error: google/protobuf/arena.h: 没有那个文件或目录 #include <google/protobuf/arena.h> ^ compilation terminated. make: *** [.build_release/src/caffe/solver.o] 错误 1 In file included from ./include/caffe/blob.hpp:9:0, from ./include/caffe/layer.hpp:8, from src/caffe/net.cpp:9: .build_release/src/caffe/proto/caffe.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is #error This file was generated by a newer version of protoc which is ^ .build_release/src/caffe/proto/caffe.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update #error incompatible with your Protocol Buffer headers. Please update ^ .build_release/src/caffe/proto/caffe.pb.h:14:2: error: #error your headers. #error your headers. ^ .build_release/src/caffe/proto/caffe.pb.h:22:35: fatal error: google/protobuf/arena.h: 没有那个文件或目录 #include <google/protobuf/arena.h> ^ compilation terminated. make: *** [.build_release/src/caffe/net.o] 错误 1 In file included from ./include/caffe/util/db.hpp:11:0, from src/caffe/util/db.cpp:1: .build_release/src/caffe/proto/caffe.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is #error This file was generated by a newer version of protoc which is ^ .build_release/src/caffe/proto/caffe.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update #error incompatible with your Protocol Buffer headers. Please update ^ .build_release/src/caffe/proto/caffe.pb.h:14:2: error: #error your headers. #error your headers. ^ .build_release/src/caffe/proto/caffe.pb.h:22:35: fatal error: google/protobuf/arena.h: 没有那个文件或目录 #include <google/protobuf/arena.h> ^ compilation terminated. make: *** [.build_release/src/caffe/util/db.o] 错误 1 In file included from ./include/caffe/blob.hpp:9:0, from ./include/caffe/data_transformer.hpp:6, from src/caffe/data_transformer.cpp:6: .build_release/src/caffe/proto/caffe.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is #error This file was generated by a newer version of protoc which is ^ .build_release/src/caffe/proto/caffe.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update #error incompatible with your Protocol Buffer headers. Please update ^ .build_release/src/caffe/proto/caffe.pb.h:14:2: error: #error your headers. #error your headers. ^ .build_release/src/caffe/proto/caffe.pb.h:22:35: fatal error: google/protobuf/arena.h: 没有那个文件或目录 #include <google/protobuf/arena.h> ^ compilation terminated. make: *** [.build_release/src/caffe/data_transformer.o] 错误 1


the next is my Makefile.config


``` ## Refer to http://caffe.berkeleyvision.org/installation.html

Contributions simplifying and improving our build system are welcome!

cuDNN acceleration switch (uncomment to build with cuDNN).

USE_CUDNN := 1

CPU-only switch (uncomment to build without GPU support).

CPU_ONLY := 1

To customize your choice of compiler, uncomment and set the following.

N.B. the default for Linux is g++ and the default for OSX is clang++

CUSTOM_CXX := g++

CUDA directory contains bin/ and lib/ directories that we need.

CUDA_DIR := /usr/local/cuda

On Ubuntu 14.04, if cuda tools are installed via

"sudo apt-get install nvidia-cuda-toolkit" then use this instead:

CUDA_DIR := /usr

CUDA architecture setting: going with all of them.

For CUDA < 6.0, comment the *_50 lines for compatibility.

CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
-gencode arch=compute_20,code=sm_21 \
-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_50,code=compute_50

BLAS choice:

atlas for ATLAS (default)

mkl for MKL

open for OpenBlas

BLAS := atlas

Custom (MKL/ATLAS/OpenBLAS) include and lib directories.

Leave commented to accept the defaults for your choice of BLAS

(which should work)!

BLAS_INCLUDE := /path/to/your/blas

BLAS_LIB := /path/to/your/blas

This is required only if you will compile the matlab interface.

MATLAB directory should contain the mex binary in /bin.

MATLAB_DIR := /usr/local

MATLAB_DIR := /Applications/MATLAB_R2012b.app

NOTE: this is required only if you will compile the python interface.

We need to be able to find Python.h and numpy/arrayobject.h.

PYTHON_INCLUDE := /usr/include/python2.7 \
/usr/lib/python2.7/dist-packages/numpy/core/include

Anaconda Python distribution is quite popular. Include path:

Verify anaconda location, sometimes it's in root.

ANACONDA_HOME := $(HOME)/anaconda

# PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
# $(ANACONDA_HOME)/include/python2.7 \
# $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include \

We need to be able to find libpythonX.X.so or .dylib.

PYTHON_LIB := /usr/lib

PYTHON_LIB := $(ANACONDA_HOME)/lib

Uncomment to support layers written in Python (will link against Python libs)

This will require an additional dependency boost_regex provided by boost.

WITH_PYTHON_LAYER := 1

Whatever else you find you need goes here.

INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib

Uncomment to use pkg-config to specify OpenCV library paths.

(Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)

USE_PKG_CONFIG := 1

BUILD_DIR := build
DISTRIBUTE_DIR := distribute

Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171

DEBUG := 1

The ID of the GPU that 'make runtest' will use to run unit tests.

TEST_GPUID := 0

enable pretty build (comment to see full commands)

Q ?= @```

many thanks

Your system configuration

Operating system:ubuntu14.04
Compiler:gcc
CUDA version (if applicable):none
CUDNN version (if applicable):none
BLAS:
Python or MATLAB version (for pycaffe and matcaffe respectively):

Most helpful comment

We have the same problem...and it is because of the wrong version of protobuf
首先你要卸载,并重装其要求的protobuf版本(2.6.1),之后重新编译就好了
我卸载了protobuf3.0,重新安装了很多次的protobuf2.6.1,但都不行
重装后:protoc --version 结果还是3.0
如果你也这样,你需要的工作是:
1。sudo find / -name protoc
2。将2.6.1版本生成的protoc,替换掉找到的3.0版本的protoc
然后就ok了
我整整搞了两天
good luck

All 19 comments

same problem...

We have the same problem...and it is because of the wrong version of protobuf
首先你要卸载,并重装其要求的protobuf版本(2.6.1),之后重新编译就好了
我卸载了protobuf3.0,重新安装了很多次的protobuf2.6.1,但都不行
重装后:protoc --version 结果还是3.0
如果你也这样,你需要的工作是:
1。sudo find / -name protoc
2。将2.6.1版本生成的protoc,替换掉找到的3.0版本的protoc
然后就ok了
我整整搞了两天
good luck

In my case, I have 2 libprotoc: one is system installed libprotoc, which is 2.5.0, the other is my local installed libprotoc 3.0.0. I modify $PATH to remove the path to my local libprotoc and can resoble this make error.

From https://github.com/BVLC/caffe/blob/master/CONTRIBUTING.md:

_Please do not post usage, installation, or modeling questions, or other requests for help to Issues._
Use the caffe-users list instead. This helps developers maintain a clear, uncluttered, and efficient view of the state of Caffe.

@dongmingyang @handong1587 thank you very much it works.

@handong1587 I am using Mac. How does your PATH variable looks like? Also, How can I locate path the old Libprotoc? Thanks a lot, sir.

@BestSongEver 怎么搞的,我也搞了好几天了,搞不定,能不能详细说下,谢谢

@BestSongEver
太感谢了,就你这个答案说到点子上。
我折腾了半天 其实就是把Anaconda下面的protoc删掉 再重装2.6.1就行了

@BestSongEver ,@07freedom 请问您是否可以说得再详细点,谢谢。

First remove the protobuf in Anaconda.
Then, sudo apt-get install libprotobuf-dev protobuf-compiler.
Problem solved somehow.

how do i remove the protobuf from Anaconda? Manually one by one after "locate protobuf" command?

把Ancona从环境变量中移除,重新编译,成功后再将 Ancona环境变量写进去,注意source重新生效一下

主要是由于版本冲突导致,卸载即可!就下面这句指令,make all matcaffe一次成功!
conda uninstall libprotobuf

CXX .build_release/src/caffe/proto/caffe.pb.cc
CXX src/caffe/util/upgrade_proto.cpp
CXX src/caffe/util/db_leveldb.cpp
CXX src/caffe/util/math_functions.cpp
CXX src/caffe/util/insert_splits.cpp
CXX src/caffe/util/signal_handler.cpp
CXX src/caffe/util/im2col.cpp
CXX src/caffe/util/io.cpp
src/caffe/util/math_functions.cpp:1:49: fatal error: boost/math/special_functions/next.hpp: No such file or directory
compilation terminated.
Makefile:579: recipe for target '.build_release/src/caffe/util/math_functions.o' failed
make: *** [.build_release/src/caffe/util/math_functions.o] Error 1
make: *** Waiting for unfinished jobs....
src/caffe/util/signal_handler.cpp:1:26: fatal error: boost/bind.hpp: No such file or directory
compilation terminated.
Makefile:579: recipe for target '.build_release/src/caffe/util/signal_handler.o' failed
make: *** [.build_release/src/caffe/util/signal_handler.o] Error 1
In file included from src/caffe/util/im2col.cpp:4:0:
./include/caffe/util/math_functions.hpp:7:26: fatal error: glog/logging.h: No such file or directory
compilation terminated.
Makefile:579: recipe for target '.build_release/src/caffe/util/im2col.o' failed
make: *** [.build_release/src/caffe/util/im2col.o] Error 1
In file included from src/caffe/util/db_leveldb.cpp:2:0:
./include/caffe/util/db_leveldb.hpp:7:24: fatal error: leveldb/db.h: No such file or directory
compilation terminated.
Makefile:579: recipe for target '.build_release/src/caffe/util/db_leveldb.o' failed
make: *** [.build_release/src/caffe/util/db_leveldb.o] Error 1
In file included from src/caffe/util/upgrade_proto.cpp:8:0:
./include/caffe/common.hpp:4:32: fatal error: boost/shared_ptr.hpp: No such file or directory
compilation terminated.
Makefile:579: recipe for target '.build_release/src/caffe/util/upgrade_proto.o' failed
make: *** [.build_release/src/caffe/util/upgrade_proto.o] Error 1
In file included from .build_release/src/caffe/proto/caffe.pb.cc:5:0:
.build_release/src/caffe/proto/caffe.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
 #error This file was generated by a newer version of protoc which is
  ^
.build_release/src/caffe/proto/caffe.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
 #error incompatible with your Protocol Buffer headers.  Please update
  ^
.build_release/src/caffe/proto/caffe.pb.h:14:2: error: #error your headers.
 #error your headers.
  ^
In file included from .build_release/src/caffe/proto/caffe.pb.cc:5:0:
.build_release/src/caffe/proto/caffe.pb.h:23:35: fatal error: google/protobuf/arena.h: No such file or directory
compilation terminated.
Makefile:586: recipe for target '.build_release/src/caffe/proto/caffe.pb.o' failed
make: *** [.build_release/src/caffe/proto/caffe.pb.o] Error 1
In file included from src/caffe/util/insert_splits.cpp:7:0:
./include/caffe/common.hpp:4:32: fatal error: boost/shared_ptr.hpp: No such file or directory
compilation terminated.
Makefile:579: recipe for target '.build_release/src/caffe/util/insert_splits.o' failed
make: *** [.build_release/src/caffe/util/insert_splits.o] Error 1
In file included from src/caffe/util/io.cpp:18:0:
./include/caffe/common.hpp:4:32: fatal error: boost/shared_ptr.hpp: No such file or directory
compilation terminated.
Makefile:579: recipe for target '.build_release/src/caffe/util/io.o' failed
make: *** [.build_release/src/caffe/util/io.o] Error 1

My protoc --version is 2.6.1.But still encounter this problem.@moyans @ycsun19 @BestSongEver @Usernamezhx @handong1587 @shelhamer

@BestSongEver
Hi, Could you please interpret how to do the step 2. 将2.6.1版本生成的protoc,替换掉找到的3.0版本的protoc?
Thank you! 谢谢。

@Luckick replace the protoc of version-3.0 with the generation protoc of version-2.6.1

after you uninstall version 3.0, you have to do "make clean" before you "make all "again

(caffe-tf) yyk@ubun:~/caffe$ make matcaffe
CXX .build_release/src/caffe/proto/caffe.pb.cc
In file included from .build_release/src/caffe/proto/caffe.pb.cc:5:0:
.build_release/src/caffe/proto/caffe.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
#error This file was generated by a newer version of protoc which is
^
.build_release/src/caffe/proto/caffe.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
#error incompatible with your Protocol Buffer headers. Please update
^
.build_release/src/caffe/proto/caffe.pb.h:14:2: error: #error your headers.
#error your headers.
^
In file included from .build_release/src/caffe/proto/caffe.pb.cc:5:0:
.build_release/src/caffe/proto/caffe.pb.h:23:35: fatal error: google/protobuf/arena.h: No such file or directory
compilation terminated.
Makefile:600: recipe for target '.build_release/src/caffe/proto/caffe.pb.o' failed
make: * [.build_release/src/caffe/proto/caffe.pb.o] Error 1

After running
sudo apt-get install libleveldb-dev
It worked for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

inferrna picture inferrna  ·  3Comments

sdemyanov picture sdemyanov  ·  3Comments

LarsHH picture LarsHH  ·  3Comments

erogol picture erogol  ·  3Comments

Ruhjkg picture Ruhjkg  ·  3Comments