Caffe: Build Caffe: #error This file was generated by an older version of protoc which is

Created on 25 May 2017  路  29Comments  路  Source: BVLC/caffe

Hi,
I git clone "caffe" source codes, and have done installation, but when I execute "make all -j $(($(nproc) + 1))" in the Caffe folder, I encountered the below errors. (.build_release/src/caffe/proto/caffe.pb.h:17:2: error:
#error This file was generated by an older version of protoc which is)
So, could you pls give me some suggestions? Thanks!

In file included from ./include/caffe/blob.hpp:9:0,
from ./include/caffe/layers/memory_data_layer.hpp:6,
from src/caffe/layers/memory_data_layer.cpp:7:
.build_release/src/caffe/proto/caffe.pb.h:17:2: error: #error This file was generated by an older version of protoc which is
#error This file was generated by an older version of protoc which is
^
.build_release/src/caffe/proto/caffe.pb.h:18:2: error: #error incompatible with your Protocol Buffer headers. Please
#error incompatible with your Protocol Buffer headers. Please
^

Most helpful comment

conda uninstall libprotobuf
conda uninstall protobuf

All 29 comments

I met the same problem too. it seems like u install several protobuf and use the wrong one, something like that.

I solved this on my computer and maybe it can help you. my environment is Ubuntu14.04, and i installed Anaconda(for python2.7) before i install Caffe. it happens that i used conda to install libprotobuf-dev, and this leads to conflict with the caffe's 'sudo apt-get install libprotobuf-dev' command, for 'apt-get' and conda installed different on my computer which can be find by 'locate protobuf', so i remove the Anaconda's version of libprotobuf, and no problem happens again.

By the way, if it's of interest, after encounter lots of similar issues across different platforms (different versions of protobuf, glog, python) we decided to provide a higher level support for customizable Caffe builds via CK workflow framework. This framework can detect all installed versions of dependencies (protobuf, cuda, glog, gflags, openblas, cudnn,python) and ask you to select the required one before building Caffe. It is an on-going community project, so maybe it can help you too:

@limTeTE Your solution works for me! Thank you so much! This problem just made me crazy yesterday ...

@limTeTE Your solution works for me! Thank you so much! This problem just made me crazy yesterday ...

@charan223 hahaha...no shame

conda uninstall libprotobuf
conda uninstall protobuf

@gaoyangyiqiao this's work for me!

make clean
It helped me in my case.

make clean
It helped me in my case.

This is also worked for me.

this does not work for me.
I have the same issue, for example
/usr/bin/protoc --version
libprotoc 2.6.1 in /usr/bin/protoc

protoc --version
libprotoc 3.4.0 in /home/lishuai/anaconda3/bin/protoc

uninstall protobuf using conda won't help, anyone have an idea? thanks.....

@derkbreeze Did you find a solution to this?

I don't understand why the default version installed by protobuf-compiler is 2.5.0

@limTeTE it works for me! Thank you very much!

Closing as solved by the community. Thank you!
If the problem reoccurs and none of the solutions given in this thread - please reopen/start a new issue.

@limTeTE You solved my problem. I've been dealing with it for 2 days and now I love you man.

I am getting this error @gfursin
[caffe] can't find path to CK entry "module:caffe" (?:032630d041b4fd8a:?)!

@derkbreeze you can probably retire the old /usr/bin/protoc and replace it with the newer version

@gaoyangyiqiao My issue is that I need the anaconda installation of libprotobuf and protobuf for another project I am working on. However, I am getting this conflicting issue when trying to install caffe required for Openpose ((https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/master/doc/installation.md#installation)) . How can I create an environment with libprotobuf and protobuf removed (without removing it from my disk). I understand I need to use a virtual environment for this but my attempts so far have been unsuccessful :(.

@SreehariRamMohan My suggestion is that you can use older version of protobuf and libprotobuf for caffe related project. And keep the anaconda version of protobuf exist as well. When using anaconda's protobuf, just open a new terminal and type: export PATH = /home/user/anaconda3/bin:$PATH to initialize the anaconda environment.

@derkbreeze So do I need to create a virtual environment for the Caffe Installation or will doing this allow me to install Caffe without getting conflicts with the protobuf and libprotobuff files.

Also @derkbreeze I checked the contents of my $PATH just now and it includes /home/user/anaconda3/bin at the start of it.

$PATH
-bash: /Users/sreeharirammohan/anaconda3/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/sreeharirammohan/anaconda/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:

@SreehariRamMohan Then by default, every time you start a terminal, you're entering the anaconda environment which the system should be using protobuf installed by anaconda which possibly will not be compatible with the protobuf needed by caffe, since in caffe the protobuf is version 2.6.0

Understood. How should I fix this incompatibility? Should I use a virtual environment?

@SreehariRamMohan You can create a virtual environment, but for me, my solution is to delete the
/Users/sreeharirammohan/anaconda3/bin: in your ~/.bashrc and restart a new terminal for the configuration to take effect and then compile caffe, you should be able to work out. And if you want to use anaconda environment, just do export PATH=/home/user/anaconda3/bin:$PATH to use anaconda.

@derkbreeze For some reason when I examine the ~/.bashrc with vi ~/.bashrc it is empty so I am unable to remove it.

@SreehariRamMohan Open a terminal and do echo $PATH to check your PATH environment.
Every time you edit your ~/.bashrc, make sure to source it or open a new terminal to make sure the change has taken effect. Or you might be using the system other than Ubuntu.

echo $PATH /Users/sreeharirammohan/anaconda3/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/sreeharirammohan/anaconda/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

I am using a MacOS system.

I have never edited my bashrc in the past, just modified the PATH variable.

I'm experiencing the issue described by the author of this issue despite the fact that I do not have protobuf installed inside a conda environment and the version number in /usr/local/include/google/protobuf/stubs/common.h matches the one required by caffe exactly. I have no idea what's going on here as the Makefile is very hard to comprehend.

@limtete It works for me, too! Thank you!!!

Was this page helpful?
0 / 5 - 0 ratings