Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Several issues with compiling Caffe2 on Mac OSX without GPU #24

Closed
ghost opened this issue Nov 22, 2015 · 5 comments
Closed

Several issues with compiling Caffe2 on Mac OSX without GPU #24

ghost opened this issue Nov 22, 2015 · 5 comments

Comments

@ghost
Copy link

ghost commented Nov 22, 2015

Hi,
I have been trying to get Caffe 2 to work on Mac OSX without GPU/CUDA .

Here are the list of issues I have encountered.

The BREW files should have 'lopencv_imgcodecs'

I added following lines to register third party target and added "opencv_imgcoded" in each BREW file where opencv was used.

cc_thirdparty_target(
name="opencv_imgcodecs",
srcs=["BREW"],
commands=[],
cc_obj_files=["-lopencv_imgcodecs"],
)

This solved the linking issue and I was able to build.

After this even though I had specified non existing CUDA_DIR in build_env.py.
it did not detect and set following PYCAFFE2_CPU_ONLY correctly, resulting in cublas_2.h not found errors. I then went to caffe2_python.cc and manully commented out all portions that relied on #ifndef PYCAFFE2_CPU_ONLY.

With this I was able to build caffe2_python.cc .

Eventually all non GPU dependencies succeed except toy models.

[libprotobuf ERROR google/protobuf/descriptor_database.cc:57] File already exists in database: caffe/proto/caffe.proto
[libprotobuf FATAL google/protobuf/descriptor.cc:1018] CHECK failed: generated_database_->Add(encoded_file_descriptor, size):
libc++abi.dylib: terminating with uncaught exception of type google::protobuf::FatalException: CHECK failed: generated_database_->Add(encoded_file_descriptor, size):
Pycaffe+GPU is not available. Using CPU only version.
/bin/sh: line 1: 81061 Abort trap: 6 python generate_mnist_linear_classifier.py

This seems to be result of two copies of Protobuf being linked / mixed.

http://stackoverflow.com/questions/33017985/static-linking-with-generated-protobufs-causes-abort

I am now trying to edit BREW file to force it to use only the system protobuf.

@ghost
Copy link
Author

ghost commented Nov 22, 2015

This issue appears just by importing pycaffe in the alexnet notebook.
Here is the dump from the crash.

Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000

Application Specific Information:
/Users/aub3/Dropbox/Career/Technical/caffe2/gen/pycaffe2/libcaffe2_python_nogpu.so
abort() called
terminating with uncaught exception of type google::protobuf::FatalException: CHECK failed: generated_database_->Add(encoded_file_descriptor, size):

@Yangqing
Copy link
Contributor

(Adding @n3011 in case interested)

@Yangqing
Copy link
Contributor

Hi @AKSHAYUBHAT - could you let me know your opencv version? opencv_imgcodecs does not exist on my machine but I am using opencv 2, so I am wondering if it is a new target introduced in the new opencv 3 - in which case we should change the BREW file to support opencv3 as well.

Regarding the protobuf: there is a flag to force the use of system protobuf:

https://github.com/Yangqing/caffe2/blob/master/build_env.py#L18

Not sure if that solves your problem, but maybe give it a try? The whole build script is kind of experimental for now, so a bit cleaning might be needed.

@ghost
Copy link
Author

ghost commented Nov 22, 2015

pkg-config --modversion opencv
3.0.0

Regarding using system protobuf, I manually edited out the protobuf to force it to use system protobuf.
Even then it gave me the same error.

Here is my edited caffe_python.cc
https://github.com/AKSHAYUBHAT/DeepLearning/blob/master/caffe2/pycaffe2/caffe2_python.cc
The fatal exception occurs in libcaffe2_python_nogpu.so

Looking at following two issues It might be due to my system:
BVLC/caffe#1917
rbgirshick/py-faster-rcnn#24

@rfarid
Copy link

rfarid commented Nov 24, 2015

I hope this one helps:

https://github.com/Yangqing/caffe2/issues/25

https://github.com/Yangqing/caffe2/issues/25

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants