Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opencv_dnn produce errors when a thirdparty also links against protobuf #823

Closed
agilmor opened this issue Oct 18, 2016 · 6 comments
Closed

Comments

@agilmor
Copy link

agilmor commented Oct 18, 2016

System information (version)
  • OpenCV => 3.1 (and probably 3.0)
  • Operating System / Platform => Debian Jessie (and others)
  • Compiler => Gcc 4.9 (and probably others)
Detailed description

When using OpenCV DNN with Caffe, both linking against Protobuf the following error apears:

[libprotobuf ERROR google/protobuf/descriptor_database.cc:57] File already exists in database: caffe.proto
[libprotobuf FATAL google/protobuf/descriptor.cc:1272] CHECK failed: generated_database_->Add(encoded_file_descriptor, size): 
terminate called after throwing an instance of 'google::protobuf::FatalException'

And then a std::terminate is thrown by protobuf.

Some people reported that its a problem with dynamic linking against Protobuf, but in my experience it also happen using static linking.

I'm not sure if the problem is in OpenCV, in Protobuf, or in Caffe.
But the current workaround is disable OpenCV DNN.
Is the problem really there, in opencv_dnn? Can we solve it?

Steps to reproduce

Build OpenCV with DNN.
Build Caffe with pycaffe or matcaffe.
In caffe, just run something like:

$ matlab -nodesktop -r "addpath ./matlab/; caffe.set_mode_cpu();"

And you will get the std::terminate.

Similar commands with pycaffe also reproduce this error.

Thanks!

PS: This comes from opencv/opencv#7425

@mshabunin
Copy link
Contributor

Can you please check whether the problem persists with the latest OpenCV version? Can you provide reproducing example in Python or C++?

@arrybn
Copy link
Contributor

arrybn commented May 23, 2017

@agilmor, there are modules in contrib, which try to use system protobuf and load caffe.proto: dnn_modern and cnn_3dobj. But dnn module builds its own version of protobuf, so there shouldn't be any conflicts with system protobuf. Try to disable dnn_modern and cnn_3dobj modules in your build (-DBUILD_opencv_cnn_3dobj=OFF -DBUILD_opencv_dnn_modern=OFF as options for cmake) and please let me know about results

@dkurt
Copy link
Member

dkurt commented May 30, 2017

@agilmor , also the latest Caffe changes might help, BVLC/caffe#5624.

@basvandijk
Copy link

In NixOS we also run into the same File already exists in database: caffe.proto error. We currently disable the dnn_modern and cnn_3dob modules to work around this issue.

@dkurt I tried building with the latest caffe which includes the cmake: rename libproto.a -> libcaffeproto.a patch but that didn't help unfortunately.

@dkurt
Copy link
Member

dkurt commented Oct 24, 2017

@basvandijk, we're going to avoid protobuf dependency by own parser, #1291 + opencv/opencv#9106. You may try it if you want to use DNN module.

basvandijk added a commit to LumiGuide/nixpkgs that referenced this issue Oct 24, 2017
Release notes: https://opencv.org/opencv-3-3.html

The contrib module cnn_3dobj is disabled because it fails to build.

The contrib module dnn_modern is disabled because it causes:
opencv/opencv_contrib#823
globin pushed a commit to NixOS/nixpkgs that referenced this issue Oct 24, 2017
Release notes: https://opencv.org/opencv-3-3.html

The contrib module cnn_3dobj is disabled because it fails to build.

The contrib module dnn_modern is disabled because it causes:
opencv/opencv_contrib#823
@alalek
Copy link
Member

alalek commented Nov 14, 2017

Migrate here: opencv/opencv#7425

asnt added a commit to asnt/pkgbuild that referenced this issue Dec 7, 2017
Third-party library liking opencv compile with the dnn module might
link a different protobuf shared library which makes it unusable as
protobuf cannot operate from two shared libs concurrently.
opencv/opencv_contrib#823
roelvandijk pushed a commit to LumiGuide/nixpkgs that referenced this issue Jan 12, 2018
Release notes: https://opencv.org/opencv-3-3.html

The contrib module cnn_3dobj is disabled because it fails to build.

The contrib module dnn_modern is disabled because it causes:
opencv/opencv_contrib#823
allnes pushed a commit to allnes/opencv_contrib that referenced this issue Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants