Open ezyang opened 7 years ago
Docs are in the gh-pages branch. Glad to have your help diagnosing as the protobuf problems seem to keep changing as versions get updated, plus there's inconsistencies in the conda packages. Generally you'll want system protobuf and python protobuf to match. Try downgrading the brew install to 3.2.0 unless you can find a conda package that is 3.3.0 to match the brew installation.
You can also try out the latest wheel and see if that works for you. https://caffe2.ai/docs/getting-started.html?platform=mac&configuration=prebuilt
OK, I've diagnosed why we're picking up the wrong version of protobuf on a OS X system with Brew. Look at this:
-- Found gflags (include: /usr/local/include, library: /usr/local/lib/libgflags.dylib)
-- Found system gflags install.
-- Found glog (include: /usr/local/include, library: /usr/local/lib/libglog.dylib)
-- Found system glog install.
This is disaster! What this means is that we will add /usr/local/include
to our include path at some arbitrary point. If we are unlucky (as is the case here), /usr/local/include
may have higher precedence over my local Anaconda include directory, so even though CMake explicitly configured Anaconda in one directory, /usr/local/include
ends up clobbering the local definition.
Here's a relevant StackOverflow question: https://stackoverflow.com/questions/7752609/cmake-ordering-of-include-directories-how-to-mix-system-and-user-based-includ (except that the problem in their case is the other way around.)
FIX: Running conda install -y --channel https://conda.anaconda.org/conda-forge gflags glog numpy protobuf=3.3.0
will install a version of protobuf that matches the version installed by brew. This will allow the sudo make install
step to properly compile (if it doesn't, from what I can tell you need to re-run cmake -DUSE_CUDA=OFF ..
.
HTH
The documentation for Ubuntu is off as well. It lists 3.2.0 while it should be 3.1.0.
In addition, the required protobuf release should be installed manually since using 'sudo apt-get install ...' will install 2.6.x, which will lead to a version mismatch.
Wanted to confirm that I also had a similar problem on Ubuntu and its fixed by updating the protobuf compiler, protoc, to match the Python version installed by Conda which was mentioned in the comment above. My steps to fix this issue follow:
conda list protobuf
protoc --version
sudo cp bin/protoc /usr/bin/
sudo rm -r /usr/include/google/protobuf/
sudo cp -r include/google/protobuf/ /usr/include/google/protobuf/
protoc --version
git clone --recursive https://github.com/caffe2/caffe2.git && cd caffe2
make && cd build && sudo make install
Hopefully this will save someone some time.
@AbsoluteStratos save my life.
In Mac OSX, I need little bit different command, because nowadays protobuf for caffe2 changed to ver 3.1 and the path of protobuf in OSX is different from that ubuntu.
I firstly do
brew install protobuf@3.1
conda install -y --channel https://conda.anaconda.org/conda-forge \
future \
gflags \
glog \
numpy \
protobuf=3.1.0 \
six
and secondly
cd /usr/local/Cellar/protobuf@3.1/3.1.0
sudo cp bin/protoc /usr/local/bin/
sudo rm -r /usr/local/include/google/protobuf/
sudo cp -r include/google/protobuf/ /usr/local/include/google/protobuf/
sudo cp -r lib /usr/local/
below is for Korean who don't want to translate English.
이 글을 읽고 계신다면 분명 까페2를 설치하는데 애를 먹고 계신 것이겠죠. 까페2 공식 홈페이지에 나온대로 설치를 하면 cmake가 brew나 conda가 설치한 protobuf가 아닌 시스템에 기본으로 내장된 protobuf를 사용해서 문제가 발생하실 겁니다. (현재 기준으로 까페2 공식 홈페이지에서는 3.1을 쓰라고 하고 있습니다.)
만약 우분투를 쓰신다면 제 윗분이 하신 방식대로 하면 되고요. 맥을 쓰신다면 제가 써놓은 커맨드를 입력하시면 될 겁니다.
The comment of @cheetah132 was very helpful!
One more thing I found (on Mac OSX) is, when I installed conda install libgcc
, cmake selects anaconda's c++ compiler and causes weird syntax errors while building caffe2.
So I removed conda, installed again, and succeeded in building caffe2.
I post the wrong message. This comment should be in #1684
Steps to reproduce:
Follow the instructions at https://caffe2.ai/docs/getting-started.html?platform=mac&configuration=compile for Mac OS X build from source. The most important things:
brew install protobufs
. At the time of writing the protobufs that brew installs by default is 3.3.0conda install -y --channel https://conda.anaconda.org/conda-forge gflags glog numpy protobuf=3.2.0
(as specified in the docs)cmake -DUSE_CUDA=OFF ..
andmake
Expected result: Successful build
Actual result: You get the error:
This is actually the same error as https://github.com/caffe2/caffe2/issues/474 but I want to reopen the issue because there is legitimately a problem with caffe2 and its build documentation. I can see several problems:
The documentation on the build page suggests installing protobufs with both brew and Anaconda. There are multiple levels of wrongness here. First, brew installs 3.3.0, and Anaconda installs 3.2.0. That can't be right. Second, if you run both instructions, you end up with TWO copies of protobufs; only one is necessary. Finally, these aren't even the right version of protobufs for HEAD: HEAD needs 3.1.0 as of https://github.com/caffe2/caffe2/commit/d9e90a968d29116d9a60e61f7f358de7aef84498
cmake should test the version of protobufs, and error if it's the wrong version. That will give a lot more interpretable error, because you will be able to see what the wrong version is.
I haven't tried reproducing this carefully, but it seems that no matter how you setup your PATH, cmake will always end up using the brew installed protobufs rather than the Anaconda one, even if you have Anaconda earlier in your PATH. I'm not too sure what is going on here.
My suggestion is that we remove brew install protobufs from the instructions, suggest protobufs be installed with Anaconda, fix the version specified in the docs, and figure out why Anaconda isn't being picked up when there is both a brew and Anaconda version of protobufs. I'd be happy to contribute doc patches but I couldn't find the website sources.