How to run caffe on Yosemite [Step by Step]

8,986 views
Skip to first unread message

Federico Monti

unread,
Oct 27, 2014, 6:37:17 PM10/27/14
to caffe...@googlegroups.com
Hi guys!!
In the last few days i worked hard to make run caffe on the last apple's release Yosemite, so to avoid to all of you the same problem I had, I've prepared a list of steps that brought me caffe to work on this:

1. Follow all the steps of the guide for OS X 10.9 till the requirements, installing also the hdf5 libraries and using boost 1.54 instead of 1.56. For some reasons boost 1.55 gave to me some problems during the building...
2. In Yosemite, the BLAS libraries have been moved or removed by Apple, but in any case caffe is not able to detect these libraries...my suggest in this case is to compile the OpenBlas which can be downloaded by here (http://www.openblas.net/) and build them in a suitable directory, easily addressable from the caffe-root directory (since you will need to refer it from the Makefile.config).

However, Openblas doesn't like the default apple compiler clang...so to be able to build them you will need the gcc and gfortran compiler, install them using:

brew install gcc

after this to build the OpenBlas using gcc you just need to give the command:

make CC=/usr/local/bin/gcc-4.9

from the OpenBlas directory and wait...

3. Finally, it's now time to build caffe! BUT, since the change of version of your OS, you need to modify a line in the makefile...in particular you have to look for the line:

ifneq ($(findstring 10.9, $(shell sw_vers -productVersion)),)

and change it with:

ifneq ($(findstring 10.10, $(shell sw_vers -productVersion)),)

otherwise caffe won't link the libstdc++ correctly to clang...
as last step you have only to set correctly the openblas in the makefile.config, placing the appropriate path to your OpenBlas root directory to the variables BLAS_INCLUDE and BLAS_LIB...

and that's it!! You have only to launch the make command and enjoy your caffe ;)

As I said this is a solution that i found on my own, maybe there are more suitable ways to make caffe working in Yosemite but...waiting for some official instructions, this can be a solution.

Hope it helps.

 

James Guo

unread,
Oct 28, 2014, 7:16:07 AM10/28/14
to caffe...@googlegroups.com
Hi Federico

Thank you very much for your post, it could be very useful. I have been stuck in OS X 10.10 before and had to switch to Ubuntu afterwards. I definitely will try your method. One question is that did you install boost-python? I check with my homebrew and cannot find formula of boost-python. Thank you for answering!

Best,
James

Daniel Golden

unread,
Oct 28, 2014, 12:19:22 PM10/28/14
to caffe...@googlegroups.com
A PR to fix the BLAS problems in OS X 10.10 / XCode 6 is open: https://github.com/BVLC/caffe/pull/1237

James Guo

unread,
Oct 29, 2014, 3:41:15 AM10/29/14
to caffe...@googlegroups.com
Now I complete make all on My OS X Yosemite, basically I did what Frederico said. Changing version from 10.9 to 10.10 in Makefile is really important. Otherwise, you will have fatal error: #include <tr1/tuple> not found and opencv problem since libstdc++ not correctly linked. Thank you very much!


On Monday, 27 October 2014 23:37:17 UTC+1, Federico Monti wrote:

Nissan Pow

unread,
Oct 29, 2014, 6:52:24 PM10/29/14
to caffe...@googlegroups.com
Great writeup (wish I found this earlier).

The BLAS libraries are there. You just need to symlink /usr/include/cblas.h to /System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Versions/Current/Headers/cblas.h and then caffe will find it. Also need to link against Accelerate instead of vecLib.

Michael Dillon

unread,
Nov 14, 2014, 9:19:08 PM11/14/14
to caffe...@googlegroups.com
To anyone who is still having problems getting boost 1.56 working with caffe on Yosemite.

I found a fix here: https://github.com/boostorg/config/commit/441311c950a40b9bea824016e9e43d7af5e3d4b0

Turns out boost is not checking for nvcc when on a mac.

On Monday, October 27, 2014 3:37:17 PM UTC-7, Federico Monti wrote:

Yukun Chen

unread,
Nov 21, 2014, 11:14:29 AM11/21/14
to caffe...@googlegroups.com
Hi, Federico, 
Thanks for your post, I did as you suggested, but get the link error:

/usr/bin/clang++ -shared -o .build_release/lib/libcaffe.so .build_release/src/caffe/proto/caffe.pb.o .build_release/src/caffe/proto/caffe_pretty_print.pb.o .build_release/src/caffe/blob.o .build_release/src/caffe/common.o .build_release/src/caffe/data_transformer.o .build_release/src/caffe/internal_thread.o .build_release/src/caffe/layer_factory.o .build_release/src/caffe/layers/absval_layer.o .build_release/src/caffe/layers/accuracy_layer.o .build_release/src/caffe/layers/argmax_layer.o .build_release/src/caffe/layers/base_data_layer.o .build_release/src/caffe/layers/bnll_layer.o .build_release/src/caffe/layers/concat_layer.o .build_release/src/caffe/layers/contrastive_loss_layer.o .build_release/src/caffe/layers/conv_layer.o .build_release/src/caffe/layers/cudnn_conv_layer.o .build_release/src/caffe/layers/cudnn_pooling_layer.o .build_release/src/caffe/layers/cudnn_relu_layer.o .build_release/src/caffe/layers/cudnn_sigmoid_layer.o .build_release/src/caffe/layers/cudnn_softmax_layer.o .build_release/src/caffe/layers/cudnn_tanh_layer.o .build_release/src/caffe/layers/data_layer.o .build_release/src/caffe/layers/dropout_layer.o .build_release/src/caffe/layers/dummy_data_layer.o .build_release/src/caffe/layers/eltwise_layer.o .build_release/src/caffe/layers/euclidean_loss_layer.o .build_release/src/caffe/layers/flatten_layer.o .build_release/src/caffe/layers/hdf5_data_layer.o .build_release/src/caffe/layers/hdf5_output_layer.o .build_release/src/caffe/layers/hinge_loss_layer.o .build_release/src/caffe/layers/im2col_layer.o .build_release/src/caffe/layers/image_data_layer.o .build_release/src/caffe/layers/infogain_loss_layer.o .build_release/src/caffe/layers/inner_product_layer.o .build_release/src/caffe/layers/loss_layer.o .build_release/src/caffe/layers/lrn_layer.o .build_release/src/caffe/layers/memory_data_layer.o .build_release/src/caffe/layers/multinomial_logistic_loss_layer.o .build_release/src/caffe/layers/mvn_layer.o .build_release/src/caffe/layers/neuron_layer.o .build_release/src/caffe/layers/pooling_layer.o .build_release/src/caffe/layers/power_layer.o .build_release/src/caffe/layers/relu_layer.o .build_release/src/caffe/layers/sigmoid_cross_entropy_loss_layer.o .build_release/src/caffe/layers/sigmoid_layer.o .build_release/src/caffe/layers/silence_layer.o .build_release/src/caffe/layers/slice_layer.o .build_release/src/caffe/layers/softmax_layer.o .build_release/src/caffe/layers/softmax_loss_layer.o .build_release/src/caffe/layers/split_layer.o .build_release/src/caffe/layers/tanh_layer.o .build_release/src/caffe/layers/threshold_layer.o .build_release/src/caffe/layers/window_data_layer.o .build_release/src/caffe/net.o .build_release/src/caffe/solver.o .build_release/src/caffe/syncedmem.o .build_release/src/caffe/util/benchmark.o .build_release/src/caffe/util/im2col.o .build_release/src/caffe/util/insert_splits.o .build_release/src/caffe/util/io.o .build_release/src/caffe/util/math_functions.o .build_release/src/caffe/util/upgrade_proto.o .build_release/src/caffe/layers/absval_layer.cuo .build_release/src/caffe/layers/base_data_layer.cuo .build_release/src/caffe/layers/bnll_layer.cuo .build_release/src/caffe/layers/concat_layer.cuo .build_release/src/caffe/layers/contrastive_loss_layer.cuo .build_release/src/caffe/layers/conv_layer.cuo .build_release/src/caffe/layers/cudnn_conv_layer.cuo .build_release/src/caffe/layers/cudnn_pooling_layer.cuo .build_release/src/caffe/layers/cudnn_relu_layer.cuo .build_release/src/caffe/layers/cudnn_sigmoid_layer.cuo .build_release/src/caffe/layers/cudnn_softmax_layer.cuo .build_release/src/caffe/layers/cudnn_tanh_layer.cuo .build_release/src/caffe/layers/dropout_layer.cuo .build_release/src/caffe/layers/eltwise_layer.cuo .build_release/src/caffe/layers/euclidean_loss_layer.cuo .build_release/src/caffe/layers/flatten_layer.cuo .build_release/src/caffe/layers/hdf5_data_layer.cuo .build_release/src/caffe/layers/hdf5_output_layer.cuo .build_release/src/caffe/layers/im2col_layer.cuo .build_release/src/caffe/layers/inner_product_layer.cuo .build_release/src/caffe/layers/lrn_layer.cuo .build_release/src/caffe/layers/mvn_layer.cuo .build_release/src/caffe/layers/pooling_layer.cuo .build_release/src/caffe/layers/power_layer.cuo .build_release/src/caffe/layers/relu_layer.cuo .build_release/src/caffe/layers/sigmoid_cross_entropy_loss_layer.cuo .build_release/src/caffe/layers/sigmoid_layer.cuo .build_release/src/caffe/layers/silence_layer.cuo .build_release/src/caffe/layers/slice_layer.cuo .build_release/src/caffe/layers/softmax_layer.cuo .build_release/src/caffe/layers/softmax_loss_layer.cuo .build_release/src/caffe/layers/split_layer.cuo .build_release/src/caffe/layers/tanh_layer.cuo .build_release/src/caffe/layers/threshold_layer.cuo .build_release/src/caffe/util/im2col.cuo .build_release/src/caffe/util/math_functions.cuo -stdlib=libstdc++ -fPIC -DNDEBUG -O2 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include -I/usr/local/include -I/opt/local/include -I.build_release/src -I./src -I./include -I/usr/local/cuda/include -I/usr/local/lib/OpenBLAS/include -I/usr/local/Cellar/opencv/2.4.9/include -I/usr/local/Cellar/boost/1.55.0_2/include -Wall -Wno-sign-compare -Wno-unneeded-internal-declaration -framework Accelerate -L/usr/lib -L/usr/local/lib -L/usr/lib -L/usr/local/cuda/lib -L/usr/local/lib/OpenBLAS/lib -L/usr/local/Cellar/opencv/2.4.9/lib -L/usr/local/Cellar/boost/1.55.0_2/lib/ -L/opt/local/lib/ -L/usr/local/lib/boost/lib -lcudart -lcublas -lcurand -lpthread -lglog -lgflags -lprotobuf -lleveldb -lsnappy -llmdb -lboost_system -lhdf5_hl -lhdf5 -lopencv_core -lopencv_highgui -lopencv_imgproc -lboost_thread-mt -lcblas

Undefined symbols for architecture x86_64:

  "cv::imread(std::string const&, int)", referenced from:

      caffe::WindowDataLayer<float>::InternalThreadEntry() in window_data_layer.o

      caffe::WindowDataLayer<double>::InternalThreadEntry() in window_data_layer.o

      caffe::ReadImageToDatum(std::string const&, int, int, int, bool, caffe::Datum*) in io.o

  "google::protobuf::MessageLite::ParseFromString(std::string const&)", referenced from:

      caffe::DataLayer<float>::DataLayerSetUp(std::vector<caffe::Blob<float>*, std::allocator<caffe::Blob<float>*> > const&, std::vector<caffe::Blob<float>*, std::allocator<caffe::Blob<float>*> >*) in data_layer.o

      caffe::DataLayer<float>::InternalThreadEntry() in data_layer.o

      caffe::DataLayer<double>::DataLayerSetUp(std::vector<caffe::Blob<double>*, std::allocator<caffe::Blob<double>*> > const&, std::vector<caffe::Blob<double>*, std::allocator<caffe::Blob<double>*> >*) in data_layer.o

      caffe::DataLayer<double>::InternalThreadEntry() in data_layer.o

      caffe::Net<float>::Forward(std::string const&, float*) in net.o

      caffe::Net<double>::Forward(std::string const&, double*) in net.o

  "google::protobuf::MessageFactory::InternalRegisterGeneratedFile(char const*, void (*)(std::string const&))", referenced from:

      caffe::protobuf_AddDesc_caffe_2eproto() in caffe.pb.o

      caffe::protobuf_AddDesc_caffe_5fpretty_5fprint_2eproto() in caffe_pretty_print.pb.o

  "google::protobuf::internal::WireFormatLite::ReadString(google::protobuf::io::CodedInputStream*, std::string*)", referenced from:

      caffe::FillerParameter::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*) in caffe.pb.o

      caffe::NetParameter::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*) in caffe.pb.o

      caffe::SolverParameter::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*) in caffe.pb.o

      caffe::SolverState::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*) in caffe.pb.o

      caffe::NetState::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*) in caffe.pb.o

      caffe::NetStateRule::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*) in caffe.pb.o

      caffe::LayerParameter::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*) in caffe.pb.o

      ...

  "google::protobuf::internal::WireFormatLite::WriteBytes(int, std::string const&, google::protobuf::io::CodedOutputStream*)", referenced from:

      caffe::Datum::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const in caffe.pb.o

  "google::protobuf::internal::WireFormatLite::WriteString(int, std::string const&, google::protobuf::io::CodedOutputStream*)", referenced from:

      caffe::FillerParameter::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const in caffe.pb.o

      caffe::NetParameter::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const in caffe.pb.o

      caffe::SolverParameter::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const in caffe.pb.o

      caffe::SolverState::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const in caffe.pb.o

      caffe::NetState::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const in caffe.pb.o

      caffe::NetStateRule::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const in caffe.pb.o

      caffe::LayerParameter::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const in caffe.pb.o

      ...

  "google::protobuf::internal::WireFormatLite::ReadBytes(google::protobuf::io::CodedInputStream*, std::string*)", referenced from:

      caffe::Datum::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*) in caffe.pb.o

  "google::protobuf::internal::StringTypeHandlerBase::Delete(std::string*)", referenced from:

      caffe::NetParameter::NetParameter(caffe::NetParameter const&) in caffe.pb.o

      caffe::NetParameter::~NetParameter() in caffe.pb.o

      caffe::SolverParameter::SolverParameter(caffe::SolverParameter const&) in caffe.pb.o

      caffe::SolverParameter::~SolverParameter() in caffe.pb.o

      caffe::NetState::NetState(caffe::NetState const&) in caffe.pb.o

      caffe::NetState::~NetState() in caffe.pb.o

      caffe::NetStateRule::NetStateRule(caffe::NetStateRule const&) in caffe.pb.o

      ...

  "google::protobuf::MessageLite::SerializeToString(std::string*) const", referenced from:

      caffe::Net<float>::Forward(std::string const&, float*) in net.o

      caffe::Net<double>::Forward(std::string const&, double*) in net.o

  "google::protobuf::DescriptorPool::FindFileByName(std::string const&) const", referenced from:

      caffe::protobuf_AssignDesc_caffe_2eproto() in caffe.pb.o

      caffe::protobuf_AssignDesc_caffe_5fpretty_5fprint_2eproto() in caffe_pretty_print.pb.o

  "google::protobuf::Message::SerializeToOstream(std::ostream*) const", referenced from:

      caffe::WriteProtoToBinaryFile(google::protobuf::Message const&, char const*) in io.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

make: *** [.build_release/lib/libcaffe.so] Error 1


Can you help me with that?
Thanks in advance.

On Monday, October 27, 2014 6:37:17 PM UTC-4, Federico Monti wrote:

Peter Wang

unread,
Nov 30, 2014, 12:46:23 AM11/30/14
to caffe...@googlegroups.com
Thx, guys for all the tips here.  I was able to complete installation of Caffe on Yosemite.  However, runtest showed 3 failed tests:

[  FAILED  ] PowerLayerTest/0.TestPowerGradientShiftZero, where TypeParam = caffe::FloatCPU

[  FAILED  ] PowerLayerTest/1.TestPowerGradient, where TypeParam = caffe::DoubleCPU

[  FAILED  ] PowerLayerTest/1.TestPowerGradientShiftZero, where TypeParam = caffe::DoubleCPU


Might these be due to Boost 1.5.6?  Or, something to do with BLAS?

BTW, I did get a warning when "brew install hdf5", about szip being built with libc++ instead of libstdc++, even though I did change the szip brew formula to specify libstdc++ according to the Caffe installation instruction.  Would appreciate any insight on why this was the case and how might it be fixed.

Michele Pratusevich

unread,
Nov 30, 2014, 5:08:50 PM11/30/14
to Peter Wang, caffe...@googlegroups.com
I had this same problem on OSX 10.9, solving it by installing / re-compiling boost 1.55 and boost-python 1.55 in addition to using MKL for BLAS. 

--
You received this message because you are subscribed to the Google Groups "Caffe Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to caffe-users...@googlegroups.com.
To post to this group, send email to caffe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/caffe-users/500548f3-d1fa-4d6c-b63c-5f562488067b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hiroaki Machida

unread,
Jan 15, 2015, 12:58:27 PM1/15/15
to caffe...@googlegroups.com
Hi.

libopencv_imgcodes.dylib has imread function,

Machida-no-MacBook-Air:opencv2 machidahiroaki$ nm -arch x86_64 /usr/local/lib/libopencv_imgcodecs.dylib | grep imread
0000000000004eb0 T __ZN2cv6imreadERKNS_6StringEi
0000000000004f50 t __ZN2cvL7imread_ERKNS_6StringEiiPNS_3MatE
so, you need to add opencv_imgcodes to LIBRARIES variable.

LIBRARIES += glog gflags protobuf leveldb snappy \
        lmdb \
        boost_system \
        hdf5_hl hdf5 \
        opencv_imgcodecs opencv_highgui opencv_imgproc opencv_core pthread

2014年11月22日土曜日 1時14分29秒 UTC+9 Yukun Chen:

Hiroaki Machida

unread,
Jan 15, 2015, 1:35:12 PM1/15/15
to caffe...@googlegroups.com
Hi guys.

It's FYI.

I got this this error when execute "make runtest".

[----------] 1 test from HDF5OutputLayerTest/0, where TypeParam = caffe::FloatCPU
[ RUN      ] HDF5OutputLayerTest/0.TestForward
Warning! ***HDF5 library version mismatched error***
The HDF5 header files used to compile this application do not match
the version used by the HDF5 library to which this application is linked.
Data corruption or segmentation faults may occur if the application continues.
This can happen when an application was compiled by one version of HDF5 but
linked with a different version of static or shared HDF5 library.
You should recompile the application or check your shared library related
settings such as 'LD_LIBRARY_PATH'.
You can, at your own risk, disable this warning by setting the environment
variable 'HDF5_DISABLE_VERSION_CHECK' to a value of '1'.
Setting it to 2 or higher will suppress the warning messages totally.
Headers are 1.8.13, library is 1.8.14

I solved it by adding this to Makefile.

    COMMON_FLAGS += -include /usr/local/include/hdf5.h -include /usr/local/include/hdf5_hl.h

It's because...

1. I installed anaconda and have HDF5 header files in ~/anaconda/include, of which versions is 1.8.13, and HDF5 dylib files in ~/anaconda/lib.

2. Somehow the compile cannot link objects to HDF5 dylib files in ~/anaconda/lib. I'm not sure but maybe it's because HDF5 dylib is not built with libstdc++.
    Machida-no-MacBook-Air:lib machidahiroaki$ otool -L libhdf5.dylib
    libhdf5.dylib:
     libhdf5.8.dylib (compatibility version 9.0.0, current version 9.2.0)
     /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.0.0)
     /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
     /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)

3. So, I installed HDF5 by "brew install hdf5". And HDF5 dylib files are installed in /usr/loca/lib.

4. I rerun "make runtest" and got a compatibility error. It's because the compiler loads HDF5 header files(1.8.13) in ~/anaconda/include first, then link objects to HDF5 dylib files in /usr/local/lib. As I said, HDF5 dylib files in ~/anaconda/lib is not linked for any reason.
     /Users/machidahiroaki/anaconda/include
     /Users/machidahiroaki/anaconda/include/python2.7
     /Users/machidahiroaki/anaconda/lib/python2.7/site-packages/numpy/core/include
     .build_debug/src
     ./src
     ./include
     /usr/local/atlas/include
     /usr/include/c++/4.2.1
     /usr/include/c++/4.2.1/backward
     /usr/local/include
     /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/include
     /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
     /usr/include
     /System/Library/Frameworks (framework directory)
     /Library/Frameworks (framework directory)

5. So, I added this to Makefile. the compiler uses both hdf5 header file and dylib files in /usr/local/(include/lib), and "make runtest" passes.
    COMMON_FLAGS += -include /usr/local/include/hdf5.h -include /usr/local/include/hdf5_hl.h



2014年10月28日火曜日 7時37分17秒 UTC+9 Federico Monti:

Hiroaki Machida

unread,
Jan 15, 2015, 2:02:32 PM1/15/15
to caffe...@googlegroups.com
In adittion, I failed to "brew install protobuf".

Adding this to install function solved it.

    /usr/local/Library/Formula/protobuf.rb:    ENV["MACOSX_DEPLOYMENT_TARGET"] = "10.9"


2014年10月28日火曜日 7時37分17秒 UTC+9 Federico Monti:
Hi guys!!

Evan Shelhamer

unread,
Jan 15, 2015, 11:34:02 PM1/15/15
to Hiroaki Machida, caffe...@googlegroups.com
PR #1740 has the updated Makefile for OS X 10.10.

I installed on OS X 10.10 with OpenCV 2.4.9, boost 1.55, and CUDA 6.5. No further changes to the Makefile for brew formulae were needed.

Evan Shelhamer

--
You received this message because you are subscribed to the Google Groups "Caffe Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to caffe-users...@googlegroups.com.
To post to this group, send email to caffe...@googlegroups.com.

Hiroaki Machida

unread,
Jan 29, 2015, 10:37:15 AM1/29/15
to caffe...@googlegroups.com, hiroaki.m...@gmail.com, shel...@eecs.berkeley.edu
I got this error. I'm trying to fix this.

Machida-no-MacBook-Air:python machidahiroaki$ python
Python 2.7.8 |Anaconda 2.1.0 (x86_64)| (default, Aug 21 2014, 15:21:46) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
>>> caffe_root = '../'  # this file is expected to be in {caffe_root}/examples
>>> import sys
>>> sys.path.insert(0, caffe_root + 'python')
>>> 
>>> import caffe
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6


2015年1月16日金曜日 13時34分02秒 UTC+9 Evan Shelhamer:

Hiroaki Machida

unread,
Jan 30, 2015, 4:05:25 PM1/30/15
to caffe...@googlegroups.com, hiroaki.m...@gmail.com, shel...@eecs.berkeley.edu
Brew for boost-python was failed. Removing anaconda path and reinstall boost-python with brew fixed it.

Machida-no-MacBook-Air:caffe machidahiroaki$ otool -L /usr/local/Cellar/boost-python/1.55.0/lib/libboost_python.dylib
/usr/local/Cellar/boost-python/1.55.0/lib/libboost_python.dylib:
/usr/local/lib/libboost_python.dylib (compatibility version 0.0.0, current version 0.0.0)
libpython2.7.dylib (compatibility version 2.7.0, current version 2.7.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 104.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
Machida-no-MacBook-Air:caffe machidahiroaki$ env | grep PATH
PATH=/Users/machidahiroaki/anaconda/bin:XXXXXXXXX
Machida-no-MacBook-Air:caffe machidahiroaki$ export PATH=XXXXXXXXX
Machida-no-MacBook-Air:caffe machidahiroaki$ which python
/usr/bin/python
Machida-no-MacBook-Air:caffe machidahiroaki$ brew uninstall boost-python
Uninstalling /usr/local/Cellar/boost-python/1.55.0...
Machida-no-MacBook-Air:caffe machidahiroaki$ brew install --build-from-source --fresh -vd boost-python
Machida-no-MacBook-Air:caffe machidahiroaki$ python
Python 2.7.6 (default, Sep  9 2014, 15:04:36) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> caffe_root = '../'  # this file is expected to be in {caffe_root}/examples
>>> import sys
>>> sys.path.insert(0, caffe_root + 'python')
>>> import caffe
>>> 


2015年1月30日金曜日 0時37分15秒 UTC+9 Hiroaki Machida:

Jay Patel

unread,
Feb 1, 2015, 2:11:32 PM2/1/15
to caffe...@googlegroups.com
I am getting this error while executing make pycaffe.

/usr/local/cuda/bin/nvcc -ccbin=/usr/bin/clang++ -Xcompiler -fPIC -DNDEBUG -O2 -I/Users/jay/anaconda/include -I/Users/jay/anaconda/include/python2.7 -I/Users/jay/anaconda/lib/python2.7/site-packages/numpy/core/include -I/usr/local/include -I.build_release/src -I./src -I./include -I/usr/local/cuda/include -I/Users/jay/include -gencode arch=compute_20,code=sm_20 -gencode arch=compute_20,code=sm_21 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_50,code=compute_50 -c src/caffe/layers/absval_layer.cu -o .build_release/src/caffe/layers/absval_layer.cuo 2> .build_release/src/caffe/layers/absval_layer.cuo.warnings.txt \

|| (cat .build_release/src/caffe/layers/absval_layer.cuo.warnings.txt; exit 1)

In file included from src/caffe/layers/absval_layer.cu:3:

In file included from ./include/caffe/layer.hpp:8:

In file included from ./include/caffe/blob.hpp:4:

./include/caffe/common.hpp:4:10: fatal error: 'boost/shared_ptr.hpp' file not found

#include <boost/shared_ptr.hpp>

         ^

1 error generated.

make: *** [.build_release/src/caffe/layers/absval_layer.cuo] Error 1


I have been trying to install caffe since a week, but I am unable to do so. I am tired of this error.. some help will be appreciated.. Thank a lot.

Am I missing setting path or some other error of clang and stdlib++  

??

Roopi

unread,
Feb 1, 2015, 6:05:10 PM2/1/15
to caffe...@googlegroups.com
Hi Jay ,

I initially had this error while running make all. 
I installed boost using brew install. I followed the steps as listed in caffe installation 10.9 till you edit the formulae. 
I also added the HDF5 dependency in the formulae though it is supposed to be provided by Anaconda python which I see you have. 
Make sure you uninstall and then install and build as written in the instructions. 

That seemed to have solved the problem you are seeing. 

I am still stuck on the error that it cannot find clang. 

clang: error: linker command failed with exit code 1 (use -v to see invocation


If I make progress I will repost 


Hope this helps

Hiroaki Machida

unread,
Feb 3, 2015, 12:59:41 PM2/3/15
to caffe...@googlegroups.com
I got this error.

Machida-no-MacBook-Air:python machidahiroaki$ python
Python 2.7.6 (default, Sep  9 2014, 15:04:36) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> caffe_root = '../'  # this file is expected to be in {caffe_root}/examples
>>> sys.path.insert(0, caffe_root + 'python')
>>> import caffe
>>> input_image = caffe.io.load_image('../examples/images/cat.jpg')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "../python/caffe/io.py", line 23, in load_image
    img = skimage.img_as_float(skimage.io.imread(filename)).astype(np.float32)
  File "/Library/Python/2.7/site-packages/skimage/io/_io.py", line 97, in imread
    img = call_plugin('imread', fname, plugin=plugin, **plugin_args)
  File "/Library/Python/2.7/site-packages/skimage/io/manage_plugins.py", line 209, in call_plugin
    return func(*args, **kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/pyplot.py", line 2177, in imread
    return _imread(*args, **kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/image.py", line 1246, in imread
    'more images' % handlers.keys())
ValueError: Only know how to handle extensions: ['png']; with PIL installed matplotlib can handle more images


I really don't want to do this, but here's a workaround.


# 'brew install pil' fails for 'Instead of PIL, consider `pip install pillow` or `brew install Homebrew/python/pillow`.
# I installed pillow, but it doesn't work.
# freetype is a prerequisite for PIL(Python Imaging Library)
# I'm not sure if it's necessary, but I did.
brew uninstall --force freetype
# I'm not sure if it's necessary, but modify install method as others.
brew edit freetype
brew install --build-from-source --fresh -vd freetype
ln -s /usr/local/Cellar/freetype/2.5.5/include/freetype2 /usr/local/include/freetype
# Download Imaging-1.1.7.tar.gz from http://www.pythonware.com/products/pil/
# Unzip it
sudo python setup.py install


2014年10月28日火曜日 7時37分17秒 UTC+9 Federico Monti:
Hi guys!!

Hiroaki Machida

unread,
Feb 4, 2015, 2:09:42 AM2/4/15
to caffe...@googlegroups.com
If you get errors about protobuf, you need to use protobuf version 2.6.1.

Brew edit protobuf and
modify url and sha1 to 
sha1 '6421ee86d8fb4e39f21f56991daa892a3e8d314b'

"google::protobuf::MessageLite::SerializeToString(std::string) const", referenced from:
caffe::Net::Forward(std::string const&, float) in net.o
caffe::Net::Forward(std::string const&, double) in net.o
"google::protobuf::Message::SerializeToOstream(std::ostream) const", referenced from:
caffe::WriteProtoToBinaryFile(google::protobuf::Message const&, char const) in io.o
"std::__1::basic_string, std::__1::allocator >::__init(char const, unsigned long)", referenced from:
caffe::protobuf_AssignDesc_caffe_2eproto() in caffe.pb.o
caffe::protobuf_AddDesc_caffe_2eproto() in caffe.pb.o
caffe::protobuf_AssignDesc_caffe_5fpretty_5fprint_2eproto() in caffe_pretty_print.pb.o


2014年10月28日火曜日 7時37分17秒 UTC+9 Federico Monti:
Hi guys!!

Kate Rakelly

unread,
Feb 5, 2015, 2:36:45 PM2/5/15
to caffe...@googlegroups.com
Yukun,

Did you ever fix this linking problem?
I have the exact same error.

Friendly User

unread,
Feb 5, 2015, 2:58:30 PM2/5/15
to caffe...@googlegroups.com

@Kate @Yukun

After running into of these issues a dozen times, they can now consistently be circumvented:

There are two paths to compile caffe on OS X

1) compile against <= CUDA 6.5 "libstdc++" in this case >>all<< the dependencies need to be re-compiled with "libstdc++" (harder, brew edit ... see install.html)

2) compile against >= CUDA 7.0 "libc++" just make sure to have fresh dependencies (compiled with "libc++" by default) and remove libstdc++ stuff in dev branch Makefile


I recommend choosing path number two:

get CUDA 7.0 (RC)

cd <caffe_root>

git checkout dev

edit Makefile and remove these two lines:

  # CXXFLAGS += -stdlib=libstdc++ << we dont want libstdc++ in this approach

  # LINKFLAGS += -stdlib=libstdc++

export CXX="/usr/bin/clang++ -std=c++11 -stdlib=libc++"

make clean

Get rid of all dependencies if you have already done the libstdc++ brew edit stunt

If necessary reinstall all dependencies (fast with brew uninstall)

Watch carefully for the output of

brew install protobuf
brew install opencv
(etc)
If you have some old libraries floating around you might have to do

brew unlink protobuf && brew link protobuf


Now everything should be beautifully aligned with libc++

make
and pray ;)

PS:  next week the whole process will be streamlined by the core development team. if you can't get it to run now just wait one week...


Roopi

unread,
Feb 5, 2015, 10:53:07 PM2/5/15
to caffe...@googlegroups.com
I have made all changes here and also on the thread installation errors but I still end up with the following error

"std::__throw_length_error(char const*)", referenced from:

      std::vector<boost::shared_ptr<caffe::Blob<double> >, std::allocator<boost::shared_ptr<caffe::Blob<double> > > >::_M_fill_insert(__gnu_cxx::__normal_iterator<boost::shared_ptr<caffe::Blob<double> >*, std::vector<boost::shared_ptr<caffe::Blob<double> >, std::allocator<boost::shared_ptr<caffe::Blob<double> > > > >, unsigned long, boost::shared_ptr<caffe::Blob<double> > const&) in absval_layer.cuo

      std::vector<boost::shared_ptr<caffe::Blob<float> >, std::allocator<boost::shared_ptr<caffe::Blob<float> > > >::_M_fill_insert(__gnu_cxx::__normal_iterator<boost::shared_ptr<caffe::Blob<float> >*, std::vector<boost::shared_ptr<caffe::Blob<float> >, std::allocator<boost::shared_ptr<caffe::Blob<float> > > > >, unsigned long, boost::shared_ptr<caffe::Blob<float> > const&) in absval_layer.cuo

      std::vector<boost::shared_ptr<caffe::Blob<double> >, std::allocator<boost::shared_ptr<caffe::Blob<double> > > >::_M_fill_insert(__gnu_cxx::__normal_iterator<boost::shared_ptr<caffe::Blob<double> >*, std::vector<boost::shared_ptr<caffe::Blob<double> >, std::allocator<boost::shared_ptr<caffe::Blob<double> > > > >, unsigned long, boost::shared_ptr<caffe::Blob<double> > const&) in bnll_layer.cuo

      std::vector<boost::shared_ptr<caffe::Blob<float> >, std::allocator<boost::shared_ptr<caffe::Blob<float> > > >::_M_fill_insert(__gnu_cxx::__normal_iterator<boost::shared_ptr<caffe::Blob<float> >*, std::vector<boost::shared_ptr<caffe::Blob<float> >, std::allocator<boost::shared_ptr<caffe::Blob<float> > > > >, unsigned long, boost::shared_ptr<caffe::Blob<float> > const&) in bnll_layer.cuo

      std::vector<boost::shared_ptr<caffe::Blob<double> >, std::allocator<boost::shared_ptr<caffe::Blob<double> > > >::_M_fill_insert(__gnu_cxx::__normal_iterator<boost::shared_ptr<caffe::Blob<double> >*, std::vector<boost::shared_ptr<caffe::Blob<double> >, std::allocator<boost::shared_ptr<caffe::Blob<double> > > > >, unsigned long, boost::shared_ptr<caffe::Blob<double> > const&) in concat_layer.cuo

      std::vector<boost::shared_ptr<caffe::Blob<float> >, std::allocator<boost::shared_ptr<caffe::Blob<float> > > >::_M_fill_insert(__gnu_cxx::__normal_iterator<boost::shared_ptr<caffe::Blob<float> >*, std::vector<boost::shared_ptr<caffe::Blob<float> >, std::allocator<boost::shared_ptr<caffe::Blob<float> > > > >, unsigned long, boost::shared_ptr<caffe::Blob<float> > const&) in concat_layer.cuo

      std::vector<boost::shared_ptr<caffe::Blob<double> >, std::allocator<boost::shared_ptr<caffe::Blob<double> > > >::_M_fill_insert(__gnu_cxx::__normal_iterator<boost::shared_ptr<caffe::Blob<double> >*, std::vector<boost::shared_ptr<caffe::Blob<double> >, std::allocator<boost::shared_ptr<caffe::Blob<double> > > > >, unsigned long, boost::shared_ptr<caffe::Blob<double> > const&) in contrastive_loss_layer.cuo

      ...

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

make: *** [.build_release/lib/libcaffe.so] Error 1


Radek M

unread,
Feb 7, 2015, 9:19:27 AM2/7/15
to caffe...@googlegroups.com
Tried that, unfortunately no luck and I was really praying. ^^

/usr/bin/clang++ src/caffe/blob.cpp -pthread -fPIC -DNDEBUG -O2 -DUSE_CUDNN -I/Users/Radek/anaconda/include -I/Users/Radek/anaconda/include/python2.7 -I/Users/Radek/anaconda/lib/python2.7/site-packages/numpy/core/include -I/usr/local/include -I.build_release/src -I./src -I./include -I/usr/local/cuda/include -I/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/Headers -Wall -Wno-sign-compare -Wno-unneeded-internal-declaration -c -o .build_release/src/caffe/blob.o 2> .build_release/src/caffe/blob.o.warnings.txt \

|| (cat .build_release/src/caffe/blob.o.warnings.txt; exit 1)

In file included from src/caffe/blob.cpp:1:

In file included from ./include/caffe/blob.hpp:4:

In file included from ./include/caffe/common.hpp:18:

In file included from ./include/caffe/util/device_alternate.hpp:40:

./include/caffe/util/cudnn.hpp:59:32: error: unknown type name 'cudnnTensor4dDescriptor_t'; did you mean 'cudnnTensorDescriptor_t'?

inline void createTensor4dDesc(cudnnTensor4dDescriptor_t* desc) {

                               ^~~~~~~~~~~~~~~~~~~~~~~~~

                               cudnnTensorDescriptor_t

/usr/local/cuda/include/cudnn.h:107:42: note: 'cudnnTensorDescriptor_t' declared here

typedef struct cudnnTensorStruct*        cudnnTensorDescriptor_t;

                                         ^

In file included from src/caffe/blob.cpp:1:

In file included from ./include/caffe/blob.hpp:4:

In file included from ./include/caffe/common.hpp:18:

In file included from ./include/caffe/util/device_alternate.hpp:40:

./include/caffe/util/cudnn.hpp:60:15: error: use of undeclared identifier 'cudnnCreateTensor4dDescriptor'; did you mean 'cudnnCreateTensorDescriptor'?

  CUDNN_CHECK(cudnnCreateTensor4dDescriptor(desc));

              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

              cudnnCreateTensorDescriptor

./include/caffe/util/cudnn.hpp:11:28: note: expanded from macro 'CUDNN_CHECK'

    cudnnStatus_t status = condition; \

                           ^

/usr/local/cuda/include/cudnn.h:122:27: note: 'cudnnCreateTensorDescriptor' declared here

cudnnStatus_t CUDNNWINAPI cudnnCreateTensorDescriptor( cudnnTensorDescriptor_t   *tensorDesc );

                          ^

In file included from src/caffe/blob.cpp:1:

In file included from ./include/caffe/blob.hpp:4:

In file included from ./include/caffe/common.hpp:18:

In file included from ./include/caffe/util/device_alternate.hpp:40:

./include/caffe/util/cudnn.hpp:64:29: error: unknown type name 'cudnnTensor4dDescriptor_t'; did you mean 'cudnnTensorDescriptor_t'?

inline void setTensor4dDesc(cudnnTensor4dDescriptor_t* desc,

                            ^~~~~~~~~~~~~~~~~~~~~~~~~

                            cudnnTensorDescriptor_t

/usr/local/cuda/include/cudnn.h:107:42: note: 'cudnnTensorDescriptor_t' declared here

typedef struct cudnnTensorStruct*        cudnnTensorDescriptor_t;

                                         ^

In file included from src/caffe/blob.cpp:1:

In file included from ./include/caffe/blob.hpp:4:

In file included from ./include/caffe/common.hpp:18:

In file included from ./include/caffe/util/device_alternate.hpp:40:

./include/caffe/util/cudnn.hpp:72:29: error: unknown type name 'cudnnTensor4dDescriptor_t'; did you mean 'cudnnTensorDescriptor_t'?

inline void setTensor4dDesc(cudnnTensor4dDescriptor_t* desc,

                            ^~~~~~~~~~~~~~~~~~~~~~~~~

                            cudnnTensorDescriptor_t

/usr/local/cuda/include/cudnn.h:107:42: note: 'cudnnTensorDescriptor_t' declared here

typedef struct cudnnTensorStruct*        cudnnTensorDescriptor_t;

                                         ^

In file included from src/caffe/blob.cpp:1:

In file included from ./include/caffe/blob.hpp:4:

In file included from ./include/caffe/common.hpp:18:

In file included from ./include/caffe/util/device_alternate.hpp:40:

./include/caffe/util/cudnn.hpp:97:5: error: unknown type name 'cudnnTensor4dDescriptor_t'; did you mean 'cudnnTensorDescriptor_t'?

    cudnnTensor4dDescriptor_t bottom, cudnnFilterDescriptor_t filter,

    ^~~~~~~~~~~~~~~~~~~~~~~~~

    cudnnTensorDescriptor_t

/usr/local/cuda/include/cudnn.h:107:42: note: 'cudnnTensorDescriptor_t' declared here

typedef struct cudnnTensorStruct*        cudnnTensorDescriptor_t;

                                         ^

In file included from src/caffe/blob.cpp:1:

In file included from ./include/caffe/blob.hpp:4:

In file included from ./include/caffe/common.hpp:18:

In file included from ./include/caffe/util/device_alternate.hpp:40:

./include/caffe/util/cudnn.hpp:99:15: error: use of undeclared identifier 'cudnnSetConvolutionDescriptor'

  CUDNN_CHECK(cudnnSetConvolutionDescriptor(*conv, bottom, filter,

              ^

./include/caffe/util/cudnn.hpp:11:28: note: expanded from macro 'CUDNN_CHECK'

    cudnnStatus_t status = condition; \

                           ^

./include/caffe/util/cudnn.hpp:112:13: error: use of undeclared identifier 'CUDNN_POOLING_AVERAGE'; did you mean 'CUDNN_POOLING_MAX'?

    *mode = CUDNN_POOLING_AVERAGE;

            ^~~~~~~~~~~~~~~~~~~~~

            CUDNN_POOLING_MAX

/usr/local/cuda/include/cudnn.h:518:5: note: 'CUDNN_POOLING_MAX' declared here

    CUDNN_POOLING_MAX     = 0,

    ^

In file included from src/caffe/blob.cpp:1:

In file included from ./include/caffe/blob.hpp:4:

In file included from ./include/caffe/common.hpp:18:

In file included from ./include/caffe/util/device_alternate.hpp:40:

./include/caffe/util/cudnn.hpp:118:15: error: use of undeclared identifier 'cudnnSetPoolingDescriptor'; did you mean 'cudnnSetPoolingNdDescriptor'?

  CUDNN_CHECK(cudnnSetPoolingDescriptor(*conv, *mode, h, w,

              ^~~~~~~~~~~~~~~~~~~~~~~~~

              cudnnSetPoolingNdDescriptor

./include/caffe/util/cudnn.hpp:11:28: note: expanded from macro 'CUDNN_CHECK'

    cudnnStatus_t status = condition; \

                           ^

/usr/local/cuda/include/cudnn.h:546:27: note: 'cudnnSetPoolingNdDescriptor' declared here

cudnnStatus_t CUDNNWINAPI cudnnSetPoolingNdDescriptor(  cudnnPoolingDescriptor_t poolingDesc,

                          ^

In file included from src/caffe/blob.cpp:1:

In file included from ./include/caffe/blob.hpp:4:

In file included from ./include/caffe/common.hpp:18:

In file included from ./include/caffe/util/device_alternate.hpp:40:

./include/caffe/util/cudnn.hpp:118:58: error: cannot initialize a parameter of type 'const int *' with an lvalue of type 'int'

  CUDNN_CHECK(cudnnSetPoolingDescriptor(*conv, *mode, h, w,

                                                         ^

./include/caffe/util/cudnn.hpp:11:28: note: expanded from macro 'CUDNN_CHECK'

    cudnnStatus_t status = condition; \

                           ^

/usr/local/cuda/include/cudnn.h:549:67: note: passing argument to parameter 'windowDimA' here

                                                        const int windowDimA[],

                                                                  ^

9 errors generated.

make: *** [.build_release/src/caffe/blob.o] Error 1

Friendly User

unread,
Feb 7, 2015, 9:49:00 AM2/7/15
to caffe...@googlegroups.com
@Radek : disable USE_CUDNN in Makefile.config (or search threads for it)


Message has been deleted

Radek M

unread,
Feb 7, 2015, 1:50:53 PM2/7/15
to caffe...@googlegroups.com

Vasant Srinivasan

unread,
Feb 7, 2015, 4:23:59 PM2/7/15
to caffe...@googlegroups.com
Hey guys!

CUDA 7.0 libc++ is a much easier installation. Both make test and make runtest passed without errors, but I have the following error when running web_demo example. I am unsure where this is coming from.. OpenCV? 

I can confirm with a successful installation with boost 1.55 and hdf5 1.8.13 

vasants-MBP:caffe vasantsrinivasan$ python examples/web_demo/app.py -h

Traceback (most recent call last):

  File "examples/web_demo/app.py", line 13, in <module>

    from PIL import Image as PILImage

  File "/Users/vasantsrinivasan/anaconda/lib/python2.7/site-packages/PIL/Image.py", line 63, in <module>

    from PIL import _imaging as core

ImportError: dlopen(/Users/vasantsrinivasan/anaconda/lib/python2.7/site-packages/PIL/_imaging.so, 2): Library not loaded: libz.1.dylib

  Referenced from: /Users/vasantsrinivasan/anaconda/lib/python2.7/site-packages/PIL/_imaging.so

  Reason: image not found

James Guo

unread,
Feb 7, 2015, 4:34:09 PM2/7/15
to caffe...@googlegroups.com
I think this is because you didn't install Image module in Python? Personally I suspect it has nothing to do with Caffe :)

Vasant Srinivasan

unread,
Feb 7, 2015, 5:29:23 PM2/7/15
to caffe...@googlegroups.com
I agree! My C++ implementation works great! 

I have pillow installed, so I think the Image module is covered. I don't know where to debug (I am not too familiar with python, so that doesn't help). Thanks for your help.

Radek M

unread,
Feb 7, 2015, 6:43:49 PM2/7/15
to caffe...@googlegroups.com
Everything is running through now. Everything I did is documented in the readme of this fork.

Friendly User

unread,
Feb 7, 2015, 8:13:04 PM2/7/15
to caffe...@googlegroups.com
@Vasant:
PIL/_imaging.so, 2): Library not loaded: libz.1.dylib
 

try

pip install PIL

brew install libz




Roopi

unread,
Feb 9, 2015, 10:15:11 PM2/9/15
to caffe...@googlegroups.com
Hi 
Installed everything from the readme on this fork and I am still ending up with the following error :

This is just a snippet of what the error is :

     caffe::Layer<float>::CheckBlobCounts(std::vector<caffe::Blob<float>*, std::allocator<caffe::Blob<float>*> > const&, std::vector<caffe::Blob<float>*, std::allocator<caffe::Blob<float>*> > const&) in base_data_layer.cuo

      caffe::Layer<double>::CheckBlobCounts(std::vector<caffe::Blob<double>*, std::allocator<caffe::Blob<double>*> > const&, std::vector<caffe::Blob<double>*, std::allocator<caffe::Blob<double>*> > const&) in base_data_layer.cuo

      caffe::BNLLLayer<float>::Forward_gpu(std::vector<caffe::Blob<float>*, std::allocator<caffe::Blob<float>*> > const&, std::vector<caffe::Blob<float>*, std::allocator<caffe::Blob<float>*> >*) in bnll_layer.cuo

      caffe::BNLLLayer<float>::Backward_gpu(std::vector<caffe::Blob<float>*, std::allocator<caffe::Blob<float>*> > const&, std::vector<bool, std::allocator<bool> > const&, std::vector<caffe::Blob<float>*, std::allocator<caffe::Blob<float>*> >*) in bnll_layer.cuo

      caffe::BNLLLayer<double>::Forward_gpu(std::vector<caffe::Blob<double>*, std::allocator<caffe::Blob<double>*> > const&, std::vector<caffe::Blob<double>*, std::allocator<caffe::Blob<double>*> >*) in bnll_layer.cuo

      ...

  "std::__throw_length_error(char const*)", referenced from:

      std::vector<boost::shared_ptr<caffe::Blob<double> >, std::allocator<boost::shared_ptr<caffe::Blob<double> > > >::_M_fill_insert(__gnu_cxx::__normal_iterator<boost::shared_ptr<caffe::Blob<double> >*, std::vector<boost::shared_ptr<caffe::Blob<double> >, std::allocator<boost::shared_ptr<caffe::Blob<double> > > > >, unsigned long, boost::shared_ptr<caffe::Blob<double> > const&) in absval_layer.cuo

      std::vector<boost::shared_ptr<caffe::Blob<float> >, std::allocator<boost::shared_ptr<caffe::Blob<float> > > >::_M_fill_insert(__gnu_cxx::__normal_iterator<boost::shared_ptr<caffe::Blob<float> >*, std::vector<boost::shared_ptr<caffe::Blob<float> >, std::allocator<boost::shared_ptr<caffe::Blob<float> > > > >, unsigned long, boost::shared_ptr<caffe::Blob<float> > const&) in absval_layer.cuo

      std::vector<boost::shared_ptr<caffe::Blob<double> >, std::allocator<boost::shared_ptr<caffe::Blob<double> > > >::_M_fill_insert(__gnu_cxx::__normal_iterator<boost::shared_ptr<caffe::Blob<double> >*, std::vector<boost::shared_ptr<caffe::Blob<double> >, std::allocator<boost::shared_ptr<caffe::Blob<double> > > > >, unsigned long, boost::shared_ptr<caffe::Blob<double> > const&) in bnll_layer.cuo

      std::vector<boost::shared_ptr<caffe::Blob<float> >, std::allocator<boost::shared_ptr<caffe::Blob<float> > > >::_M_fill_insert(__gnu_cxx::__normal_iterator<boost::shared_ptr<caffe::Blob<float> >*, std::vector<boost::shared_ptr<caffe::Blob<float> >, std::allocator<boost::shared_ptr<caffe::Blob<float> > > > >, unsigned long, boost::shared_ptr<caffe::Blob<float> > const&) in bnll_layer.cuo

      std::vector<boost::shared_ptr<caffe::Blob<double> >, std::allocator<boost::shared_ptr<caffe::Blob<double> > > >::_M_fill_insert(__gnu_cxx::__normal_iterator<boost::shared_ptr<caffe::Blob<double> >*, std::vector<boost::shared_ptr<caffe::Blob<double> >, std::allocator<boost::shared_ptr<caffe::Blob<double> > > > >, unsigned long, boost::shared_ptr<caffe::Blob<double> > const&) in concat_layer.cuo

      std::vector<boost::shared_ptr<caffe::Blob<float> >, std::allocator<boost::shared_ptr<caffe::Blob<float> > > >::_M_fill_insert(__gnu_cxx::__normal_iterator<boost::shared_ptr<caffe::Blob<float> >*, std::vector<boost::shared_ptr<caffe::Blob<float> >, std::allocator<boost::shared_ptr<caffe::Blob<float> > > > >, unsigned long, boost::shared_ptr<caffe::Blob<float> > const&) in concat_layer.cuo

      std::vector<boost::shared_ptr<caffe::Blob<double> >, std::allocator<boost::shared_ptr<caffe::Blob<double> > > >::_M_fill_insert(__gnu_cxx::__normal_iterator<boost::shared_ptr<caffe::Blob<double> >*, std::vector<boost::shared_ptr<caffe::Blob<double> >, std::allocator<boost::shared_ptr<caffe::Blob<double> > > > >, unsigned long, boost::shared_ptr<caffe::Blob<double> > const&) in contrastive_loss_layer.cuo

      ...

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

make: *** [.build_release/lib/libcaffe.so] Error 1


I have been stuck at this error for a week now trying to figure out what is different. I am not sure what your Makefile.config changes are thought. 

I have enabled anaconda python and added the BLAS_LIB and INCLUDE Path as per Yosemite recommendations in the blog.

Any help would be appreciated 


Thanks

Radek M

unread,
Feb 11, 2015, 11:53:42 AM2/11/15
to caffe...@googlegroups.com
I'll check, remembering having the same error. Will try to reproduce it.

Radek M

unread,
Feb 12, 2015, 5:17:06 PM2/12/15
to caffe...@googlegroups.com
Checkout the dev branch. :)


Am Dienstag, 10. Februar 2015 04:15:11 UTC+1 schrieb Roopi:

Radek M

unread,
Feb 12, 2015, 8:24:11 PM2/12/15
to caffe...@googlegroups.com
Let me know if it worked. Maybe also try with "sudo make clean" before.

Roopi

unread,
Feb 12, 2015, 10:06:23 PM2/12/15
to caffe...@googlegroups.com
I tried both did not work. The only difference is that I have 10.10.2.

Roopi

unread,
Feb 12, 2015, 10:35:13 PM2/12/15
to caffe...@googlegroups.com
The only difference is I am getting this error 

Undefined symbols for architecture x86_64:

  "leveldb::DB::Open(leveldb::Options const&, std::string const&, leveldb::DB**)", referenced from:

      caffe::db::LevelDB::Open(std::string const&, caffe::db::Mode) in db.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

make: *** [.build_release/lib/libcaffe.so] Error 1


Radek M

unread,
Feb 13, 2015, 12:04:29 PM2/13/15
to caffe...@googlegroups.com
I'm sorry, don't know how to fix this.

Roopi

unread,
Feb 14, 2015, 12:24:51 AM2/14/15
to caffe...@googlegroups.com
Thanks for the try. I will try to reinstall caffe and see if it works

deep samal

unread,
Apr 12, 2015, 4:41:01 AM4/12/15
to caffe...@googlegroups.com
Thanks for the solution. Although this solves ld: symbol(s) not found for architecture x86_64 problem, Now I am getting error:- ld: library not found for -lopencv_imgcodecs
Mac OS 10.9, Cuda 6.5, Python- Anaconda, Opencv 2.4.11
Some are saying 2.4.11 doesn't have opencv_imgcodecs only 3.0 does which is in beta version and creating a lot of probe during brew install.
Any idea what to do?

On Thursday, January 15, 2015 at 12:58:27 PM UTC-5, Hiroaki Machida wrote:
Hi.

libopencv_imgcodes.dylib has imread function,

Machida-no-MacBook-Air:opencv2 machidahiroaki$ nm -arch x86_64 /usr/local/lib/libopencv_imgcodecs.dylib | grep imread
0000000000004eb0 T __ZN2cv6imreadERKNS_6StringEi
0000000000004f50 t __ZN2cvL7imread_ERKNS_6StringEiiPNS_3MatE
so, you need to add opencv_imgcodes to LIBRARIES variable.

LIBRARIES += glog gflags protobuf leveldb snappy \
        lmdb \
        boost_system \
        hdf5_hl hdf5 \
        opencv_imgcodecs opencv_highgui opencv_imgproc opencv_core pthread

2014年11月22日土曜日 1時14分29秒 UTC+9 Yukun Chen:
Hi, Federico, 
Thanks for your post, I did as you suggested, but get the link error:

/usr/bin/clang++ -shared -o .build_release/lib/libcaffe.so .build_release/src/caffe/proto/caffe.pb.o .build_release/src/caffe/proto/caffe_pretty_print.pb.o .build_release/src/caffe/blob.o .build_release/src/caffe/common.o .build_release/src/caffe/data_transformer.o .build_release/src/caffe/internal_thread.o .build_release/src/caffe/layer_factory.o .build_release/src/caffe/layers/absval_layer.o .build_release/src/caffe/layers/accuracy_layer.o .build_release/src/caffe/layers/argmax_layer.o .build_release/src/caffe/layers/base_data_layer.o .build_release/src/caffe/layers/bnll_layer.o .build_release/src/caffe/layers/concat_layer.o .build_release/src/caffe/layers/contrastive_loss_layer.o .build_release/src/caffe/layers/conv_layer.o .build_release/src/caffe/layers/cudnn_conv_layer.o .build_release/src/caffe/layers/cudnn_pooling_layer.o .build_release/src/caffe/layers/cudnn_relu_layer.o .build_release/src/caffe/layers/cudnn_sigmoid_layer.o .build_release/src/caffe/layers/cudnn_softmax_layer.o .build_release/src/caffe/layers/cudnn_tanh_layer.o .build_release/src/caffe/layers/data_layer.o .build_release/src/caffe/layers/dropout_layer.o .build_release/src/caffe/layers/dummy_data_layer.o .build_release/src/caffe/layers/eltwise_layer.o .build_release/src/caffe/layers/euclidean_loss_layer.o .build_release/src/caffe/layers/flatten_layer.o .build_release/src/caffe/layers/hdf5_data_layer.o .build_release/src/caffe/layers/hdf5_output_layer.o .build_release/src/caffe/layers/hinge_loss_layer.o .build_release/src/caffe/layers/im2col_layer.o .build_release/src/caffe/layers/image_data_layer.o .build_release/src/caffe/layers/infogain_loss_layer.o .build_release/src/caffe/layers/inner_product_layer.o .build_release/src/caffe/layers/loss_layer.o .build_release/src/caffe/layers/lrn_layer.o .build_release/src/caffe/layers/memory_data_layer.o .build_release/src/caffe/layers/multinomial_logistic_loss_layer.o .build_release/src/caffe/layers/mvn_layer.o .build_release/src/caffe/layers/neuron_layer.o .build_release/src/caffe/layers/pooling_layer.o .build_release/src/caffe/layers/power_layer.o .build_release/src/caffe/layers/relu_layer.o .build_release/src/caffe/layers/sigmoid_cross_entropy_loss_layer.o .build_release/src/caffe/layers/sigmoid_layer.o .build_release/src/caffe/layers/silence_layer.o .build_release/src/caffe/layers/slice_layer.o .build_release/src/caffe/layers/softmax_layer.o .build_release/src/caffe/layers/softmax_loss_layer.o .build_release/src/caffe/layers/split_layer.o .build_release/src/caffe/layers/tanh_layer.o .build_release/src/caffe/layers/threshold_layer.o .build_release/src/caffe/layers/window_data_layer.o .build_release/src/caffe/net.o .build_release/src/caffe/solver.o .build_release/src/caffe/syncedmem.o .build_release/src/caffe/util/benchmark.o .build_release/src/caffe/util/im2col.o .build_release/src/caffe/util/insert_splits.o .build_release/src/caffe/util/io.o .build_release/src/caffe/util/math_functions.o .build_release/src/caffe/util/upgrade_proto.o .build_release/src/caffe/layers/absval_layer.cuo .build_release/src/caffe/layers/base_data_layer.cuo .build_release/src/caffe/layers/bnll_layer.cuo .build_release/src/caffe/layers/concat_layer.cuo .build_release/src/caffe/layers/contrastive_loss_layer.cuo .build_release/src/caffe/layers/conv_layer.cuo .build_release/src/caffe/layers/cudnn_conv_layer.cuo .build_release/src/caffe/layers/cudnn_pooling_layer.cuo .build_release/src/caffe/layers/cudnn_relu_layer.cuo .build_release/src/caffe/layers/cudnn_sigmoid_layer.cuo .build_release/src/caffe/layers/cudnn_softmax_layer.cuo .build_release/src/caffe/layers/cudnn_tanh_layer.cuo .build_release/src/caffe/layers/dropout_layer.cuo .build_release/src/caffe/layers/eltwise_layer.cuo .build_release/src/caffe/layers/euclidean_loss_layer.cuo .build_release/src/caffe/layers/flatten_layer.cuo .build_release/src/caffe/layers/hdf5_data_layer.cuo .build_release/src/caffe/layers/hdf5_output_layer.cuo .build_release/src/caffe/layers/im2col_layer.cuo .build_release/src/caffe/layers/inner_product_layer.cuo .build_release/src/caffe/layers/lrn_layer.cuo .build_release/src/caffe/layers/mvn_layer.cuo .build_release/src/caffe/layers/pooling_layer.cuo .build_release/src/caffe/layers/power_layer.cuo .build_release/src/caffe/layers/relu_layer.cuo .build_release/src/caffe/layers/sigmoid_cross_entropy_loss_layer.cuo .build_release/src/caffe/layers/sigmoid_layer.cuo .build_release/src/caffe/layers/silence_layer.cuo .build_release/src/caffe/layers/slice_layer.cuo .build_release/src/caffe/layers/softmax_layer.cuo .build_release/src/caffe/layers/softmax_loss_layer.cuo .build_release/src/caffe/layers/split_layer.cuo .build_release/src/caffe/layers/tanh_layer.cuo .build_release/src/caffe/layers/threshold_layer.cuo .build_release/src/caffe/util/im2col.cuo .build_release/src/caffe/util/math_functions.cuo -stdlib=libstdc++ -fPIC -DNDEBUG -O2 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include -I/usr/local/include -I/opt/local/include -I.build_release/src -I./src -I./include -I/usr/local/cuda/include -I/usr/local/lib/OpenBLAS/include -I/usr/local/Cellar/opencv/2.4.9/include -I/usr/local/Cellar/boost/1.55.0_2/include -Wall -Wno-sign-compare -Wno-unneeded-internal-declaration -framework Accelerate -L/usr/lib -L/usr/local/lib -L/usr/lib -L/usr/local/cuda/lib -L/usr/local/lib/OpenBLAS/lib -L/usr/local/Cellar/opencv/2.4.9/lib -L/usr/local/Cellar/boost/1.55.0_2/lib/ -L/opt/local/lib/ -L/usr/local/lib/boost/lib -lcudart -lcublas -lcurand -lpthread -lglog -lgflags -lprotobuf -lleveldb -lsnappy -llmdb -lboost_system -lhdf5_hl -lhdf5 -lopencv_core -lopencv_highgui -lopencv_imgproc -lboost_thread-mt -lcblas

Undefined symbols for architecture x86_64:

  "cv::imread(std::string const&, int)", referenced from:

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

make: *** [.build_release/lib/libcaffe.so] Error 1


Can you help me with that?
Thanks in advance.

Carlos Treviño

unread,
May 5, 2015, 9:45:03 AM5/5/15
to caffe...@googlegroups.com
Thanks for the tips! I'm trying to install caffe but when I compile, those errors appear. Thanks in advance

vpn51128:caffe-future CarlosTrevino$ cp Makefile.config.example Makefile.config

vpn51128:caffe-future CarlosTrevino$ # Adjust Makefile.config (for example, if using Anaconda Python)

vpn51128:caffe-future CarlosTrevino$ make all

No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.

CXX src/caffe/blob.cpp

In file included from src/caffe/blob.cpp:4:

In file included from ./include/caffe/blob.hpp:10:

In file included from ./include/caffe/syncedmem.hpp:7:

In file included from ./include/caffe/util/math_functions.hpp:11:

./include/caffe/util/mkl_alternate.hpp:11:10: fatal error: 'cblas.h' file not found

#include <cblas.h>

         ^

1 error generated.

make: *** [.build_release/src/caffe/blob.o] Error 1

vpn51128:caffe-future CarlosTrevino$ make test

No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.

CXX src/caffe/test/test_accuracy_layer.cpp

In file included from src/caffe/test/test_accuracy_layer.cpp:8:

In file included from ./include/caffe/blob.hpp:10:

In file included from ./include/caffe/syncedmem.hpp:7:

In file included from ./include/caffe/util/math_functions.hpp:11:

./include/caffe/util/mkl_alternate.hpp:11:10: fatal error: 'cblas.h' file not found

#include <cblas.h>

         ^

1 error generated.

make: *** [.build_release/src/caffe/test/test_accuracy_layer.o] Error 1

vpn51128:caffe-future CarlosTrevino$ make runtest

No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.

CXX src/caffe/test/test_accuracy_layer.cpp

In file included from src/caffe/test/test_accuracy_layer.cpp:8:

In file included from ./include/caffe/blob.hpp:10:

In file included from ./include/caffe/syncedmem.hpp:7:

In file included from ./include/caffe/util/math_functions.hpp:11:

./include/caffe/util/mkl_alternate.hpp:11:10: fatal error: 'cblas.h' file not found

#include <cblas.h>

         ^

1 error generated.

make: *** [.build_release/src/caffe/test/test_accuracy_layer.o] Error 1

vpn51128:caffe-future CarlosTrevino$ 


Ting Lee

unread,
May 6, 2015, 4:42:25 AM5/6/15
to caffe...@googlegroups.com
I don't use Yosemite for now but I think this can be very useful in the future.

在 2014年10月27日星期一 UTC+1下午11:37:17,Federico Monti写道:

Carlos Treviño

unread,
May 6, 2015, 6:34:10 AM5/6/15
to caffe...@googlegroups.com
Hi guys!
I was able to run Caffe on Yosemite, the caffe-future has already fixed this problem and to make things easier i would suggest to use CMake to configure all settings like CUDNN or CPU only, and then to compile everything in Terminal using the commands:

make all
make test
make runtest

Hope it helps

Carlos Treviño

unread,
May 15, 2015, 10:02:00 AM5/15/15
to caffe...@googlegroups.com
Hi, i have no problems compiling caffe but when i try to import it the following message appears:

Fatal Python error: PyThreadState_Get: no current thread

any idea of how to solve this? 

Thanks in advance

Alex Bewley

unread,
Jul 12, 2015, 10:34:22 PM7/12/15
to caffe...@googlegroups.com
I too get the same error when trying to import caffe. \
Did you manage to resolve this issue?

Joshua peng

unread,
Nov 10, 2016, 10:18:34 PM11/10/16
to Caffe Users, alex....@gmail.com
I am having the same problem, any solutions figured out yet? Thanks,

雷伯涵

unread,
Mar 22, 2018, 10:24:10 AM3/22/18
to Caffe Users
Hi! I met the same problem resently and have not found a solution to this yet. How did you figure out this 3 yrs ago?
Please reply. QAQ

在 2015年2月6日星期五 UTC+8上午11:53:07,Roopi写道:
Reply all
Reply to author
Forward
0 new messages