参考

http://www.linuxidc.com/Linux/2016-09/135026.html

1. 安装brew,也叫homebrew,mac下类似于ubuntu的apt-get功能

curl -LsSf http://github.com/mxcl/homebrew/tarball/master | sudo tar xvz -C/usr/local --strip 1
brew update

2. 安装git包,包含gitk,(注:brew doctor可以用来诊断brew)

a. 安装git
brew install git b. 安装OpenBlas
brew install homebrew/science/openblas c. 安装Caffe的依赖库,在终端输入如下命令:
for x in snappy leveldb gflags glog szip hdf5 lmdb homebrew/science/opencv;
do
brew uninstall $x;
brew install --fresh -vd $x;
done
brew uninstall --force protobuf; brew install --with-python --fresh -vd protobuf
brew uninstall boost boost-python; brew install --fresh -vd boost boost-python
Info1:
Homebrew no longer needs to have ownership of /usr/local. If you wish you can
return /usr/local to its default ownership with:
sudo chown root:wheel /usr/local

3. 解决retina屏下gitk模糊的问题

# sudo chmod a+w /System/Library/Frameworks/Tk.framework/Versions/Current/Resources/Wish.app/Contents/Info.plist

# vim /System/Library/Frameworks/Tk.framework/Versions/Current/Resources/Wish.app/Contents/Info.plist 

添加

 <!-- support retina screen, xiaxing -->
  <key>NSHighResolutionCapable</key>
  <true/>

生效

# touch /System/Library/Frameworks/Tk.framework/Versions/Current/Resources/Wish.app

4. 安装Xcode,caffe编译依赖很多库,xcode可以提供,从官方AppStore安装即可。

5. 下载caffe工程,配置编译环境

git clone https://github.com/BVLC/caffe
cd <..>/caffe
cp Makefile.config.example Makefile.config // 拷贝生成我们使用的config文件

6. 修改Makefile.config文件,以下是我修改的部分,仅供参考:

# 我的电脑不支持GPU编译,选择CPU ONLY的编译选项

# CPU-only switch (uncomment to build without GPU support).
CPU_ONLY :=
# 我的OpenCV版本为2.X,所以注视掉此行

# Uncomment if you're using OpenCV 3
# OPENCV_VERSION :=
# 我的python环境是Anaconda,打开对应注释

# NOTE: this is required only if you will compile the python interface.
# We need to be able to find Python.h and numpy/arrayobject.h.
# PYTHON_INCLUDE := /usr/include/python2. \
/usr/lib/python2./dist-packages/numpy/core/include
# Anaconda Python distribution is quite popular. Include path:
# Verify anaconda location, sometimes it's in root.
ANACONDA_HOME := $(HOME)/anaconda2
PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
$(ANACONDA_HOME)/include/python2. \
$(ANACONDA_HOME)/lib/python2./site-packages/numpy/core/include # Uncomment to use Python (default is Python )
# PYTHON_LIBRARIES := boost_python3 python3.5m
# PYTHON_INCLUDE := /usr/include/python3.5m \
# /usr/lib/python3./dist-packages/numpy/core/include # We need to be able to find libpythonX.X.so or .dylib.
# PYTHON_LIB := /usr/lib
PYTHON_LIB := $(ANACONDA_HOME)/lib

7. 编译

# make all
# make test
# make runtest

8. 编译python wrapper

# make pycaffe

Error记录

Error 1.  <resolved, 从AppStore安装Xcode>
-------------------------------------------------------------------------------------------------------------------
0000095573:caffe xiaxing$ make all
ls: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/: No such file or directory
CXX src/caffe/blob.cpp
In file included from src/caffe/blob.cpp::
In file included from ./include/caffe/util/math_functions.hpp::
./include/caffe/util/mkl_alternate.hpp::: fatal error: 'cblas.h' file not found
#include <cblas.h>
^
error generated.
make: *** [.build_release/src/caffe/blob.o] Error
:caffe xiaxing$

Error 2.  <# make pycaffe出错>

0000095573:caffe xiaxing$ make pycaffe


CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp


python/caffe/_caffe.cpp:10:10: fatal error: 'numpy/arrayobject.h' file not found


#include <numpy/arrayobject.h>


1 error generated.


make: *** [python/caffe/_caffe.so] Error 1

Error 3. 
.build_release/test/test_all.testbin --gtest_shuffle --gtest_filter="-*GPU*"
dyld: Library not loaded: @rpath/libhdf5_hl..dylib
Referenced from: /Users/xiaxing/Desktop/baidu/caffe/caffe/.build_release/test/test_all.testbin
Reason: image not found
make: *** [runtest] Trace/BPT trap: 5 解决:
install_name_tool -add_rpath '/Users/work/anaconda/lib'  /Users/work/gitclone/caffe/.build_release/tools/caffe
Error .  test_all.testbin 继续出错-->
dyld: Library not loaded: @rpath/libhdf5_hl..dylib
Referenced from: /Users/work/gitclone/caffe/.build_release/test/test_all.testbin
Reason: image not found 解决:
install_name_tool -add_rpath '/Users/work/anaconda/lib' /Users/work/gitclone/caffe/.build_release/test/test_all.testbin

caffe之mac下环境搭建的更多相关文章

  1. Mac OS X下环境搭建 Sublime Text 2 环境变量配置 开发工具配置Golang (Go语言)

    Golang (Go语言) Mac OS X下环境搭建 环境变量配置 开发工具配置 Sublime Text 2 一.安装Golang的SDK 在官网http://golang.org/ 直接下载安装 ...

  2. Mac下docker搭建lnmp环境 + redis + elasticsearch

    之前在windows下一直使用vagrant做开发, 团队里面也是各种开发环境,几个人也没有统一环境,各种上线都是人肉,偶尔还会有因为开发.测试.生产环境由于软件版本或者配置不一致产生的问题, 今年准 ...

  3. Appium+python自动化16-appium1.6在mac上环境搭建启动ios模拟器上Safari浏览器

    前言 在mac上搭建appium踩了不少坑,先是版本低了,启动后无限重启模拟器.后来全部升级最新版本,就稳稳的了. 环境准备: 1.OS版本号10.12 2.xcode版本号8.3.2 3.appiu ...

  4. appium1.6在mac上环境搭建启动ios模拟器上Safari浏览器 转自:上海-悠悠

    前言 在mac上搭建appium踩了不少坑,先是版本低了,启动后无限重启模拟器.后来全部升级最新版本,就稳稳的了. 环境准备: 1.OS版本号10.12 2.xcode版本号8.3.2 3.appiu ...

  5. MAC OpenGL 环境搭建

    MAC OpenGL 环境搭建 基础库介绍 先要安装两个库一个是GLEW(OpenGL Extension Wrangler Library),另外一个是GLFW(Graphics Library F ...

  6. Redis的简单介绍及在Windows下环境搭建

    简单介绍 1,Redis是什么 最直接的还是看官方的定义吧. Redis is an open source (BSD licensed), in-memory data structure stor ...

  7. opencv在vc2010 express下环境搭建方法笔记+空白通用工程(已编译测试通过)(提供下载)

    opencv在VC2010 express版本下的环境搭建可以参见下面的wiki,这里面讲的非常清楚. http://wiki.opencv.org.cn/index.php/VC_2010_Expr ...

  8. Linux下环境搭建(四)——jenkins+gitlab+jmeter实践

    经过前三篇博文的介绍,jenkins+gitlab+jmeter接口自动化的框架就搭建成功了,详细可见 Linux下环境搭建(一)——java.tomcat配置 Linux下环境搭建(二)——jenk ...

  9. Mac Appium环境搭建

    安装brew ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)" 安装java brew install ...

随机推荐

  1. JAVA中如何判断一个输入是数字(小数和整数)还是字符串?

    public class Test1 {     public static void main(String[] args) {         Scanner input = new Scanne ...

  2. 63)对于STL基本概念东西 自己百度(没有整理)

    基础知识 看  C++进阶课程讲义的那个word文档

  3. 题解 P1884 【[USACO12FEB]过度种植(银)Overplanting 】

    什么,扫描线需要线段树? 那我第一个不干啊(其实是不会写) 这里介绍一种裸的扫描线: 我们根据x排序,对于相等的 \(x\) ,将 \(y\) 进入和退出分类讨论,然后全部放进set里面.每次 \(x ...

  4. myeclipse跟tomcat的同步

    一般来说,我们在myeclipse里把文件内容改了并保存之后,直接刷新网页就可以非常直观的看到内容的改变. 这是因为myeclipse检测到文件内容的变动,及时地把新的文件部署到了tomcat上. m ...

  5. POJ 2796 Feel Good 【单调栈】

    传送门:http://poj.org/problem?id=2796 题意:给你一串数字,需要你求出(某个子区间乘以这段区间中的最小值)所得到的最大值 例子: 6 3 1 6 4 5 2 当L=3,R ...

  6. JS 特效三大系列总结

    一. offset系列 1. offset系列的5个属性 1. offsetLeft : 用于获取元素到最近的定位父盒子的左侧距离 * 计算方式: 当前元素的左边框的左侧到定位父盒子的左边框右侧 * ...

  7. windows安装theano和keras

    系统: Windows 2008 python版本: Anaconda3 1. theano 安装 pip install theano 2. 安装g++ 下载安装mingw, 推荐版本tdm64-g ...

  8. SQL count与distinct的结合使用

    select Score,(select count(distinct score) from Scores where score >= s.score) as Rank from Score ...

  9. Debian8.8为普通用户添加sudo权限

    1.进入root用户,su root 输入密码,我们首先修改 /etc/sudoers 文件的属性为可写权限# chmod +w /etc/sudoers2.编辑 vim /etc/sudoers,添 ...

  10. VS2015提示资源视图加载失败

    关闭VS打开的resource,h这个文件,然后重启VS就行了.网上有很多其他的说法,我本地尝试始终不行,暴力解决. 今天发现,其实是不用重启的,直接对rc文件右键保存,就可以正常打开了......