Caffe层创建失败 [英] Caffe layer creation failure

查看:1966
本文介绍了Caffe层创建失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在TEST阶段加载一个网络配置,它先有一个内存数据层,然后是一个卷积层。 MemoryData层创建成功,
但卷积层的创建在以下位置失败:

  LOG(INFO) ;& 创建层<< param.name(); 
const string& type = param.type();
CreatorRegistry& registry = Registry();
CHECK_EQ(registry.count(type),1)< 未知层类型:<<类型
<< (已知类型:<< LayerTypeList()<);

列印错误是:


F0519 14:54:12.494139 14504 layer_factory.hpp:77]检查失败:
registry.count(t ype)== 1(0对1)未知层类型:卷积
(已知类型:MemoryData)


注册表只有一个条目,确实有MemoryData。
当进入注册表创建函数时,它看起来像是从

调用的第一个(和最后,因为这是一个单例)

  REGISTER_LAYER_CLASS(MemoryData); 



in memory_data_later.cpp。



看到类似 REGISTER_LAYER_CLASS 调用其他支持的图层,但看起来他们从未被调用。
我如何解决它?



谢谢!

解决方案

p>当尝试将caffe静态链接到可执行文件时,会出现此错误。您需要传递额外的链接器标志,以确保包含层注册代码。



如果您使用cmake,请查看Targets.cmake:

  ############################### ################################################## ########## 
#定义全局Caffe_LINK标志,该标志是防止链接器排除
#需要的标志。一些不直接寻址,但通过静态构造函数注册的对象
if(BUILD_SHARED_LIBS)
set(Caffe_LINK caffe)
else()
if($ {CMAKE_CXX_COMPILER_ID}STREQUALClang)
set(Caffe_LINK -Wl,-force_load caffe)
elseif($ {CMAKE_CXX_COMPILER_ID}STREQUALGNU)
set(Caffe_LINK -Wl, - 整个存档caffe -Wl, - 无整个存档)
endif()
endif()

然后在你创建目标的地方:

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

快速解决方案是将caffe建置为连结共用资料库,



另请参阅此帖



只需在Windows上完成MSVC编译:
使用 / OPT:NOREF / INCLUDE 链接器选项。


I'm trying to load in TEST phase a network configuration which has a memory data layer first and then a convolution layer. The MemoryData layer creation succeeds, But the convolution layer's creation 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() << ")";

Printed error is:

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

registry has one entry only, indeed with MemoryData. When stepping into the registry creation functions, it looks like it first (and last, since this is a singletone) called from

REGISTER_LAYER_CLASS(MemoryData);

in memory_data_later.cpp.

I see similar REGISTER_LAYER_CLASS calls for the other supported layers, but it looks like they are never called. How could I solve it?

Thanks!

解决方案

This error occurs when trying to link caffe statically to an executable. You need to pass extra linker flags to make sure that layer registration code gets included.

If you are using cmake take a 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 target:

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

A quick solution would be to build and link caffe as a shared lib instead of static.

Also see this post.

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

这篇关于Caffe层创建失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆