2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Chainer をソースコードを弄りながらあれこれ試す時の環境

Posted at

ようやく時間が取れたのでchainerを弄っています。
僕はソースをいろいろ弄りながらじゃないと理解ができないのですが、環境汚染やソースに手を入れた後これをクリーンに戻すのが面倒だったりします。
これを楽にできる方法としての現時点での自分のベストプラクティスです。

Dockerを使う

pythonも2系と3系が入り混じっててあれなので、基本的にはDockerを使います。
この時に手元のコードとchainerのコードをあれこれするので以下のようにVolumesを使って試しています(emacsが使いたいし)

% cd ${MYPATH}
% git clone git@github.com:pfnet/chainer.git
% mkdir chainer-egg
% mkdir chainer-try
% docker pull python:3.5.1
% docker run -it \
  --entrypoint /bin/bash \
  --name chainer \
  -v ${MYPATH}/chainer-try:/tmp/chainer \
  -v ${MYPATH}/chainer:/usr/local/lib/python3.5/site-packages/chainer \
  -v ${MYPATH}/chainer-egg:/usr/local/lib/python3.5/site-packages/chainer-1.7.0-py3.5-linux-x86_64.egg \
  python:3.5.1
root@00b6a6aa3955:/ pushd /usr/local/lib/python3.5/site-packages/chainer
root@00b6a6aa3955:/usr/local/lib/python3.5/site-packages/chainer pip install numpy
root@00b6a6aa3955:/usr/local/lib/python3.5/site-packages/chainer python setup.py install
root@00b6a6aa3955:/usr/local/lib/python3.5/site-packages/chainer pushd /tmp/chainer
root@00b6a6aa3955:/tmp/chainer 

こうしておいてから、あとは

root@00b6a6aa3955:/tmp/chainer python -B sample.py

として適宜手元の方の ${MYPATH}/chainer-egg のコードにdebugなりprintなりを打ち込んであれこれ試しながらやると、破棄も簡単だし、pythonのバージョンのあれこれを懸念したりしないでできるのでとてもよいです。

おまけ

同様に tensorflow とか python、 ruby でもなんでもできます。

emacs 最高です

2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?