遇到這樣一個(gè)錯(cuò)誤
/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
執(zhí)行
python setup.py build && python setup.py install
出現(xiàn)錯(cuò)誤提示
fatal error: 'endian.h' file not found
首先需要安裝Command Line Tools (macOS 10.X) for XCode 10.X
xcode-select --install
MacOS 10.14之前版本立倍,同時(shí)會自動生成"/usr/include"文件, 包括 "/usr/include/machine/endian.h".
MacOS 10.14起身坐,文件不會自動升成燎猛,需要手動安裝 /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
如果出現(xiàn)權(quán)限不足錯(cuò)誤
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