Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
JenifferWuUCLA opened this issue May 25, 2017 · 30 comments

Comments

@JenifferWuUCLA
Copy link

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
^

@kalinlau
Copy link

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

@kalinlau
Copy link

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.

@gfursin
Copy link

gfursin commented May 29, 2017

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:

@liqing-ustc
Copy link

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

1 similar comment
@charan223
Copy link

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

@RoboEvangelist
Copy link

@charan223 hahaha...no shame

@gaoyangyiqiao
Copy link

conda uninstall libprotobuf
conda uninstall protobuf

@michaeldong
Copy link

@gaoyangyiqiao this's work for me!

@BalintMagyar4
Copy link

make clean
It helped me in my case.

@densechen
Copy link

make clean
It helped me in my case.

This is also worked for me.

@derkbreeze
Copy link

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.....

@rohun-tripathi
Copy link

@derkbreeze Did you find a solution to this?

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

@LaviLiu
Copy link

LaviLiu commented Apr 19, 2018

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

@Noiredd
Copy link
Member

Noiredd commented Apr 19, 2018

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.

@Noiredd Noiredd closed this as completed Apr 19, 2018
@4cce8er
Copy link

4cce8er commented Jun 11, 2018

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

@srbnghosh99
Copy link

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

@jeremy-rutman
Copy link

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

@SreehariRamMohan
Copy link

@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 :(.

@derkbreeze
Copy link

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

@SreehariRamMohan
Copy link

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

@SreehariRamMohan
Copy link

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:

@derkbreeze
Copy link

@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

@SreehariRamMohan
Copy link

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

@derkbreeze
Copy link

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

@SreehariRamMohan
Copy link

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

@derkbreeze
Copy link

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

@SreehariRamMohan
Copy link

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.

@Time0o
Copy link

Time0o commented May 1, 2019

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.

@eastsky0614
Copy link

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

@Himeshi
Copy link

Himeshi commented Sep 3, 2021

Adding the the /bin directory of the protoc installation to the PATH variable while removing the conda path solved the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests