Help us understand the problem. What is going on with this article?

dockerでdqnを動かす

More than 1 year has passed since last update.

下のDockerfileでopen ai gymを利用してdqnが動きます。
ポイントは"GNOME Desktop"をインストールするところとnvidia-docker runの時オプションを指定してホストのディスプレイに画面を表示させるようにしているところです。

これをするとjupyter qtconsoleをdockerから立ち上げることもできます。

要らないソフトは削ってくださいね。

Dockerfile
# --------------------
# hostos is centos7.3
# --------------------

FROM nvidia/cuda:8.0-cudnn5-devel-centos7

# -----
# user
# -----
#RUN useradd -m plenty
#RUN echo "plenty ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
WORKDIR /home/plenty
#USER plenty

# -------------------
# packages on centos
# -------------------
RUN yum -y install epel-release && yum clean all
RUN yum -y update && yum clean all
RUN yum -y install wget sudo vim python-pip && yum clean all
RUN pip install --upgrade pip

# ------
# pyenv
# ------
RUN yum -y install gcc gcc-c++ \
                   zlib-devel bzip2 bzip2-devel readline readline-devel \
                   sqlite sqlite-devel openssl openssl-devel git && yum clean all
RUN git clone git://github.com/yyuu/pyenv.git .pyenv
ENV HOME /home/plenty
ENV PYENV_ROOT $HOME/.pyenv
ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH

# ---------------
# juman++ server
# ---------------
RUN rpm -ivh http://packages.groonga.org/centos/groonga-release-1.1.0-1.noarch.rpm
RUN yum -y install mecab mecab-devel mecab-ipadic && yum clean all

RUN wget -O juman7.0.1.tar.bz2 "http://nlp.ist.i.kyoto-u.ac.jp/DLcounter/lime.cgi?down=http://nlp.ist.i.kyoto-u.ac.jp/nl-resource/juman/juman-7.01.tar.bz2&name=juman-7.01.tar.bz2"
RUN bzip2 -dc juman7.0.1.tar.bz2  | tar xvf -
RUN cd juman-7.01 && ./configure && make && make install

RUN yum -y install python-devel && yum clean all
RUN wget https://sourceforge.net/projects/boost/files/boost/1.62.0/boost_1_62_0.tar.gz
RUN tar xvzf boost_1_62_0.tar.gz
RUN cd boost_1_62_0 && sh bootstrap.sh && ./b2 install -j2

RUN yum -y install ruby 
RUN wget http://lotus.kuee.kyoto-u.ac.jp/nl-resource/jumanpp/jumanpp-1.01.tar.xz
RUN tar xJvf jumanpp-1.01.tar.xz
RUN cd jumanpp-1.01/ && ./configure && make && make install
RUN sed -i -e "s/\('command'=>'jumanpp',\)/\1 'host'=>'localhost',/g" ./jumanpp-1.01/script/server.rb
RUN echo 'ruby jumanpp-1.01/script/server.rb --cmd "jumanpp -B 5" &' >> .bashrc

ENV LIBRARY_PATH /usr/lib64:$LIBRARY_PATH 
RUN yum -y install make
RUN wget http://www.phontron.com/kytea/download/kytea-0.4.7.tar.gz
RUN tar -xvf kytea-0.4.7.tar.gz
RUN cd kytea-0.4.7 && ./configure && make && make install
RUN pip install kytea

# --------
# mongodb
# --------
RUN echo -e "[mongodb-org-3.4]\nname=MongoDB Repository\nbaseurl=https://repo.mongodb.org/yum/redhat/\$releasever/mongodb-org/3.4/x86_64/\ngpgcheck=1\nenabled=1\ngpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc" > /etc/yum.repos.d/mongodb-org-3.4.repo
RUN yum -y install mongodb-org
RUN mkdir -p data/db
RUN echo '/usr/bin/mongod --dbpath /home/plenty/data/db &' >> .bashrc

# ---------
# anaconda
# ---------
RUN yum -y install libX11-devel libXext-devel libXdmcp-devel
RUN pyenv install anaconda3-4.4.0
RUN pyenv global anaconda3-4.4.0
RUN pyenv rehash
RUN pip install --upgrade pip
RUN sed -i -e "s/backend      : Qt5Agg/#backend      : Qt5Agg/g" .pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages/matplotlib/mpl-data/matplotlibrc
RUN sed -i -e "s/#backend.qt4 : PyQt4/backend.qt4 : PyQt4/g" .pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages/matplotlib/mpl-data/matplotlibrc
RUN sed -i -e "s/backend      : Qt5Agg/#backend      : Qt5Agg/g" .pyenv/versions/anaconda3-4.4.0/pkgs/matplotlib-2.0.2-np112py36_0/lib/python3.6/site-packages/matplotlib/mpl-data/matplotlibrc
RUN sed -i -e "s/#backend.qt4 : PyQt4/backend.qt4 : PyQt4/g" .pyenv/versions/anaconda3-4.4.0/pkgs/matplotlib-2.0.2-np112py36_0/lib/python3.6/site-packages/matplotlib/mpl-data/matplotlibrc

# ------------------
# modules on python
# ------------------
RUN yum -y install libxml2-devel libffi-devel python-devel libxslt-devel
RUN pip install scrapy
RUN pip install chainer
RUN pip install seaborn
RUN pip install -U scikit-learn
RUN pip install -U pandas
RUN pip install pystan
RUN pip install pymongo
RUN pip install nimfa
RUN pip install keras
RUN pip install tensorflow-gpu
RUN pip install gensim
RUN pip install python-crfsuite
RUN pip install sklearn-crfsuite

RUN wget https://github.com/mongodb/mongo-c-driver/releases/download/1.5.3/mongo-c-driver-1.5.3.tar.gz
RUN tar xzf mongo-c-driver-1.5.3.tar.gz
RUN cd mongo-c-driver-1.5.3 && ./configure && make && make install
RUN yum -y install cyrus-sasl-devel
ENV LD_LIBRARY_PATH /usr/local/lib:$LD_LIBRARY_PATH
RUN pip install monary

# --------------
# gym
# --------------
RUN yum -y groupinstall "GNOME Desktop"
RUN yum -y install cmake
RUN pip install gym
RUN pip install keras-rl

# -----------------
# setting japanese
# -----------------
RUN yum -y reinstall glibc-common && yum clean all
RUN localedef -v -c -i ja_JP -f UTF-8 ja_JP.UTF-8; echo "";
ENV LANG ja_JP.UTF-8
RUN rm -f /etc/localtime
RUN ln -fs /usr/share/zoneinfo/Asia/Tokyo /etc/localtime

RUN pip install JapaneseTokenizer

# ------------------
# entry point
# ------------------
RUN echo 'export HOME=/share' >> .bashrc
RUN echo 'cd $HOME' >> .bashrc
ENTRYPOINT ["/bin/bash"]

よく使うdockerコマンドを整理しておきます。

コンテナの起動
sudo nvidia-docker run --privileged=true --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -it --name plenty -v ~/work/plenty:/share:rw plenty
コンテナの停止
sudo docker stop plenty
コンテナの再起動
sudo docker start plenty
コンテナに入る
sudo docker attach plenty
全てのコンテナの削除
sudo docker rm $(sudo docker ps -a | awk '{print $1}' | grep -v CONTAINER)
全てのイメージの削除
sudo docker rmi -f $(sudo docker images | awk '{print $3}' | grep -v IMAGE)
イメージの作成
sudo nvidia-docker build -t plenty .
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした