LoginSignup
11
9

More than 5 years have passed since last update.

買ったばかりのMacにchainerをインストールするまでの流れ

Last updated at Posted at 2016-11-08

はじめに

2年ほど使っていたMacbook Airが以下のように突然使えなくなった。
http://qiita.com/masataka46/items/62c1cc4ca75313bc72d7
データはなんとか移行できたが、諸々のアプリはインストールし直す必要がある。

ubuntuでないので、私のこの記事
http://qiita.com/masataka46/items/94417a5974dba810e7b8
はそのままでは使えない。そこで以下のサイトを参考にした。
http://pip-install-deeplearning.hatenadiary.jp/entry/2015/12/29/144222
http://hellkite.hatenablog.com/entry/python_chainer_install_on_mac

chainerをインストールする際に仮想環境にインストールするか、直にインストールするかは重要だが、今回は直にインストールする。

環境

Macbook Pro Early 2015
CPU 2.7GHz intel Core i5
memory 8GB
Graphics Intel Iris Graphics 6100
OS X EL Capitan
python2.7.10
インストール済みのソフト:Xcodeなど

全体の流れ

以下の手順で進める。
1. pipをインストールする
2. pip経由でnumpyとsixをインストールする
3. pip経由でprotocol buffersをインストールする
4. pip経由でpillow、h5pyをインストールする
5. chainerをインストールする

pipをインストールする

pipでchainerをインストールするので、まずそのpipをインストールする。

sudo easy_install pip

pip経由でnumpyとsixをインストールする

chainerのホームページ内Install Guideに従ってdependenciesを入れていく。
http://docs.chainer.org/en/stable/install.html
主なものは以下。
- numpy
- six
- protocol buffers
- pillow
- h5py

今回はGPUを使わないのでCUDAとcuDNNは必要ない。下の3つは任意だが、後々のことを考えてインストールする。まずNumpy。

sudo pip install numpy

入ってた。次にsix。

sudo pip install six

入ってた。どこで入れたんだろうか?次にprotocol bufferをインストールする。

protocol buffersをインストールする

まずpipで入るか試す。

sudo pip install protobuf
.....
.....
DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
    Uninstalling six-1.4.1:
.....
.....
OSError: [Errno 1] Operation not permitted: '/tmp/pip-hysI2x-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'

なんかエーラが出た。sixのヴァージョンが古いと出ている。

調べてみると、Mac El Capitanにはデフォルトでsixの1.4.0とかがインストールされているが、これはpipなどではuninstallできない。ここで以下のサイトを参考にした。
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#on-macosx-

sudo easy_install --upgrade six 

1.10.0にヴァージョンアップした。こののちに再度

sudo pip install protobuf

としたらうまくいった。

pipでpillow、h5pyをインストールする

これは簡単。PILとか入れてると面倒らしい。

sudo pip install pillow

問題なくインストールされた。次にh5py。

sudo pip install h5py

これも問題なかった。

chainerをインストールする

pip経由でインストールする。

sudo pip install chainer
.....
.....
Installing collected packages: numpy, chainer
  Found existing installation: numpy 1.8.0rc1
    DEPRECATION: Uninstalling a distutils installed project (numpy) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
.....
.....
OSError: [Errno 1] Operation not permitted: '/tmp/pip-Tyykzf-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info'

などとエラーが出た。numpyのヴァージョンがどうのこうのと言っている。sixの場合と同様に備え付けのnumpyが古いのが問題だろうか。

実際、chainerの条件であるのはnumpy1.9とか1.10、1.11だが、備え付けは1.8となっている。sixと同様、easy_installでヴァージョンアップをしてみる。

sudo easy_install --upgrade numpy

warningが出まくったが、一応インストールされたみたい。再度chainerのインストールを試みる。

sudo pip install chainer
.....
.....
Successfully installed chainer-1.18.0

とうまくいった。しかし後々にnumpy絡みでエラーが出ないか心配。

11
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
9