SSD(old)版本caffe安装在已安装新版本caffe的服务器,出现的问题及解决方案

来源:互联网 发布:calvin klein钱包知乎 编辑:程序博客网 时间:2024/05/17 07:48

我出现的问题和下面引用别人的方案很相似,解决方案相同,下面把该方案列出,主要体会提解决问题的思路!

原文地址:http://blog.csdn.net/jonaspku/article/details/72637523


weiliu大神的ssd框架是很好用的,但在服务器重装之后,ssd编译却出现了奇怪的bug:

CXX src/caffe/data_transformer.cppIn file included from src/caffe/data_transformer.cpp:8:0:./include/caffe/data_transformer.hpp:69:24: error: ‘AnnotatedDatum’ does not name a type   void Transform(const AnnotatedDatum& anno_datum,                        ^./include/caffe/data_transformer.hpp:71:35: error: ‘AnnotationGroup’ was not declared in this scope                  RepeatedPtrField<AnnotationGroup>* transformed_anno_vec);                                   ^./include/caffe/data_transformer.hpp:71:50: error: template argument 1 is invalid                  RepeatedPtrField<AnnotationGroup>* transformed_anno_vec);                                                  ^./include/caffe/data_transformer.hpp:72:24: error: ‘AnnotatedDatum’ does not name a type   void Transform(const AnnotatedDatum& anno_datum,                        ^
......

一步一步来。

error: ‘AnnotatedDatum’ does not name a type 说明没找到定义,去看一下  “./include/caffe/data_transformer.hpp:69:24:”

void Transform(const AnnotatedDatum& anno_datum,                 Blob<Dtype>* transformed_blob,                 RepeatedPtrField<AnnotationGroup>* transformed_anno_vec);

结论同样:没有定义。

grep 一下,看看AnnotatedDatum定义到底在哪,很快,找到:

“caffe/proto/caffe.pb.h”

于是看看这个caffe.pb.h 怎么来的,发现是make 的第一步

PROTOC src/caffe/proto/caffe.proto

的产物,事实上,caffe.proto--→caffe.pb.h  这个过程是成功的,caffe.pb.h 也包含在路径之中。


那么问题来了:

CXX src/caffe/data_transformer.cpp找到了头文件caffe.pb.h而且,caffe.pb.h也给了AnnotatedDatum定义,那么为什么编译的时候报错AnnotatedDatum没定义(而非找不到caffe.pb.h)????



经过一系列痛苦的debug,原因在于Makefile 里面的一句话:

COMMON_FLAGS += $(foreach includedir,$(INCLUDE_DIRS),-isystem $(includedir))


注意蓝色字部分,

-isystem 是gcc的参数,表示引用路径,但是但是但是:

If a standard system include directory, or a directory specified with-isystem, is also specified with-I, the -Ioption is ignored. The directory is still searched but as asystem directory at its normal position in the system include chain. This is to ensure that GCC's procedure to fix buggy system headers andthe ordering for theinclude_next directive are not inadvertently changed. If you really need to change the search order for system directories,use the-nostdinc and/or -isystem

 options. 

大意就是-isystem里面如果和-I里面的头文件有冲突,会忽略-I!!!!!!!!


也就是,如果系统中(比如/usr/local/include)等地方有同名文件,会不进行本地(比如/home/XXX/caffe/include)的头文件搜索。

巧合的是,我之前安装caffe的时候又一次用了cmake,手贱写了make install。。。。。。于是我系统里确实有一套基础caffe环境,和ssd不同。。。。。。

至此,


改了几个字母:-isystem ---->-I

问题解决。


原创粉丝点击