The new version of caffe doesn't run on older version of prototxt
I clone the latest version of caffe but it didn't even work on the MNIST demo. I run following the website http://caffe.berkeleyvision.org/gathered/examples/mnist.html but it gives error:
Creating layer mnist F0226 16:02:12.381031 5959 layer_factory.hpp:77] Check failed: registry.count(type) == 1 (0 vs. 1) Unknown layer type: Data (known types: ) *** Check failure stack trace: *** @ 0x7effc27bd95d google::LogMessage::Fail() @ 0x7effc27c1fd7 google::LogMessage::SendToLog() @ 0x7effc27bfe39 google::LogMessage::Flush() @ 0x7effc27c013d google::LogMessageFatal::~LogMessageFatal() @ 0x4a69af caffe::Net<>::Init() @ 0x4a7f62 caffe::Net<>::Net() @ 0x491304 caffe::Solver<>::InitTrainNet() @ 0x491827 caffe::Solver<>::Init() @ 0x491c15 caffe::Solver<>::Solver() @ 0x41c328 caffe::GetSolver<>() @ 0x417bf1 train() @ 0x41b558 main @ 0x39c4a1ed5d (unknown) @ 0x415c45 (unknown)
I can see you have changed the layer_factor.h/cpp so it's even harder to follow what happen. Seems it's incompatible to the older version prototxt to set up layers.
With all releases one should do make clean && make superclean to clear out old materials before compiling the new release to avoid inconsistencies. See #1849 for release details.
Old proto are in fact upgraded automatically in many uses.
my prolem solved by here
原因分析(大概):
Caffe中每种层都需要在layer_factory中“注册”,然后才能根据prototxt中创建出来,然后build caffe的tools时,编译命令链接到caffe的静态库.a文件,由于没有直接引用各个层,所以这些层的代码并没有从.a文件中编译到./build/tools/caffe.bin中,导致无法找到层的类型。
成因推测:
我编译次数不多,推测是使用cmake生成Makefile时的参数不对,导致编译的工具集与caffe的静态库链接。
解决办法:
修改Makefile中关于tools相关部分(注意根据情况不同修改,注意备份):
原版:
$(TOOL_BINS): %.bin : %.o | $(DYNAMIC_NAME)
@ echo CXX/LD -o $@
$(Q)$(CXX) $< -o $@ $(LINKFLAGS) $(PWD)/build/lib/libcaffe.a $(LDFLAGS)
-Wl,-rpath,$(ORIGIN)/../lib
修改后:
$(TOOL_BINS): %.bin : %.o | $(DYNAMIC_NAME)
@ echo CXX/LD -o $@
$(Q)$(CXX) $< -o $@ $(LINKFLAGS) -L$(PWD)/build/lib -Wl,--whole-archive -lcaffe -Wl,--no-whole-archive $(LDFLAGS) -Wl,-rpath,$(ORIGIN)/../lib
修改替换 $(PWD)/build/lib/libcaffe.a为-L$(PWD)/build/lib -Wl,--whole-archive -lcaffe -Wl,--no-whole-archive $(LDFLAGS),即链接.a文件中所有符号,包括没有使用到的。