ディープラーニングのプログラムの肝であるchainerは日本製の深層学習フレームワークです。
Pythonのpipコマンドを使ってインストールするわけだが、このツールもインストールにハマリポイントがあったので備忘録としてメモしておきます。
(2017.1.22現在)
環境
MacBookPro13-inch
CPU core-i7 3.3GHz
Mem 16Gb
Python : ver 2.7.13
pip : 9.1
インストール手順
# Homebrewのアップデート
$ brew doctor
$ brew update
# pipのインストール
$ wget https://bootstrap.pypa.io/get-pip.py
$ python get-pip.py
$ pip -V
pip 9.0.1 from /usr/local/lib/python2.7/site-packages (python 2.7)
# モジュールインストール
$ pip install cython
$ pip install -U setuptools
$ pip install -U numpy
$ pip install chainer
※ここでエラーが発生
...
Installing collected packages: filelock, nose, six, protobuf, chainer
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/site-packages/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 784, in install
**kwargs
File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 377, in move_wheel_files
clobber(source, dest, False, fixer=fixer, filter=filter)
File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 316, in clobber
ensure_dir(destdir)
File "/usr/local/lib/python2.7/site-packages/pip/utils/__init__.py", line 83, in ensure_dir
os.makedirs(path)
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 150, in makedirs
makedirs(head, mode)
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/man'
filelock, nose, six, protobuf, chainer
これらのモジュールが事前に必要なようだ。
なので入れてあげる
$ pip install -U filelock
Requirement already up-to-date: filelock in /usr/local/lib/python2.7/site-packages
$ pip install -U nose
Requirement already up-to-date: nose in /usr/local/lib/python2.7/site-packages
$ pip install -U six
Collecting six
Using cached six-1.10.0-py2.py3-none-any.whl
Installing collected packages: six
Successfully installed six-1.10.0
$ pip install -U protobuf
Collecting protobuf
Using cached protobuf-3.1.0.post1-py2.py3-none-any.whl
Requirement already up-to-date: setuptools in /usr/local/lib/python2.7/site-packages (from protobuf)
Requirement already up-to-date: six>=1.9 in /usr/local/lib/python2.7/site-packages (from protobuf)
Installing collected packages: protobuf
Successfully installed protobuf-3.1.0.post1
そして再度chainerインストール
$ pip install -U chainer
Collecting chainer
Requirement already up-to-date: protobuf in /usr/local/lib/python2.7/site-packages (from chainer)
Requirement already up-to-date: nose in /usr/local/lib/python2.7/site-packages (from chainer)
Requirement already up-to-date: six>=1.9.0 in /usr/local/lib/python2.7/site-packages (from chainer)
Requirement already up-to-date: filelock in /usr/local/lib/python2.7/site-packages (from chainer)
Requirement already up-to-date: numpy>=1.9.0 in /usr/local/lib/python2.7/site-packages (from chainer)
Requirement already up-to-date: setuptools in /usr/local/lib/python2.7/site-packages (from protobuf->chainer)
Installing collected packages: chainer
Successfully installed chainer-1.20.0
無事に成功
確認
chainerのインストールされているか確認するには、pythonのコンソールで、次のコマンドを叩いてエラーがでないことを確認するといい。
import chainer
$ python
Python 2.7.13 (default, Jan 22 2017, 19:00:39)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
## インストールされていれば、下記のように何も返答がない
>>> import chainer
## もしインストールされていない場合は以下のようなエラーが出る。
>>> import chainer
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named chainer
関連リンク
Chainer
Chainerで始めるニューラルネットワーク
0 件のコメント:
コメントを投稿