三年前的Mac到手后一直懒得做更新,主要是因为系统升级后一些有依赖的软件都需要更新,有时还挺容易出问题。为了安全稳定起见,OSX 10.9系统就被我用了三年。但是,这么久不更新实在跟不上潮流了,最近想安装TensorFlow,结果我这么旧的系统被它鄙视并且拒绝了,只好趁着假期把系统更新一下。结果一更新,原来的caffe就用不了,编译过程出现了些问题,本博文记录了这些问题和对应的解决方案。
- OSX 10.12.4 (Sierra)
- Xcode 8.3.2
- Cuda 8.0.61
- cuDNN 5.0
- Matlab2016b
- nvcc fatal : The version ('80300') of the host compiler ('Apple clang') is not supported
通过搜索发现,cuda 8.0是支持Xcode 8.2的,于是将Xcode降为8.2版本。解决步骤为:
1,登录apple开发者网站:http://developer.apple.com/downloads/
2,下载命令行工具: Command Line Tools (macOS 10.12) for Xcode 8.3
3,安装Command Line Tools
4,将Xcode改为命令行工具对于的8.2版本,运行
- sudo xcode-select --switch /Library/Developer/CommandLineTools
5, 查看clang的版本, 为8.0.0
- $ clang --version
- Apple LLVM version 8.0.0 (clang-800.0.42.1)
- Target: x86_64-apple-darwin16.5.0
- Thread model: posix
- InstalledDir: /Library/Developer/CommandLineTools/usr/bin
于是使用make重新编译caffe即可。
运行 make, make test都没有问题,但是到了make runtest这一步,又出现以下问题:
- $ make runtest
- .build_release/tools/caffe
- dyld: Library not loaded: @rpath/./libhdf5_hl.10.dylib
- Referenced from:.build_release/tools/caffe
- Reason: image not found
这个问题的原因是caffe没有成功连接到Anaconda安装的libhdf5_hl.10.dylib。解决办法如下:
1, 用otool查看caffe的连接库。
- $ cd build/tools
- $ otool -L caffe | grep rpath
- @rpath/libcaffe.so.1.0.0-rc3 (compatibility version 0.0.0, current version 0.0.0)
- @rpath/libcudart.8.0.dylib (compatibility version 0.0.0, current version 8.0.61)
- @rpath/libcublas.8.0.dylib (compatibility version 0.0.0, current version 8.0.61)
- @rpath/libcurand.8.0.dylib (compatibility version 0.0.0, current version 8.0.61)
- @rpath/libhdf5_hl.10.dylib (compatibility version 12.0.0, current version 12.0.0)
- @rpath/libhdf5.10.dylib (compatibility version 13.0.0, current version 13.0.0)
- @rpath/libcudnn.5.dylib (compatibility version 0.0.0, current version 5.0.5)
- @rpath/libpython2.7.dylib (compatibility version 2.7.0, current version 2.7.0)
可以看到caffe连接到了@rpath/libhdf5_hl.10.dylib 而不是Anaconda中的hdf5。
2, 使用install_name_tool -change 重新设置hdf5的连接