[ディープラーニングフレームワーク]
第1章〜第5章
特記事項無し。
第6章 ディープラーニングフレームワーク
chainerとnumpyのWarning
iMacでChainerとNumpyをimportすると
import numpy
import chainer
Warningが出る。numpyでOpenBLASのような他のBLASを使うことを推奨される。
/Users/xxx/Library/Python/3.8/lib/python/site-packages/chainer/_environment_check.py:33: 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
Tips and FAQs — Chainer 7.8.1 documentation
Please be aware that Mac OS X is not an officially supported OS.
warnings.warn('''\
公式ページの通りにOpenBLASを入れていく。
Tips and FAQs — Chainer 7.8.1 documentation
Use Homebrew to install OpenBLAS.
$ brew install openblas
Uninstall existing NumPy installation
$ pip uninstall numpy
You’ll to create a file called .numpy-site.cfg in your home (~/) directory with the following:
[openblas]
libraries = openblas
library_dirs = /usr/local/opt/openblas/lib
include_dirs = /usr/local/opt/openblas/include
Install NumPy from the source code
pip install --no-binary :all: numpy
Confirm NumPy has been installed with OpenBLAS by running this command:
$ python -c "import numpy; print(numpy.show_config())"
You should see the following information:
blas_mkl_info:
NOT AVAILABLE
blis_info:
NOT AVAILABLE
openblas_info:
libraries = ['openblas', 'openblas']
library_dirs = ['/usr/local/opt/openblas/lib']
language = c
define_macros = [('HAVE_CBLAS', None)]
runtime_library_dirs = ['/usr/local/opt/openblas/lib']
...
Once this is done, you should be able to import chainer without OpenBLAS errors.
結果
blas_mkl_info:
NOT AVAILABLE
blis_info:
NOT AVAILABLE
openblas_info:
libraries = ['openblas', 'openblas']
library_dirs = ['/usr/local/opt/openblas/lib']
language = c
define_macros = [('HAVE_CBLAS', None)]
blas_opt_info:
libraries = ['openblas', 'openblas']
library_dirs = ['/usr/local/opt/openblas/lib']
language = c
define_macros = [('HAVE_CBLAS', None)]
lapack_mkl_info:
NOT AVAILABLE
openblas_lapack_info:
libraries = ['openblas', 'openblas']
library_dirs = ['/usr/local/opt/openblas/lib']
language = c
define_macros = [('HAVE_CBLAS', None)]
lapack_opt_info:
libraries = ['openblas', 'openblas']
library_dirs = ['/usr/local/opt/openblas/lib']
language = c
define_macros = [('HAVE_CBLAS', None)]
これでimport chainerとimport numpyしてもエラーが出なくなった。
補足
.numpy-site.cfgは公式に書いてある通りの4行を記載したテキストファイルを作成して.numpy-site.cfgの名前でホームディレクトリに保存するだけ。「.」で始まるファイルは隠しファイル。command + shift + . で表示/非表示を切り替えられる。このファイルを消してしまうとまたエラーが出るようになるので注意。
コメント