caffe compilation troubleshooting
Issue 1
When I compile caffe toolkit(actually, a caffe fork: lisa-caffe-public), I always encounter some errors like:
1 | Tab found; better use space |
At the beginning, I thought these warnings were caused by gcc/g++, so I googled but found few result about this question.
Then I read the manual of gcc. In the manual, I found some useful information:
- Adding
-Wall
parameter aftergcc
will display all warning information. Adding `-w` parameter will turn off all warning information.
Adding `-Wstring` will display warning information about `string`. For example, if `-Wfloat-equal` is set, then it will warn if floating-point values are used in equality comparisons.
- Adding
-Wno-string
will not display warning information aboutstring
. For example, if-Wno-div-by-zero
, then it will not warn if integer division by zero.
So I try to review Makefile of caffe and comment some lines, but the warning information remain. The knowledge is useful, but can’t solve my problem.
After searching and searching, I finally found that it’s cpplint that caused errors. Cpplint is automated checker to make sure a C++ file follows Google’s C++ style guide. So I checked the Makefile, and find a line like this:
1 | EVERYTHING_TARGETS := all py$(PROJECT) test warn lint |
Explain: EVERYTHING_TARGETS
is target of command make everything
. When compile caffe, we can just type make everything
then gcc will do everything for us, including make all
, make test
, make warn
, make lint
.
So finally I got the simplest solution: just remove lint
from this line and recompiled it. This time everything went well.
Issue 2
When I train network using lisa-caffe-public, I encounter error:
1 | Unknown layer type: Python |
I searched about this question and found the answer here: uncomment WITH__PYTHON_LAYER: =1 in Makefile.config and recompile it.
lisa-caffe-public is a fork of fast-rcnn, which is a fork of original caffe of BVLC. The developer of fast-rcnn use Python layer
in his implementation and lisa’s caffe fork inherits it. In order to run the network correctly, we must use the flag when compiling the source code.
Issue 3
Error message like this:
1 | fatal error: caffe/proto/caffe.pb.h: No such file or directory |
caffe.pb.h is a header file generated by Google Protocol Buffer. Here is a tutorial about it. We must first generate it use commands below:
1 | $ protoc src/caffe/proto/caffe.proto --cpp_out=. |
Then compile again and we have the question solved.
Reference from here
Issue 4
Error message like this:
1 | Check failed: proto.SerializeToOstream(&output) |
This error happens when write snapshot to disk. There are three reasons that cause this error:
- The writing directory doesn’t exist
- You have to permission to write in the directory
- The target disk is full
You can check these 3 aspects.
Reference: https://github.com/BVLC/caffe/issues/1394
Issue 5
When use fast R-CNN, got error like this:
1 | Floating point exception(core dumped). |
It’s like something about box size. the solution is add filter_roidb
function in lib/fast_rcnn/train.py
file, like here.
Reference: https://github.com/rbgirshick/py-faster-rcnn/issues/159