matcaffe_demo fails on Mac OS X 10.10/MATLAB_R2013b

772 views
Skip to first unread message

Hiroshi Kuwajima

unread,
Dec 21, 2014, 12:05:51 AM12/21/14
to caffe...@googlegroups.com
Hi, I am trying to use matcaffe on Mac OS X 10.10 and MATLAB_R2013b, but have trouble executing matcaffe_demo. 

I succeeded to make all, make test, make runtest, and make pycaffe, thanks to 10.9-specific Instructions on http://caffe.berkeleyvision.org/installation.html. And then, I succeeded to make matcaffe by editing mexopts.sh: 

$ diff /Applications/MATLAB_R2013b.app/bin/mexopts.sh ~/.matlab/R2013b/mexopts.sh
61c61
<             CFLAGS="$CFLAGS  -fexceptions"
---
>             CFLAGS="$CFLAGS  -fexceptions -Dchar16_t=UINT16_T"
128c128
<             CC='xcrun  -sdk macosx10.7  clang'
---
>             CC='xcrun  -sdk macosx10.10  clang -stdlib=libstdc++'
132c132
<             MW_SDKROOT_TMP="find `xcode-select -print-path` -name MacOSX10.7.sdk"
---
>             MW_SDKROOT_TMP="find `xcode-select -print-path` -name MacOSX10.10.sdk"
134c134
<             MACOSX_DEPLOYMENT_TARGET='10.7'
---
>             MACOSX_DEPLOYMENT_TARGET='10.10'
137c137
<             CFLAGS="$CFLAGS  -fexceptions"
---
>             CFLAGS="$CFLAGS  -fexceptions -Dchar16_t=UINT16_T -stdlib=libstdc++"
149,150c149,150
<             CXX='xcrun  -sdk macosx10.7  clang++'
<             CXXFLAGS="-fno-common -fexceptions -arch $ARCHS -isysroot $MW_SDKROOT -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
---
>             CXX='xcrun  -sdk macosx10.10  clang++ -stdlib=libstdc++'
>             CXXFLAGS="-fno-common -fexceptions -arch $ARCHS -isysroot $MW_SDKROOT -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -Dchar16_t=UINT16_T -stdlib=libstdc++"

However, I cannot run matcaffe_demo in MATLAB_R2013b with the error: 

>> matcaffe_demo
Invalid MEX-file '/Users/user/caffe/matlab/caffe/caffe.mexmaci64':
dlopen(/Users/user/caffe/matlab/caffe/caffe.mexmaci64, 6): Library not loaded:
/usr/local/lib/libtiff.5.dylib
  Referenced from: /usr/local/lib/libopencv_highgui.2.4.dylib
  Reason: Incompatible library version: libopencv_highgui.2.4.dylib requires version 8.0.0 or
  later, but libtiff.5.dylib provides version 6.0.0

Error in matcaffe_init (line 19)
if caffe('is_initialized') == 0

Error in matcaffe_demo (line 53)
  matcaffe_init();

Does anyone have any idea or experience to work around this? 

Thanks, 

Hiroshi 

Daniel Golden

unread,
Dec 22, 2014, 12:25:12 AM12/22/14
to caffe...@googlegroups.com

See https://github.com/BVLC/caffe/issues/655

The instructions there are for Linux, but the idea is the same on Mac. On Mac, replace ldd with otool -L and replace LD_PRELOAD with DYLD_INSERT_LIBRARIES.

Hiroshi Kuwajima

unread,
Dec 22, 2014, 3:50:15 AM12/22/14
to caffe...@googlegroups.com
Hi Daniel, thank you for your help. 

On my Mac OS X 10.10/MATLAB_R2013b, the results of commands

otool -L /Users/user/caffe/matlab/caffe/caffe.mexmaci64
otool -L /usr/local/lib/libopencv_highgui.2.4.dylib

both inside and outside of MATLAB are identical. Especially, the latter command displays 

/usr/local/lib/libtiff.5.dylib (compatibility version 8.0.0, current version 8.0.0)

which is not the version 6.0.0 one tried to be referenced from libopencv_highgui.2.4.dylib

Now I noticed that I have 3 different libtiffs in MATLAB, anaconda, and brew, and their versions are 6.0.0, 7.0.0, and 8.0.0, respectively. I guessed MATLAB_R2013b loads its own libtiff /Applications/MATLAB_R2013b.app/bin/maci64/libtiff.5.dylib even if otool displays /usr/local/lib/libtiff.5.dylib which is linked to the brew one. I think this MATLAB behavior is weird, though. 

Finally, I succeed to run matcaffe_init() in MATLAB by explicitly specifying /usr/local/lib/libtiff.5.dylib to load: 

DYLD_INSERT_LIBRARIES=/usr/local/lib/libtiff.5.dylib /Applications/MATLAB_R2013b.app/bin/matlab

I appreciate your help. 

Hiroshi 
Reply all
Reply to author
Forward
0 new messages