aihot  2017-06-04 08:46:39  机器学习 |   查看评论   

       三年前的Mac到手后一直懒得做更新,主要是因为系统升级后一些有依赖的软件都需要更新,有时还挺容易出问题。为了安全稳定起见,OSX 10.9系统就被我用了三年。但是,这么久不更新实在跟不上潮流了,最近想安装TensorFlow,结果我这么旧的系统被它鄙视并且拒绝了,只好趁着假期把系统更新一下。结果一更新,原来的caffe就用不了,编译过程出现了些问题,本博文记录了这些问题和对应的解决方案。

 
      更新后,系统及相关软件的版本为: 
  • OSX 10.12.4 (Sierra) 
  • Xcode 8.3.2 
  • Cuda 8.0.61 
  • cuDNN 5.0 
  • Matlab2016b
 
      caffe具体的安装过程见《深度学习框架Caffe在Mac上的安装和测试》,这里使用的是基于Anaconda的安装。Xcode和Cuda都是最新的,但是编译caffe的过程中发现cuda 8.0不支持Xcode 8.3,报错为:
 
  1. 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版本,运行

 

  1. sudo xcode-select --switch /Library/Developer/CommandLineTools

 

5, 查看clang的版本, 为8.0.0

 

  1. $ clang --version
  2. Apple LLVM version 8.0.0 (clang-800.0.42.1)
  3. Target: x86_64-apple-darwin16.5.0
  4. Thread model: posix
  5. InstalledDir: /Library/Developer/CommandLineTools/usr/bin

 

       于是使用make重新编译caffe即可。 

      运行 make, make test都没有问题,但是到了make runtest这一步,又出现以下问题:

 

  1. $ make runtest
  2. .build_release/tools/caffe
  3. dyld: Library not loaded: @rpath/./libhdf5_hl.10.dylib
  4.   Referenced from:.build_release/tools/caffe
  5.   Reason: image not found

 

       这个问题的原因是caffe没有成功连接到Anaconda安装的libhdf5_hl.10.dylib。解决办法如下: 

      1, 用otool查看caffe的连接库。

 

  1. $ cd build/tools
  2. $ otool -L caffe | grep rpath
  3.     @rpath/libcaffe.so.1.0.0-rc3 (compatibility version 0.0.0, current version 0.0.0)
  4.     @rpath/libcudart.8.0.dylib (compatibility version 0.0.0, current version 8.0.61)
  5.     @rpath/libcublas.8.0.dylib (compatibility version 0.0.0, current version 8.0.61)
  6.     @rpath/libcurand.8.0.dylib (compatibility version 0.0.0, current version 8.0.61)
  7.     @rpath/libhdf5_hl.10.dylib (compatibility version 12.0.0, current version 12.0.0)
  8.     @rpath/libhdf5.10.dylib (compatibility version 13.0.0, current version 13.0.0)
  9.     @rpath/libcudnn.5.dylib (compatibility version 0.0.0, current version 5.0.5)
  10.     @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的连接

 

除特别注明外,本站所有文章均为 赢咖4注册 原创,转载请注明出处来自Mac升级为Sierra后安装caffe的问题

留言与评论(共有 0 条评论)
   
验证码:
[lianlun]1[/lianlun]