Skip to content

Instantly share code, notes, and snippets.

@threecourse
Created December 18, 2019 07:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save threecourse/e3eb5cec09578246cc37c6915a07628b to your computer and use it in GitHub Desktop.
Save threecourse/e3eb5cec09578246cc37c6915a07628b to your computer and use it in GitHub Desktop.
GUIを使うためのdocker設定

dockerのビルド

docker build -t kag0 -f dockerfile-kag0 .
docker build -t rl-study-rlbook -f dockerfile-rl-study-rlbook . --build-arg USER=$USER --build-arg UID=$(id -u) --build-arg GID=$(id -g)

dockerの起動

export DOCKER_USER="--user=$(id -u):$(id -g) $(for i in $(id -G); do echo -n "--group-add "$i " "; done) --volume=/etc/group:/etc/group:ro --volume=/etc/passwd:/etc/passwd:ro --volume=/etc/shadow:/etc/shadow:ro --volume=/etc/sudoers.d:/etc/sudoers.d:ro"
export DOCKER_PORT="-p 8888:8888 -p 6006-6015:6006-6015"
export DOCKER_DISP="$DOCKER_USER $DOCKER_PORT --env=DISPLAY=$DISPLAY --volume=/tmp/.X11-unix:/tmp/.X11-unix:rw -e QT_X11_NO_MITSHM=1"

docker run -it --rm --runtime=nvidia $DOCKER_DISP -v $PWD:/tmp/work -w /tmp/work --name rl rl-study-rlbook

動作確認

git clone https://github.com/icoxfog417/baby-steps-of-rl-ja
cd baby-steps-of-rl-ja
python welcome.py
FROM nvidia/cuda:10.0-cudnn7-devel-ubuntu18.04
# reference: https://hub.docker.com/r/nejumi/tools_for_kaggle/dockerfile
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y software-properties-common && \
add-apt-repository ppa:git-core/ppa && \
apt-get update && \
apt-get install -y git build-essential cmake && \
git --version
RUN apt-get update && \
apt-get install -y \
curl \
wget \
bzip2 \
ca-certificates \
libglib2.0-0 \
libxext6 \
libsm6 \
libxrender1 \
git \
vim \
mercurial \
subversion \
cmake \
libboost-dev \
libboost-system-dev \
libboost-filesystem-dev \
gcc \
g++
# Add OpenCL ICD files for LightGBM
RUN mkdir -p /etc/OpenCL/vendors && \
echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd
##############################################################################
# TINI
##############################################################################
# Install tini
ENV TINI_VERSION v0.14.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini
##############################################################################
# anaconda python
##############################################################################
RUN apt-get update && \
apt-get install -y wget bzip2 ca-certificates && \
rm -rf /var/lib/apt/lists/*
RUN wget https://repo.continuum.io/archive/Anaconda3-2019.03-Linux-x86_64.sh && \
/bin/bash Anaconda3-2019.03-Linux-x86_64.sh -b -p /opt/conda && \
rm Anaconda3-2019.03-Linux-x86_64.sh
ENV PATH /opt/conda/bin:$PATH
RUN pip install --upgrade pip
RUN apt-get update && \
# Anaconda's build of gcc is way out of date; monkey-patch some linking problems that affect
# packages like xgboost and Shapely
rm /opt/conda/lib/libstdc++* && rm /opt/conda/lib/libgomp.* && \
ln -s /usr/lib/x86_64-linux-gnu/libgomp.so.1 /opt/conda/lib/libgomp.so.1 && \
ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /opt/conda/lib/libstdc++.so.6
FROM kag0
# home directory, sudo
ARG USER
ARG UID
ARG GID
RUN mkdir /home/$USER && chown $UID:$GID /home/$USER
RUN apt-get update && apt-get install -y sudo
# opengl
ENV NVIDIA_VISIBLE_DEVICES ${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES ${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics
RUN apt-get update && apt-get install -y --no-install-recommends mesa-utils x11-apps python-opengl && rm -rf /var/lib/apt/lists/*
# check: glxinfo, glxgears
# requirements
ADD requirements.txt .
RUN pip install -r requirements.txt
# check: python welcome.py
gym==0.14.0
# jupyter==1.0.0
# numpy==1.16.4
# pandas==0.24.2
# scipy==1.3.0
# scikit-learn==0.21.2
# matplotlib==3.1.0
tensorflow-gpu==1.14.0
-e git+https://github.com/ntasfi/PyGame-Learning-Environment.git#egg=ple
-e git+https://github.com/lusob/gym-ple.git#egg=gym-ple
# h5py==2.9.0
pygame==1.9.6
tqdm==4.32.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment