1
0
mirror of https://github.com/gryf/coach.git synced 2025-12-17 19:20:19 +01:00

create per environment Dockerfiles. (#70)

* create per environment Dockerfiles.

Adjust CI setup to better parallelize runs.
Fix a couple of issues in golden and trace tests.
Update a few of the docs.

* bugfix in mmc agent.

Also install kubectl for CI, update badge branch.

* remove integration test parallelism.
This commit is contained in:
Scott Leishman
2018-11-14 07:40:22 -08:00
committed by GitHub
parent a849c17e46
commit 524f8436a2
20 changed files with 448 additions and 139 deletions

View File

@@ -1,16 +1,32 @@
FROM coach-base:master
FROM coach-base:master as builder
# prep some of the more common environments
# Gym (installed with coach)
# Mujoco
RUN mkdir -p ~/.mujoco \
&& wget https://www.roboti.us/download/mjpro150_linux.zip -O mujoco.zip \
&& unzip mujoco.zip -d ~/.mujoco \
&& rm mujoco.zip
ARG MUJOCO_KEY
ENV MUJOCO_KEY=$MUJOCO_KEY
ENV LD_LIBRARY_PATH /root/.mujoco/mjpro150/bin:$LD_LIBRARY_PATH
RUN echo $MUJOCO_KEY | base64 --decode > /root/.mujoco/mjkey.txt
RUN pip3 install mujoco_py
# Vizdoom
RUN pip3 install vizdoom
RUN mkdir /root/src
COPY setup.py /root/src/.
COPY requirements.txt /root/src/.
RUN pip3 install -r /root/src/requirements.txt
FROM coach-base:master
WORKDIR /root/src
COPY --from=builder /root/.mujoco /root/.mujoco
ENV LD_LIBRARY_PATH /root/.mujoco/mjpro150/bin:$LD_LIBRARY_PATH
COPY --from=builder /root/.cache /root/.cache
COPY setup.py /root/src/.
COPY requirements.txt /root/src/.
COPY README.md /root/src/.
WORKDIR /root/src
RUN pip3 install -e .[all]
# everything above here should be cached most of the time
RUN pip3 install mujoco_py vizdoom && pip3 install -e .[all] && rm -rf /root/.cache
COPY . /root/src
WORKDIR /root/src
RUN pip3 install -e .[all]
RUN chmod 777 /root/src/docker/docker_entrypoint.sh
ENTRYPOINT ["/root/src/docker/docker_entrypoint.sh"]

View File

@@ -1,16 +1,4 @@
FROM nvidia/cuda:9.0-cudnn7-devel-ubuntu16.04
# https://github.com/NVIDIA/nvidia-docker/issues/619
RUN rm /etc/apt/sources.list.d/cuda.list
RUN apt-get update && \
apt-get upgrade -y && \
apt-get clean autoclean && \
apt-get autoremove -y && apt-get update && \
apt-get install -y python-pip && \
apt-get clean autoclean && \
apt-get autoremove -y
RUN pip install pip --upgrade
WORKDIR /root
FROM nvidia/cuda:9.0-cudnn7-runtime-ubuntu16.04
################################
# Install apt-get Requirements #
@@ -45,19 +33,7 @@ RUN apt-get update && \
# Install Pip Requirements #
############################
RUN pip3 install --upgrade pip
RUN pip3 install pytest
RUN pip3 install pytest-xdist
# initial installation of coach, so that the docker build won't install everything from scratch
RUN pip3 install rl_coach>=0.10.0 && pip3 install gym[atari]==0.10.5 && \
pip3 install mujoco_py==1.50.1.56 && pip3 install vizdoom==1.1.6
RUN mkdir -p ~/.mujoco \
&& wget https://www.roboti.us/download/mjpro150_linux.zip -O mujoco.zip \
&& unzip mujoco.zip -d ~/.mujoco \
&& rm mujoco.zip
# COPY ./mjkey.txt /root/.mujoco/
ENV LD_LIBRARY_PATH /root/.mujoco/mjpro150/bin:$LD_LIBRARY_PATH
RUN pip3 install setuptools==39.1.0 && pip3 install pytest && pip3 install pytest-xdist
RUN curl -o /usr/local/bin/patchelf https://s3-us-west-2.amazonaws.com/openai-sci-artifacts/manual-builds/patchelf_0.9_amd64.elf \
&& chmod +x /usr/local/bin/patchelf

View File

@@ -1,26 +0,0 @@
FROM ubuntu:16.04
RUN apt-get update \
&& apt-get install -y \
python3-pip cmake zlib1g-dev python3-tk python-opencv \
libboost-all-dev \
libblas-dev liblapack-dev libatlas-base-dev gfortran \
libsdl-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev \
libsmpeg-dev libportmidi-dev libavformat-dev libswscale-dev \
dpkg-dev build-essential python3.5-dev libjpeg-dev libtiff-dev \
libsdl1.2-dev libnotify-dev freeglut3 freeglut3-dev libsm-dev \
libgtk2.0-dev libgtk-3-dev libwebkitgtk-dev libgtk-3-dev \
libwebkitgtk-3.0-dev libgstreamer-plugins-base1.0-dev \
libav-tools libsdl2-dev swig
RUN pip3 install --upgrade pip
COPY requirements.txt /coach/requirements.txt
WORKDIR /coach
RUN pip3 install -r requirements.txt
COPY . /coach
RUN pip3 install .

View File

@@ -0,0 +1,20 @@
FROM coach-base:master as builder
# prep vizdoom and any of its related requirements.
RUN pip3 install vizdoom
# add coach source starting with files that could trigger
# re-build if dependencies change.
RUN mkdir /root/src
COPY setup.py /root/src/.
COPY requirements.txt /root/src/.
RUN pip3 install -r /root/src/requirements.txt
FROM coach-base:master
WORKDIR /root/src
COPY --from=builder /root/.cache /root/.cache
COPY setup.py /root/src/.
COPY requirements.txt /root/src/.
COPY README.md /root/src/.
RUN pip3 install vizdoom && pip3 install -e .[all] && rm -rf /root/.cache
COPY . /root/src

View File

@@ -0,0 +1,20 @@
FROM coach-base:master as builder
# prep gym and any of its related requirements.
RUN pip3 install gym[atari,box2d,classic_control]==0.10.5
# add coach source starting with files that could trigger
# re-build if dependencies change.
RUN mkdir /root/src
COPY setup.py /root/src/.
COPY requirements.txt /root/src/.
RUN pip3 install -r /root/src/requirements.txt
FROM coach-base:master
WORKDIR /root/src
COPY --from=builder /root/.cache /root/.cache
COPY setup.py /root/src/.
COPY requirements.txt /root/src/.
COPY README.md /root/src/.
RUN pip3 install gym[atari,box2d,classic_control]==0.10.5 && pip3 install -e .[all] && rm -rf /root/.cache
COPY . /root/src

View File

@@ -0,0 +1,31 @@
FROM coach-base:master as builder
# prep mujoco and any of its related requirements.
# Mujoco
RUN mkdir -p ~/.mujoco \
&& wget https://www.roboti.us/download/mjpro150_linux.zip -O mujoco.zip \
&& unzip -n mujoco.zip -d ~/.mujoco \
&& rm mujoco.zip
ARG MUJOCO_KEY
ENV MUJOCO_KEY=$MUJOCO_KEY
ENV LD_LIBRARY_PATH /root/.mujoco/mjpro150/bin:$LD_LIBRARY_PATH
RUN echo $MUJOCO_KEY | base64 --decode > /root/.mujoco/mjkey.txt
RUN pip3 install mujoco_py
# add coach source starting with files that could trigger
# re-build if dependencies change.
RUN mkdir /root/src
COPY setup.py /root/src/.
COPY requirements.txt /root/src/.
RUN pip3 install -r /root/src/requirements.txt
FROM coach-base:master
WORKDIR /root/src
COPY --from=builder /root/.mujoco /root/.mujoco
ENV LD_LIBRARY_PATH /root/.mujoco/mjpro150/bin:$LD_LIBRARY_PATH
COPY --from=builder /root/.cache /root/.cache
COPY setup.py /root/src/.
COPY requirements.txt /root/src/.
COPY README.md /root/src/.
RUN pip3 install mujoco_py && pip3 install -e .[all] && rm -rf /root/.cache
COPY . /root/src

View File

@@ -1,8 +1,7 @@
# REGISTRY=nervana-dockrepo01.fm.intel.com:5001/
# REGISTRY=gcr.io/
REGISTRY=docker.io/
IMAGE=zdwiel/coach
# IMAGE=gcr.io/deep-greens/inference:v5
# REGISTRY=gcr.io
REGISTRY=docker.io
ORGANIZATION=nervana
IMAGE=coach
BUILD_ARGUMENTS=
RUN_ARGUMENTS=
@@ -15,15 +14,23 @@ ifdef https_proxy
BUILD_ARGUMENTS+=--build-arg https_proxy=$(https_proxy)
RUN_ARGUMENTS+=--env https_proxy=$(https_proxy)
endif
ifdef MUJOCO_KEY
BUILD_ARGUMENTS+=--build-arg MUJOCO_KEY=$(MUJOCO_KEY)
endif
RUN_ARGUMENTS+=--rm
RUN_ARGUMENTS+=--net host
RUN_ARGUMENTS+=-v /tmp/checkpoint:/checkpoint
UNIT_TESTS=python3 -m pytest rl_coach/tests -m unit_test
INTEGRATION_TESTS=python3 -m pytest rl_coach/tests -m integration_test -n auto --tb=short
GOLDEN_TESTS=python3 -m pytest rl_coach/tests -m golden_test -n auto
TRACE_TESTS=python3 rl_coach/tests/trace_tests.py -prl
INTEGRATION_TESTS=python3 -m pytest rl_coach/tests -m integration_test --tb=short
ifdef PRESETS
PRESETS := -p $(PRESETS)
else
PRESETS :=
endif
GOLDEN_TESTS=python3 rl_coach/tests/test_golden.py ${PRESETS}
TRACE_TESTS=python3 rl_coach/tests/trace_tests.py -prl ${PRESETS}
CONTEXT = $(realpath ..)
@@ -31,7 +38,10 @@ ifndef DOCKER
DOCKER = docker
endif
build:
build_base:
${DOCKER} build -f=Dockerfile.base -t=${IMAGE}-base:master ${BUILD_ARGUMENTS} ${CONTEXT}
build: build_base
${DOCKER} build -f=Dockerfile -t=${IMAGE} ${BUILD_ARGUMENTS} ${CONTEXT}
mkdir -p /tmp/checkpoint
rm -rf /tmp/checkpoint/*
@@ -40,13 +50,13 @@ shell: build
${DOCKER} run ${RUN_ARGUMENTS} -it ${IMAGE} /bin/bash
unit_tests: build
${DOCKER} run ${RUN_ARGUMENTS} -it ${IMAGE} ${UNIT_TESTS} -n 8
${DOCKER} run ${RUN_ARGUMENTS} -it ${IMAGE} ${UNIT_TESTS}
integration_tests: build
${DOCKER} run ${RUN_ARGUMENTS} -it ${IMAGE} ${INTEGRATION_TESTS}
golden_tests: build
${DOCKER} run ${RUN_ARGUMENTS} -it ${IMAGE} ${GOLDEN_TESTS}
${DOCKER} run ${RUN_ARGUMENTS} -it ${IMAGE} ${GOLDEN_TESTS} ${PRESETS}
trace_tests: build
${DOCKER} run ${RUN_ARGUMENTS} -it ${IMAGE} ${TRACE_TESTS}
@@ -61,7 +71,7 @@ run_rollout_worker: build
${DOCKER} run ${RUN_ARGUMENTS} -it ${IMAGE} python3 rl_coach/rollout_worker.py --preset CartPole_DQN_distributed
bootstrap_kubernetes: build push
kubectl run -i --tty --attach --image=${REGISTRY}${IMAGE} --restart=Never distributed-coach -- python3 rl_coach/orchestrators/start_training.py --preset CartPole_DQN_distributed --image ${IMAGE} -ns 10.63.249.182 -np /
kubectl run -i --tty --attach --image=${REGISTRY}/${IMAGE} --restart=Never distributed-coach -- python3 rl_coach/orchestrators/start_training.py --preset CartPole_DQN_distributed --image ${IMAGE} -ns 10.63.249.182 -np /
stop_kubernetes:
kubectl delete service --ignore-not-found redis-service
@@ -75,8 +85,8 @@ kubernetes: stop_kubernetes
python3 ${CONTEXT}/rl_coach/orchestrators/start_training.py --preset CartPole_DQN_distributed --image ${IMAGE} -ns 10.63.249.182 -np /
push: build
${DOCKER} tag ${IMAGE} ${REGISTRY}${IMAGE}
${DOCKER} push ${REGISTRY}${IMAGE}
${DOCKER} tag ${IMAGE} ${REGISTRY}/${ORGANIZATION}/${IMAGE}
${DOCKER} push ${REGISTRY}/${ORGANIZATION}/${IMAGE}
unit_tests_without_docker:
cd .. && ${UNIT_TESTS}

27
docker/README.md Normal file
View File

@@ -0,0 +1,27 @@
# Container Images
In this directory we've put together several different Dockerfile's that can be used to build
containers that have coach and other environments/dependencies installed. How to build these
and what each contains is defined below:
## default `Dockerfile`
* `make build` to create the image
* will create a basic Coach installation along with Gym (atari), Mujoco, and Vizdoom environments.
* useful for running unit/integration tests `make unit_tests` to run these in the container
* `make shell` will launch this container locally, and provide a bash shell prompt.
* includes GPU support (derives from `Dockerfile.base` which is a CUDA ubuntu 16.04 derived image)
## `Dockerfile.mujoco_environment`
* `docker build --build-arg MUJOCO_KEY=${MUJOCO_KEY} -f docker/Dockerfile.mujoco_environment .`
from the parent dir to create the image
* contains mujoco environment and Coach.
* you need to supply your own license key (base64 encrypted) as an environment variable `MUJOCO_KEY`
to ensure you get the complete Mujoco environment
## `Dockerfile.gym_environment`
* `docker build -f docker/Dockerfile.gym_environment .` from the parent dir to create the image
* contains OpenAI Gym environment (and all extras) and Coach.
## `Dockerfile.doom_environment`
* `docker build -f docker/Dockerfile.doom_environment .` from the parent dir to create the image
* contains vizdoom environment and Coach.

View File

@@ -1,19 +0,0 @@
#!/bin/sh
set -e
# # download mjpro150
# mkdir /root/.mujoco
# cd /root/.mujoco
# wget https://www.roboti.us/download/mjpro150_linux.zip
# unzip mjpro150_linux.zip
# copy the mujoco license key into the container
# echo $MUJOCO_KEY | base64 --decode > /root/.mujoco/mjkey.txt
# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/root/.mujoco/mjpro150/bin
# git clone https://github.com/deepmind/dm_control.git
# pip3 install ./dm_control
export VIZDOOM_ROOT=`pip show vizdoom 2>/dev/null | awk '/Location/{print $2}'`/vizdoom
bash -c "$@"