带有OpenCV 3和NVIDIA Digits的Caffe:OpenCV版本冲突(2.4与3.0) [英] Caffe with OpenCV 3 and NVIDIA Digits: OpenCV version conflict (2.4 vs 3.0)

查看:157
本文介绍了带有OpenCV 3和NVIDIA Digits的Caffe:OpenCV版本冲突(2.4与3.0)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:

我希望同时使用 Caffe

I wish to use both Caffe and Digits such that I can use Caffe within the Digits framework or external to it.

但是,对于特定的项目,我要求Caffe使用OpenCV 3而不是OpenCV 2.4,默认情况下,Digits将安装它.该项目使用Digits外部的Caffe,并且不使用Digits框架.

However, for a particular project, I require that Caffe uses OpenCV 3 and not OpenCV 2.4, which Digits installs by default. This project uses Caffe external to Digits, and does not make any use of the Digits framework.

看来,通过安装Digits,我的OpenCV 3安装被OpenCV 2.4所破坏"了,这现在在我原来的Caffe安装中引起了问题.

It appears that by installing Digits, my OpenCV 3 installation was "clobbered" with OpenCV 2.4, which is now causing problems within my original Caffe installation.

为使事情更清楚,下面列出了我已采取的步骤.

To make things clearer, below is a listing of the steps that I have taken.

通过全新的Ubuntu 14.04安装:

From a fresh Ubuntu 14.04 installation:

  1. 根据 Ubuntu安装的Caffe依赖项(OpenCV除外) 安装指南
  2. 将OpenCV 3从源代码安装到/usr/local
  3. 经过测试的OpenCV安装
    • Demos包括OpenCV都运行良好 3种特定代码
  1. Installed Caffe dependencies (except OpenCV) as per the Ubuntu install guide
  2. Installed OpenCV 3 from source to /usr/local
  3. Tested OpenCV installation
    • Demos worked fine including OpenCV 3-specific code
  • 所有测试均通过,演示正常运行
  • Caffe和OpenCV 2.4默认是由安装程序脚本安装的
  • OpenCV 3被OpenCV 2.4(?)所破坏
  • 所有步骤都成功
  • 发生与OpenCV 3.0和2.4冲突有关的错误-以下详细信息.

编译命令:

g ++分类.cpp -o分类-I/home/josh/software/caffe/include/-L/home/josh/software/caffe/build/lib/-lcaffe -I/usr/local/cuda/include -L/usr/local/cuda/lib64 -lcuda -lcudart -lcublas -lcurand -I/home/josh/software/cudnn/include/-L/home/josh/software/cudnn/lib64/-lcudnn -L/usr /lib/x86_64-linux-gnu/-lglog -L/usr/local/lib -lboost_system -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_imgcodecs -DUSE_OPENCV

g++ classification.cpp -o classification -I/home/josh/software/caffe/include/ -L/home/josh/software/caffe/build/lib/ -lcaffe -I/usr/local/cuda/include -L/usr/local/cuda/lib64 -lcuda -lcudart -lcublas -lcurand -I/home/josh/software/cudnn/include/ -L/home/josh/software/cudnn/lib64/ -lcudnn -L/usr/lib/x86_64-linux-gnu/ -lglog -L/usr/local/lib -lboost_system -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_imgcodecs -DUSE_OPENCV

错误消息:

/usr/bin/ld:警告:/home/josh/software/caffe/build/lib//libcaffe.so所需的libopencv_core.so.3.0可能与libopencv_core.so.2.4冲突 /usr/bin/ld:/tmp/ccHaWcOl.o:对符号'_ZN2cv6String10deallocateEv'的未定义引用 //usr/local/lib/libopencv_core.so.3.0:添加符号时出错:命令行缺少DSO collect2:错误:ld返回1退出状态

/usr/bin/ld: warning: libopencv_core.so.3.0, needed by /home/josh/software/caffe/build/lib//libcaffe.so, may conflict with libopencv_core.so.2.4 /usr/bin/ld: /tmp/ccHaWcOl.o: undefined reference to symbol '_ZN2cv6String10deallocateEv' //usr/local/lib/libopencv_core.so.3.0: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status

问题:

  1. 如何最好地解决OpenCV版本冲突而不中断Caffe/Digits安装?
  2. 我需要删除OpenCV并重新安装Caffe和Digits吗?
    • 如果是这样,我需要采取其他措施来防止OpenCV版本冲突,同时仍允许Caffe(与OpenCV 3)和Digits并排工作吗?
  1. How do I best resolve the OpenCV version conflict without breaking either Caffe/Digits installations?
  2. Do I need to remove OpenCV and reinstall Caffe and Digits?
    • If so, what do I need to do differently to prevent the OpenCV version conflicts while still allowing Caffe (with OpenCV 3) and Digits to work side-by-side?

推荐答案

安装OpenCV库时,共享库的存储方式类似于libopencv_core.so.2.4.8,其中2.4.8是OpenCV的版本号. libopencv_core.so文件通常链接到系统中安装的OpenCV的最新版本.

When OpenCV library is installed, the shared libraries are stored like libopencv_core.so.2.4.8, where 2.4.8 is the version number of OpenCV. libopencv_core.so file usually links to the last version of OpenCV installed in the system.

因此,尽管最初将libopencv_core.so链接到libopencv_core.so.3.0,但在安装旧版本时,链接已更新为链接到旧版本.

Thus, though libopencv_core.so was initially linked to libopencv_core.so.3.0, when you installed the older version, the link got updated to link to the older version.

解决方法是在caffe中专门调用最新的OpenCV库.为此,您将必须修改caffe中存在的Makefile. 将所有出现的opencv_*替换为:libopencv_*.so.3.0

The workaround will be to specifically call the latest OpenCV library in caffe. To do so, you will have to modify the Makefile present in caffe. Replace all occurrences of opencv_* to :libopencv_*.so.3.0

这篇关于带有OpenCV 3和NVIDIA Digits的Caffe:OpenCV版本冲突(2.4与3.0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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