なんかツールのインストールだけで殆ど使いこなせていないのだが、TensorFlowの次にBash on WindowsにChainerをインストールしてみた。
といっても、インストール自体はpipで一発で実行可能だ。
masayuki@FIXEDESK:~$ pip install chainer Collecting chainer Downloading chainer-1.16.0.tar.gz (1.1MB) 100% |████████████████████████████████| 1.1MB 1.0MB/s Collecting filelock (from chainer) Downloading filelock-2.0.6.tar.gz Requirement already satisfied (use --upgrade to upgrade): nose in ./.pyenv/versions/anaconda3-4.1.1/lib/python3.5/site-packages (from chainer) Requirement already satisfied (use --upgrade to upgrade): numpy>=1.9.0 in ./.pyenv/versions/anaconda3-4.1.1/lib/python3.5/site-packages (from chainer) Requirement already satisfied (use --upgrade to upgrade): protobuf in ./.pyenv/versions/anaconda3-4.1.1/lib/python3.5/site-packages (from chainer) Requirement already satisfied (use --upgrade to upgrade): six>=1.9.0 in ./.pyenv/versions/anaconda3-4.1.1/lib/python3.5/site-packages (from chainer) Requirement already satisfied (use --upgrade to upgrade): setuptools in ./.pyenv/versions/anaconda3-4.1.1/lib/python3.5/site-packages/setuptools-23.0.0-py3.5.egg (from protobuf->chainer) Building wheels for collected packages: chainer, filelock Running setup.py bdist_wheel for chainer ... done Stored in directory: /home/masayuki/.cache/pip/wheels/66/41/b3/64e4fc7d00104fc20af6d704ba3aaece4890aa1d45d32b5b3b Running setup.py bdist_wheel for filelock ... done Stored in directory: /home/masayuki/.cache/pip/wheels/97/9b/c0/47c42b4f38b378a65671364fb62ae7822b68b13f8048221d07 Successfully built chainer filelock Installing collected packages: filelock, chainer Successfully installed chainer-1.16.0 filelock-2.0.6 masayuki@FIXEDESK:~$
さっそく、Chainerのサンプルプログラムをダウンロードし、実行してみよう。
masayuki@FIXEDESK:~/work$ git clone https://github.com/pfnet/chainer.git Cloning into 'chainer'... remote: Counting objects: 41306, done. remote: Compressing objects: 100% (65/65), done. remote: Total 41306 (delta 24), reused 0 (delta 0), pack-reused 41241 Receiving objects: 100% (41306/41306), 12.67 MiB | 2.53 MiB/s, done. Resolving deltas: 100% (29679/29679), done. Checking connectivity... done. masayuki@FIXEDESK:~/work$ cd chainer/examples/mnist/ masayuki@FIXEDESK:~/work/chainer/examples/mnist$ python train_mnist.py -g -1 GPU: -1 # unit: 1000 # Minibatch-size: 100 # epoch: 20 OMP: Error #100: Fatal system error detected. OMP: System error #22: Invalid argument 中止 (コアダンプ)
おや、エラーを吐いて終了してしまった。これはBash on Windows固有のエラーかな?
この、OMP: Error #100: Fatal system error detected.
を回避するためには、環境変数の設定が必要そうだった。参考にしたのは、githubの以下のディスカッションだ。
KMP_AFFINITY=disabled
という環境変数を設定する必要がありそうだ。設定して実行してみよう。
masayuki@FIXEDESK:~/work/chainer/examples/mnist$ KMP_AFFINITY=disabled python train_mnist.py -g -1 GPU: -1 # unit: 1000 # Minibatch-size: 100 # epoch: 20 epoch main/loss validation/main/loss main/accuracy validation/main/accuracy 1 0.191856 0.104489 0.941767 0.9672 2 0.0716813 0.0846484 0.977583 0.9732 3 0.0481666 0.0801073 0.98455 0.9777 4 0.0353043 0.0716036 0.9885 0.978 5 0.0287204 0.0856727 0.990267 0.9785 6 0.0237751 0.0714374 0.991783 0.9812 7 0.0206211 0.0803223 0.9933 0.9806 8 0.0207687 0.0877314 0.9934 0.9784 9 0.0170502 0.0871984 0.99455 0.9804 10 0.0140119 0.0920289 0.995417 0.9815 11 0.0174262 0.0906213 0.994433 0.9798 12 0.0129915 0.10583 0.995817 0.9782 13 0.0117543 0.0844722 0.996317 0.9838 14 0.00811143 0.0858693 0.99765 0.9833 15 0.0111486 0.0911458 0.996733 0.9832 16 0.00956446 0.093201 0.99695 0.9836 17 0.0161112 0.0958432 0.995533 0.9829 18 0.0075644 0.0988045 0.9978 0.9827 19 0.0108992 0.105838 0.997283 0.9828 20 0.00950929 0.0935197 0.997183 0.9832
ちゃんと動作した!ところで、KMP_AFFINITY
というのは何なんだろう?
スレッド・アフィニティー・インターフェイス (Linux* および Windows*)
どうやらマルチスレッドに関するオプションのようだ。とりあえずこれはシングルスレッドで動作させる、というオプションだろうか?