LoginSignup
4
3

More than 5 years have passed since last update.

Chainer が GPU で動いた日 CentOS 編 (CPUまで)

Last updated at Posted at 2015-10-14

感動した.実働にして約一週間は頑張っていたと思う.
結論として重要なことを先に書いておきます.

・Nvidiaのドライバーを最新の状態にする.
・pythonのライブラリ群をはじめにすべて入れておく.

以下詳細に述べていきたいと思います.

行ったこと

1.python2.7.4の導入
 
問題点
 python 2.6.6がインストールされてたので2.7.4の導入を行う必要があった.

解決法

$ su 
$ yum install zlib zlib-devel tk-devel tcl-devel sqlite-devel ncurses-devel gdbm-devel readline-devel bzip2-devel db4-devel openssl-devel
$ wget http://python.org/ftp/python/2.7.2/Python-2.7.4.tgz
$ tar zxvf Python-2.7.4.tgz 
$ cd Python-2.7.4
$ ./configure --with-threads --enable-shared
$ make
$ make install
$ ln -s /usr/local/lib/libpython2.7.so.1.0 /lib64/

一言
しっかりとシンボリックリンクを張ること
make install を行うこと
いろいろ入れているが分かっていないことが多い

補足
make altinstall を行うと既存のバージョンを変えずに入れることができるらしい

参考にしました
http://qiita.com/fuzzy31u/items/c35f2f4db5f3a48d86a7
http://a-records.info/2014/10/25/34/

2.python各種ライブラリの導入

問題点
Chainerを入れる際にいろいろライブラリが足りないことが分かったので入れてみました.
pipも入っていなかったのでそれも含めていれてみました.

解決法

$ su
$ yum install python-setuptools
$ wget http://peak.telecommunity.com/dist/ez_setup.py
$ /usr/local/bin/python ez_setup.py
$ easy_install pip
$ easy_install numpy
$ easy_install six
$ easy_install Mako
$ easy_install scipy
$ pip install scikit-learn

一言
easy_installを入れるときはez_setup.pyから入れましょう
/usr/bin/python はcentosもともとのpythonであるので
のちのち,pythonのバージョンで悩むでしょう

easy_install でも pip install でもよいですが
scikit-learnだけはpip install で入りました

参考にしました
http://www.tomoyan.net/dokuwiki/python/easy_install
http://inoccu.net/blog/2013/04/16/075618.html

3.chainerの導入

問題点
chainerを入れる

解決法

$ su
$ pip install chainer
$ git clone  https://github.com/pfnet/chainer
$ cd chainer/examples/mnist/
$ python train_mnist.py

一言
git clone https://github.com/pfnet/chainerには
サンプルファイルが入っています.
これで一応cpu版での実行はできるようになります.
次からはGPUを使った学習を解説していきたいと思います.

4
3
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
4
3