Chainer+GPUはMacで動くのだろうか
El CapitanでChainer+GPUを動かそうとしたらRuntimeError: CUDA environment is not correctly set up
と出た。
$ python MLP.py --gpu 0
Traceback (most recent call last):
File "MLP.py", line 126, in <module>
x_batch = cuda.to_gpu(x_batch)
File "/usr/local/var/pyenv/versions/2.7.11/lib/python2.7/site-packages/chainer/cuda.py", line 192, in to_gpu
check_cuda_available()
File "/usr/local/var/pyenv/versions/2.7.11/lib/python2.7/site-packages/chainer/cuda.py", line 82, in check_cuda_available
raise RuntimeError(msg)
RuntimeError: CUDA environment is not correctly set up
(see https://github.com/pfnet/chainer#installation).dlopen(/usr/local/var/pyenv/versions/2.7.11/lib/python2.7/site-packages/cupy/core/core.so, 2): Library not loaded: @rpath/libcublas.7.5.dylib
Referenced from: /usr/local/var/pyenv/versions/2.7.11/lib/python2.7/site-packages/cupy/core/core.so
Reason: image not found
環境
- OS X 10.11.4 (El Capitan)
- NVIDIA GeForce GT 750M
- python 2.7.11
- Chainer 1.8.0
- CUDA 7.5
解決。動いた。
- パスを通してターミナル再起動
~/.bashrc
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib:$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=/usr/local/cuda/lib:$DYLD_LIBRARY_PATH
~~~
- SIP(Macのシステム保護機能)を無効化
一旦システムを終了させ、```Command + R + 電源ボタン```で起動後、ターミナルで
~~~
$ csrutil disable
~~~
を実行
- Chainerをインストールしなおす
~~~
$ pip uninstall chainer
$ CUDA_PATH=/usr/local/cuda pip install chainer --no-cache-dir
~~~
### 参考
- http://applech2.com/archives/46435268.html
- https://github.com/pfnet/chainer/issues/780