OpenVINO之链接库

OpenVINO之链接库教程

1. 程序编好后为什么会提示plugins.xml:1:0: File was not found

我们回顾下OpenVINO(最新版本2020.2)的使用过程
在这里插入图片描述

  1. 新建InferenceEngine::Core core
  2. 读取模型,由xxx.binxxx.xml
  3. 配置输入输出格式(似乎这里可以不做,一切继承模型的配置)
  4. 将模型依靠InferenceEngine::Core::LoadNetwork()载入到硬件上
  5. 建立推理请求CreateInferRequest()
  6. 准备输入数据
  7. 推理
  8. 接住推理后的输出

如果查看一下第一步的源码就可以知道,InferenceEngine::Core::Core这个东西实际上是需要输入参数const std::string & xmlConfigFile的,如下图所示:
在这里插入图片描述

因此,如果我们没有规定这个xmlConfigFile的参数,它就会默认读取在inference_engine.so文件路径下的plugins.xml,可以查看windows下的your_openvino_install_root\Intel\OpenVINO\omz_demos_build\intel64\Release或者Linux下的your_openvino_install_root/openvino/inference_engine/lib/intel64找到。

为了好奇,可以看下plugins.xml这个里面到底有什么,这也跟下面的问题2有关:

<ie>
    <plugins>
        <plugin name="GNA" location="libGNAPlugin.so">
        </plugin>
        <plugin name="HETERO" location="libHeteroPlugin.so">
        </plugin>
        <plugin name="CPU" location="libMKLDNNPlugin.so">
        </plugin>
        <plugin name="MULTI" location="libMultiDevicePlugin.so">
        </plugin>
        <plugin name="GPU" location="libclDNNPlugin.so">
        </plugin>
        <plugin name="MYRIAD" location="libmyriadPlugin.so">
        </plugin>
        <plugin name="HDDL" location="libHDDLPlugin.so">
        </plugin>
        <plugin name="FPGA" location="libdliaPlugin.so">
        </plugin>
    </plugins>
</ie>

2. 我至少该链接哪些OpenVINO的库

编译教程提示,最基本的库,需要链接libinference_engine.solibinference_engine_legacy.so,所以也需要拖家带口把它们依赖的libinference_engine_transformations.solibngraph.so还有libtbb.so.2带上,需要注意的是,依赖库的路径有些并不是在your_openvino_install_root/openvino/inference_engine/lib/intel64下的,各位同学可以通过ldd libinference_engine.so的方式找到准确的依赖库的位置。算了,我这里就把路径全部提出来吧:

  • libinference_engine.so: root/openvino/inference_engine/lib/intel64
  • libinference_engine_legacy.so: root/openvino/inference_engine/lib/intel64
  • libinference_engine_transformations.so: root/openvino/inference_engine/lib/intel64
  • libngraph.so: root/deployment_tools/ngraph/lib/
  • libtbb.so.2: root/openvino/inference_engine/external/tbb/lib

在这里插入图片描述

然后,冷静下,Core Inference Engine Libraries后面还有Device-specific Plugin Libraries,这就是plugins.xml规定的plugin需要的库。根据模型运行在目标设备的类型,设置需要的库。比如,我的目标设备是CPU,所以就需要root/openvino/inference_engine/lib/intel64下的libMKLDNNPlugin.so,因此需要将plugins.xml修改为:

<ie>
    <plugins>
        <plugin name="CPU" location="libMKLDNNPlugin.so">
        </plugin>
    </plugins>
</ie>

3. 提示符号未定义

my_lib.so: undefined reference to `InferenceEngine::Core::LoadNetwork(InferenceEngine::CNNNetwork, std::string const&, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > > const&)'
my_lib.so: undefined reference to `InferenceEngine::Data::getName() const'
my_lib.so: undefined reference to `InferenceEngine::Core::Core(std::string const&)'
my_lib.so: undefined reference to `InferenceEngine::details::InferenceEngineException::InferenceEngineException(std::string const&, int, std::string const&)'
my_lib.so: undefined reference to `InferenceEngine::Core::ReadNetwork(std::string const&, std::string const&) const'

莫慌,看看my_lib.so里面链接了什么:
在这里插入图片描述

可以看出,只链接了libinference_engine_legacy.so,缺了libinference_engine.so,为啥?检查下CMakeLists.txt吧,看看编译选项有没有add_definitions(-D _GLIBCXX_USE_CXX11_ABI=0)什么的,链接OpenVINO需要c++11或c++14。

4. 下期预告

  1. OpenVINO没有提供多输入、多输出示例,我该怎么办
    1. python
    2. c++
  2. OpenVINO怎么装
  3. 遇到的坑
  • 5
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值