遇到这样一个错误
/usr/local/lib/python2.7/site-packages/chainer/_environment_check.py:38: UserWarning: Accelerate has been detected as a NumPy backend library.
vecLib, which is a part of Accelerate, is known not to work correctly with Chainer.
We recommend using other BLAS libraries such as OpenBLAS.
For details of the issue, please see
https://docs.chainer.org/en/stable/tips.html#mnist-example-does-not-converge-in-cpu-mode-on-mac-os-x.
需要使用OpenBLAS集成编译numpy
首先安装openblas
$ brew install openblas
$ cd ~/github
$ git clone git://github.com/numpy/numpy.git numpy
$ cd numpy
$ cp site.cfg.example site.cfg
编辑site.cfg
[ALL]
library_dirs = /usr/local/opt/openblas/lib
include_dirs = /usr/local/opt/openblas/include
[atlas]
library_dirs = openblas
include_dirs = openblas
[openblas]
libraries = openblas
library_dirs = /usr/local/opt/openblas/lib
include_dirs = /usr/local/opt/openblas/include
runtime_library_dirs = /usr/local/opt/openblas/lib
编辑 ~/.bash_profile 添加
export LDFLAGS=-I/usr/local/opt/openblas/lib
export CPPFLAGS=-L/usr/local/opt/openblas/include
export PKG_CONFIG_PATH=/usr/local/opt/openblas/lib/pkgconfig
执行
python setup.py build && python setup.py install
出现错误提示
fatal error: 'endian.h' file not found
首先需要安装Command Line Tools (macOS 10.X) for XCode 10.X
xcode-select --install
MacOS 10.14之前版本,同时会自动生成"/usr/include"文件, 包括 "/usr/include/machine/endian.h".
MacOS 10.14起,文件不会自动升成,需要手动安装 /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
如果出现权限不足错误
Adding numpy 1.16.0.dev0+11a316e to easy-install.pth file
error: [Errno 13] Permission denied: '/usr/local/lib/python2.7/site-packages/easy-install.pth'
可以改用
sudo python setup.py build && sudo python setup.py install
网友评论