Caffe layer creation failed

I am trying to load a network configuration at the TEST stage, which first has a memory data layer and then a convolution level. Creating a MemoryData layer succeeds, but creating a convolution level fails at the following location:

LOG(INFO) << "Creating layer " << param.name(); const string& type = param.type(); CreatorRegistry& registry = Registry(); CHECK_EQ(registry.count(type), 1) << "Unknown layer type: " << type << " (known types: " << LayerTypeList() << ")"; 

Print error:

F0519 14: 54: 12.494139 14504 layer_factory.hpp: 77] Verification failed: registry.count (t ype) == 1 (0 vs 1) Unknown layer type: Convolution (known types: MemoryData)

In the registry

there is only one entry, even with MemoryData. When you enter the registry creation functions, it looks first (and finally, since it is a singleton) called from

 REGISTER_LAYER_CLASS(MemoryData); 

in memory_data_later.cpp.

I see similar REGISTER_LAYER_CLASS calls for other supported levels, but it looks like they are never called. How can i solve this?

Thanks!

+7
c ++ deep-learning caffe layer
source share
2 answers

This error occurs when trying to link caffe statically with an executable file. You need to pass additional linker flags to make sure the layer registration code is enabled.

If you are using cmake, look at Targets.cmake:

 ########################################################################################### # Defines global Caffe_LINK flag, This flag is required to prevent linker from excluding # some objects which are not addressed directly but are registered via static constructors if(BUILD_SHARED_LIBS) set(Caffe_LINK caffe) else() if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") set(Caffe_LINK -Wl,-force_load caffe) elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(Caffe_LINK -Wl,--whole-archive caffe -Wl,--no-whole-archive) endif() endif() 

And then where you create your goal:

 # target add_executable(${name} ${source}) target_link_libraries(${name} ${Caffe_LINK}) 

A quick fix would be to create and bind caffe as a shared lib, not a static one.

Also see this post .

Just to complete this, to compile MSVC on Windows: Use the / OPT: NOREF or / INCLUDE linker options on the target executable or dll.

+7
source share

Replace -l$(PROJECT) with $(STATIC_LINK_COMMAND) in your Makefile in the appropriate places and delete the unnecessary boot path at runtime: -Wl,-rpath,$(ORIGIN)/../lib .

+2
source share

All Articles