MAC下openBlas的安装

2017/6/21 posted in  Caffe I/O模块

这里我们安装openblas主要有两种方法:

  1. 通过git代码到本地并安装
  2. 通过brew来安装

git到本地编译安装.

  1. git代码到本地并安装
git clone https://github.com/xianyi/OpenBLAS.git
cd OpenBLAS
make -j4
make install

  1. 修改Caffe的Makefile.config
BLAS := open
BLAS_INCLUDE :=  /opt/OpenBLAS/include
BLAS_LIB := /opt/OpenBLAS/lib
  1. caffe重新make
make clean
make pycaffe
make all -j4
make test && runtest

使用brew进行安装

  1. brew uninstall openblas; brew install --fresh -vd openblas.运行上面命令安装openblas
  2. 更改Makefile.config

# Homebrew puts openblas in a directory that is not on the standard search path
BLAS_INCLUDE := $(shell brew --prefix openblas)/include
BLAS_LIB := $(shell brew --prefix openblas)/lib

  1. 重新编译

如果有些人遇到了这种错误

In file included from src/caffe/util/blocking_queue.cpp:5:
In file included from ./include/caffe/layers/base_data_layer.hpp:9:
In file included from ./include/caffe/layer.hpp:12:
In file included from ./include/caffe/util/math_functions.hpp:11:
./include/caffe/util/mkl_alternate.hpp:14:10: fatal error: 'cblas.h' file not found
#include <cblas.h>
         ^
1 error generated.
make: *** [.build_release/src/caffe/util/blocking_queue.o] Error 1

可以试试这个命令:

cmake -DCMAKE_CXX_FLAGS=-I/usr/local/opt/openblas/include ..