mirror of
https://github.com/gryf/coach.git
synced 2025-12-17 19:20:19 +01:00
introduce dockerfiles. (#169)
* introduce dockerfiles. * ensure golden tests are run not just collected. * Skip CI download of dockerfiles. * add StarCraft environment and tests. * add minimaps starcraft validation parameters. * Add functional test running (from Ayoob) * pin mujoco_py version to a 1.5 compatible release. * fix config syntax issue. * pin remaining mujoco_py install calls. * Relax pin of gym version in gym Dockerfile. * update makefile based on functional test filtering.
This commit is contained in:
@@ -30,11 +30,6 @@ aliases:
|
|||||||
aws eks update-kubeconfig --name coach-aws-cicd
|
aws eks update-kubeconfig --name coach-aws-cicd
|
||||||
sudo curl -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
|
sudo curl -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
|
||||||
sudo chmod a+x /usr/local/bin/kubectl
|
sudo chmod a+x /usr/local/bin/kubectl
|
||||||
- &docker_prep
|
|
||||||
run:
|
|
||||||
name: Prepare dockerfiles
|
|
||||||
command: |
|
|
||||||
aws s3 cp --recursive s3://coach-ci-dockerfiles docker
|
|
||||||
|
|
||||||
version: 2
|
version: 2
|
||||||
jobs:
|
jobs:
|
||||||
@@ -45,7 +40,6 @@ jobs:
|
|||||||
- *remote_docker
|
- *remote_docker
|
||||||
- *restore_cache
|
- *restore_cache
|
||||||
- *aws_prep
|
- *aws_prep
|
||||||
- *docker_prep
|
|
||||||
- run:
|
- run:
|
||||||
name: Build and push base and main container
|
name: Build and push base and main container
|
||||||
command: |
|
command: |
|
||||||
@@ -76,7 +70,6 @@ jobs:
|
|||||||
- *remote_docker
|
- *remote_docker
|
||||||
- *restore_cache
|
- *restore_cache
|
||||||
- *aws_prep
|
- *aws_prep
|
||||||
- *docker_prep
|
|
||||||
- run:
|
- run:
|
||||||
name: Build and push gym environment container
|
name: Build and push gym environment container
|
||||||
command: |
|
command: |
|
||||||
@@ -95,7 +88,6 @@ jobs:
|
|||||||
- *remote_docker
|
- *remote_docker
|
||||||
- *restore_cache
|
- *restore_cache
|
||||||
- *aws_prep
|
- *aws_prep
|
||||||
- *docker_prep
|
|
||||||
- run:
|
- run:
|
||||||
name: Build and push vizdoom environment container
|
name: Build and push vizdoom environment container
|
||||||
command: |
|
command: |
|
||||||
@@ -114,7 +106,6 @@ jobs:
|
|||||||
- *remote_docker
|
- *remote_docker
|
||||||
- *restore_cache
|
- *restore_cache
|
||||||
- *aws_prep
|
- *aws_prep
|
||||||
- *docker_prep
|
|
||||||
- run:
|
- run:
|
||||||
name: Build and push mujoco environment container
|
name: Build and push mujoco environment container
|
||||||
command: |
|
command: |
|
||||||
@@ -126,6 +117,24 @@ jobs:
|
|||||||
docker push ${REGISTRY}/coach-mujoco_environment:${TAG}
|
docker push ${REGISTRY}/coach-mujoco_environment:${TAG}
|
||||||
no_output_timeout: 10m
|
no_output_timeout: 10m
|
||||||
|
|
||||||
|
build_starcraft_env:
|
||||||
|
<<: *executor_prep
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- *remote_docker
|
||||||
|
- *restore_cache
|
||||||
|
- *aws_prep
|
||||||
|
- run:
|
||||||
|
name: Build and push starcraft environment container
|
||||||
|
command: |
|
||||||
|
REGISTRY=316971102342.dkr.ecr.us-west-2.amazonaws.com
|
||||||
|
TAG=$(git describe --tags --always --dirty)
|
||||||
|
docker pull ${REGISTRY}/coach-base:${MASTER_BRANCH}
|
||||||
|
docker tag ${REGISTRY}/coach-base:${MASTER_BRANCH} coach-base:master
|
||||||
|
docker build --cache-from ${REGISTRY}/coach-base:${MASTER_BRANCH} -t ${REGISTRY}/coach-starcraft_environment:${TAG} -f docker/Dockerfile.starcraft_environment .
|
||||||
|
docker push ${REGISTRY}/coach-starcraft_environment:${TAG}
|
||||||
|
no_output_timeout: 10m
|
||||||
|
|
||||||
unit_tests:
|
unit_tests:
|
||||||
<<: *executor_prep
|
<<: *executor_prep
|
||||||
steps:
|
steps:
|
||||||
@@ -133,7 +142,6 @@ jobs:
|
|||||||
- *remote_docker
|
- *remote_docker
|
||||||
- *restore_cache
|
- *restore_cache
|
||||||
- *aws_prep
|
- *aws_prep
|
||||||
- *docker_prep
|
|
||||||
- run:
|
- run:
|
||||||
name: run unit tests
|
name: run unit tests
|
||||||
command: |
|
command: |
|
||||||
@@ -152,7 +160,6 @@ jobs:
|
|||||||
- *remote_docker
|
- *remote_docker
|
||||||
- *restore_cache
|
- *restore_cache
|
||||||
- *aws_prep
|
- *aws_prep
|
||||||
- *docker_prep
|
|
||||||
- run:
|
- run:
|
||||||
name: run integration tests
|
name: run integration tests
|
||||||
command: |
|
command: |
|
||||||
@@ -172,7 +179,6 @@ jobs:
|
|||||||
- *remote_docker
|
- *remote_docker
|
||||||
- *restore_cache
|
- *restore_cache
|
||||||
- *aws_prep
|
- *aws_prep
|
||||||
- *docker_prep
|
|
||||||
- run:
|
- run:
|
||||||
name: run functional tests
|
name: run functional tests
|
||||||
command: |
|
command: |
|
||||||
@@ -193,7 +199,6 @@ jobs:
|
|||||||
- *remote_docker
|
- *remote_docker
|
||||||
- *restore_cache
|
- *restore_cache
|
||||||
- *aws_prep
|
- *aws_prep
|
||||||
- *docker_prep
|
|
||||||
- run:
|
- run:
|
||||||
name: run gym related golden tests
|
name: run gym related golden tests
|
||||||
command: |
|
command: |
|
||||||
@@ -214,7 +219,6 @@ jobs:
|
|||||||
- *remote_docker
|
- *remote_docker
|
||||||
- *restore_cache
|
- *restore_cache
|
||||||
- *aws_prep
|
- *aws_prep
|
||||||
- *docker_prep
|
|
||||||
- run:
|
- run:
|
||||||
name: run doom related golden tests
|
name: run doom related golden tests
|
||||||
command: |
|
command: |
|
||||||
@@ -235,7 +239,6 @@ jobs:
|
|||||||
- *remote_docker
|
- *remote_docker
|
||||||
- *restore_cache
|
- *restore_cache
|
||||||
- *aws_prep
|
- *aws_prep
|
||||||
- *docker_prep
|
|
||||||
- run:
|
- run:
|
||||||
name: run mujoco related golden tests
|
name: run mujoco related golden tests
|
||||||
command: |
|
command: |
|
||||||
@@ -249,6 +252,26 @@ jobs:
|
|||||||
kubectl delete ns golden-test-mujoco-${CIRCLE_BUILD_NUM} || true
|
kubectl delete ns golden-test-mujoco-${CIRCLE_BUILD_NUM} || true
|
||||||
when: always
|
when: always
|
||||||
|
|
||||||
|
golden_test_starcraft:
|
||||||
|
<<: *executor_prep
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- *remote_docker
|
||||||
|
- *restore_cache
|
||||||
|
- *aws_prep
|
||||||
|
- run:
|
||||||
|
name: run starcraft related golden tests
|
||||||
|
command: |
|
||||||
|
export GOLDEN_PRESETS='Starcraft'
|
||||||
|
python3 rl_coach/tests/test_eks.py -c coach-test -bn ${CIRCLE_BUILD_NUM} -tn golden-test-starcraft -tc "export GOLDEN_PRESETS=${GOLDEN_PRESETS} && make golden_tests_without_docker" -i 316971102342.dkr.ecr.us-west-2.amazonaws.com/coach-starcraft_environment:$(git describe --tags --always --dirty) -cpu 2048 -mem 4096
|
||||||
|
no_output_timeout: 30m
|
||||||
|
- run:
|
||||||
|
name: cleanup
|
||||||
|
command: |
|
||||||
|
kubectl delete --all pods --namespace=golden-test-starcraft-${CIRCLE_BUILD_NUM} || true
|
||||||
|
kubectl delete ns golden-test-starcraft-${CIRCLE_BUILD_NUM} || true
|
||||||
|
when: always
|
||||||
|
|
||||||
functional_test_mujoco:
|
functional_test_mujoco:
|
||||||
<<: *executor_prep
|
<<: *executor_prep
|
||||||
steps:
|
steps:
|
||||||
@@ -256,7 +279,6 @@ jobs:
|
|||||||
- *remote_docker
|
- *remote_docker
|
||||||
- *restore_cache
|
- *restore_cache
|
||||||
- *aws_prep
|
- *aws_prep
|
||||||
- *docker_prep
|
|
||||||
- run:
|
- run:
|
||||||
name: run mujoco related functional tests
|
name: run mujoco related functional tests
|
||||||
command: |
|
command: |
|
||||||
@@ -277,7 +299,6 @@ jobs:
|
|||||||
- *remote_docker
|
- *remote_docker
|
||||||
- *restore_cache
|
- *restore_cache
|
||||||
- *aws_prep
|
- *aws_prep
|
||||||
- *docker_prep
|
|
||||||
- run:
|
- run:
|
||||||
name: run doom related functional tests
|
name: run doom related functional tests
|
||||||
command: |
|
command: |
|
||||||
@@ -298,7 +319,6 @@ jobs:
|
|||||||
- *remote_docker
|
- *remote_docker
|
||||||
- *restore_cache
|
- *restore_cache
|
||||||
- *aws_prep
|
- *aws_prep
|
||||||
- *docker_prep
|
|
||||||
- run:
|
- run:
|
||||||
name: run Starcraft related functional tests
|
name: run Starcraft related functional tests
|
||||||
command: |
|
command: |
|
||||||
@@ -319,7 +339,6 @@ jobs:
|
|||||||
- *remote_docker
|
- *remote_docker
|
||||||
- *restore_cache
|
- *restore_cache
|
||||||
- *aws_prep
|
- *aws_prep
|
||||||
- *docker_prep
|
|
||||||
- run:
|
- run:
|
||||||
name: run gym related trace tests
|
name: run gym related trace tests
|
||||||
command: |
|
command: |
|
||||||
@@ -340,7 +359,6 @@ jobs:
|
|||||||
- *remote_docker
|
- *remote_docker
|
||||||
- *restore_cache
|
- *restore_cache
|
||||||
- *aws_prep
|
- *aws_prep
|
||||||
- *docker_prep
|
|
||||||
- run:
|
- run:
|
||||||
name: run doom related trace tests
|
name: run doom related trace tests
|
||||||
command: |
|
command: |
|
||||||
@@ -361,7 +379,6 @@ jobs:
|
|||||||
- *remote_docker
|
- *remote_docker
|
||||||
- *restore_cache
|
- *restore_cache
|
||||||
- *aws_prep
|
- *aws_prep
|
||||||
- *docker_prep
|
|
||||||
- run:
|
- run:
|
||||||
name: run mujoco related trace tests
|
name: run mujoco related trace tests
|
||||||
command: |
|
command: |
|
||||||
@@ -375,6 +392,26 @@ jobs:
|
|||||||
kubectl delete ns trace-test-mujoco-${CIRCLE_BUILD_NUM} || true
|
kubectl delete ns trace-test-mujoco-${CIRCLE_BUILD_NUM} || true
|
||||||
when: always
|
when: always
|
||||||
|
|
||||||
|
trace_test_starcraft:
|
||||||
|
<<: *executor_prep
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- *remote_docker
|
||||||
|
- *restore_cache
|
||||||
|
- *aws_prep
|
||||||
|
- run:
|
||||||
|
name: run starcraft related trace tests
|
||||||
|
command: |
|
||||||
|
export TRACE_PRESETS='Starcraft_CollectMinerals_Arc,Starcraft_CollectMinerals_Deuling_DDQN'
|
||||||
|
python3 rl_coach/tests/test_eks.py -c coach-test -bn ${CIRCLE_BUILD_NUM} -tn trace-test-starcraft -tc "export TRACE_PRESETS=${TRACE_PRESETS} && make trace_tests_without_docker" -i 316971102342.dkr.ecr.us-west-2.amazonaws.com/coach-starcraft_environment:$(git describe --tags --always --dirty) -cpu 2048 -mem 4096
|
||||||
|
no_output_timeout: 30m
|
||||||
|
- run:
|
||||||
|
name: cleanup
|
||||||
|
command: |
|
||||||
|
kubectl delete --all pods --namespace=trace-test-starcraft-${CIRCLE_BUILD_NUM} || true
|
||||||
|
kubectl delete ns trace-test-starcraft-${CIRCLE_BUILD_NUM} || true
|
||||||
|
when: always
|
||||||
|
|
||||||
multinode_test:
|
multinode_test:
|
||||||
<<: *executor_prep
|
<<: *executor_prep
|
||||||
steps:
|
steps:
|
||||||
@@ -382,7 +419,6 @@ jobs:
|
|||||||
- *remote_docker
|
- *remote_docker
|
||||||
- *restore_cache
|
- *restore_cache
|
||||||
- *aws_prep
|
- *aws_prep
|
||||||
- *docker_prep
|
|
||||||
- run:
|
- run:
|
||||||
name: run multinode test
|
name: run multinode test
|
||||||
command: |
|
command: |
|
||||||
@@ -417,7 +453,6 @@ jobs:
|
|||||||
- *remote_docker
|
- *remote_docker
|
||||||
- *restore_cache
|
- *restore_cache
|
||||||
- *aws_prep
|
- *aws_prep
|
||||||
- *docker_prep
|
|
||||||
- run:
|
- run:
|
||||||
name: Tag and push updated base and main container
|
name: Tag and push updated base and main container
|
||||||
command: |
|
command: |
|
||||||
@@ -468,9 +503,9 @@ workflows:
|
|||||||
- build_mujoco_env:
|
- build_mujoco_env:
|
||||||
requires:
|
requires:
|
||||||
- e2e_approval
|
- e2e_approval
|
||||||
# - build_starcraft_env:
|
- build_starcraft_env:
|
||||||
# requires:
|
requires:
|
||||||
# - e2e_approval
|
- e2e_approval
|
||||||
- gym_approval:
|
- gym_approval:
|
||||||
type: approval
|
type: approval
|
||||||
requires:
|
requires:
|
||||||
@@ -483,6 +518,10 @@ workflows:
|
|||||||
type: approval
|
type: approval
|
||||||
requires:
|
requires:
|
||||||
- golden_test_mujoco
|
- golden_test_mujoco
|
||||||
|
- starcraft_approval:
|
||||||
|
type: approval
|
||||||
|
requires:
|
||||||
|
- golden_test_starcraft
|
||||||
- golden_test_gym:
|
- golden_test_gym:
|
||||||
requires:
|
requires:
|
||||||
- build_gym_env
|
- build_gym_env
|
||||||
@@ -492,6 +531,9 @@ workflows:
|
|||||||
- golden_test_mujoco:
|
- golden_test_mujoco:
|
||||||
requires:
|
requires:
|
||||||
- build_mujoco_env
|
- build_mujoco_env
|
||||||
|
- golden_test_starcraft:
|
||||||
|
requires:
|
||||||
|
- build_starcraft_env
|
||||||
- trace_test_gym:
|
- trace_test_gym:
|
||||||
requires:
|
requires:
|
||||||
- gym_approval
|
- gym_approval
|
||||||
@@ -501,6 +543,9 @@ workflows:
|
|||||||
- trace_test_mujoco:
|
- trace_test_mujoco:
|
||||||
requires:
|
requires:
|
||||||
- mujoco_approval
|
- mujoco_approval
|
||||||
|
- trace_test_starcraft:
|
||||||
|
requires:
|
||||||
|
- starcraft_approval
|
||||||
- container_deploy:
|
- container_deploy:
|
||||||
requires:
|
requires:
|
||||||
- unit_tests
|
- unit_tests
|
||||||
@@ -523,15 +568,18 @@ workflows:
|
|||||||
- build_gym_env
|
- build_gym_env
|
||||||
- build_doom_env
|
- build_doom_env
|
||||||
- build_mujoco_env
|
- build_mujoco_env
|
||||||
# - functional_test_starcraft:
|
- build_starcraft_env
|
||||||
# requires:
|
|
||||||
# - build_starcraft_env
|
|
||||||
- functional_test_doom:
|
- functional_test_doom:
|
||||||
requires:
|
requires:
|
||||||
- build_doom_env
|
- build_doom_env
|
||||||
- functional_test_mujoco:
|
- functional_test_mujoco:
|
||||||
requires:
|
requires:
|
||||||
- build_mujoco_env
|
- build_mujoco_env
|
||||||
|
- functional_test_doom
|
||||||
|
- functional_test_starcraft:
|
||||||
|
requires:
|
||||||
|
- build_starcraft_env
|
||||||
|
- functional_test_mujoco
|
||||||
- golden_test_gym:
|
- golden_test_gym:
|
||||||
requires:
|
requires:
|
||||||
- build_gym_env
|
- build_gym_env
|
||||||
@@ -543,12 +591,22 @@ workflows:
|
|||||||
requires:
|
requires:
|
||||||
- build_mujoco_env
|
- build_mujoco_env
|
||||||
- golden_test_doom
|
- golden_test_doom
|
||||||
|
- golden_test_starcraft:
|
||||||
|
requires:
|
||||||
|
- build_starcraft_env
|
||||||
|
- golden_test_mujoco
|
||||||
# - trace_test_gym:
|
# - trace_test_gym:
|
||||||
# requires:
|
# requires:
|
||||||
# - build_gym_env
|
# - build_gym_env
|
||||||
# - trace_test_doom:
|
# - trace_test_doom:
|
||||||
# requires:
|
# requires:
|
||||||
# - build_doom_env
|
# - build_doom_env
|
||||||
|
# - trace_test_gym
|
||||||
# - trace_test_mujoco:
|
# - trace_test_mujoco:
|
||||||
# requires:
|
# requires:
|
||||||
# - build_mujoco_env
|
# - build_mujoco_env
|
||||||
|
# - trace_test_doom
|
||||||
|
# - trace_test_starcraft:
|
||||||
|
# requires:
|
||||||
|
# - build_mujoco_env
|
||||||
|
# - trace_test_mujoco
|
||||||
|
|||||||
33
docker/Dockerfile
Normal file
33
docker/Dockerfile
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
FROM coach-base:master as builder
|
||||||
|
|
||||||
|
# prep some of the more common environments
|
||||||
|
# Gym (installed with coach)
|
||||||
|
Run pip3 install gym[atari] box2d
|
||||||
|
# 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==1.50.1.68
|
||||||
|
# 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/.
|
||||||
|
RUN pip3 install gym[atari] box2d mujoco_py==1.50.1.68 vizdoom && pip3 install -e .[all] && rm -rf /root/.cache
|
||||||
|
COPY . /root/src
|
||||||
39
docker/Dockerfile.base
Normal file
39
docker/Dockerfile.base
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
FROM nvidia/cuda:9.0-cudnn7-runtime-ubuntu16.04
|
||||||
|
|
||||||
|
################################
|
||||||
|
# Install apt-get Requirements #
|
||||||
|
################################
|
||||||
|
|
||||||
|
# General
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y python3-pip cmake zlib1g-dev python3-tk python-opencv \
|
||||||
|
# Boost libraries
|
||||||
|
libboost-all-dev \
|
||||||
|
# Scipy requirements
|
||||||
|
libblas-dev liblapack-dev libatlas-base-dev gfortran \
|
||||||
|
# Pygame requirements
|
||||||
|
libsdl-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev \
|
||||||
|
libsmpeg-dev libportmidi-dev libavformat-dev libswscale-dev \
|
||||||
|
# Dashboard
|
||||||
|
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 \
|
||||||
|
# Gym
|
||||||
|
libav-tools libsdl2-dev swig cmake \
|
||||||
|
# Mujoco_py
|
||||||
|
curl libgl1-mesa-dev libgl1-mesa-glx libglew-dev libosmesa6-dev software-properties-common \
|
||||||
|
# ViZDoom
|
||||||
|
build-essential zlib1g-dev libsdl2-dev libjpeg-dev \
|
||||||
|
nasm tar libbz2-dev libgtk2.0-dev cmake git libfluidsynth-dev libgme-dev \
|
||||||
|
libopenal-dev timidity libwildmidi-dev unzip wget && \
|
||||||
|
apt-get clean autoclean && \
|
||||||
|
apt-get autoremove -y
|
||||||
|
|
||||||
|
############################
|
||||||
|
# Install Pip Requirements #
|
||||||
|
############################
|
||||||
|
RUN pip3 install --upgrade pip
|
||||||
|
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
|
||||||
20
docker/Dockerfile.doom_environment
Normal file
20
docker/Dockerfile.doom_environment
Normal 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
|
||||||
20
docker/Dockerfile.gym_environment
Normal file
20
docker/Dockerfile.gym_environment
Normal 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]
|
||||||
|
|
||||||
|
# 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] && pip3 install -e .[all] && rm -rf /root/.cache
|
||||||
|
COPY . /root/src
|
||||||
31
docker/Dockerfile.mujoco_environment
Normal file
31
docker/Dockerfile.mujoco_environment
Normal 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==1.50.1.68
|
||||||
|
|
||||||
|
# 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==1.50.1.68 && pip3 install -e .[all] && rm -rf /root/.cache
|
||||||
|
COPY . /root/src
|
||||||
27
docker/Dockerfile.starcraft_environment
Normal file
27
docker/Dockerfile.starcraft_environment
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
FROM coach-base:master as builder
|
||||||
|
|
||||||
|
# prep pysc2 and any of its related requirements.
|
||||||
|
RUN wget http://blzdistsc2-a.akamaihd.net/Linux/SC2.3.17.zip -O sc2.zip \
|
||||||
|
&& unzip -P 'iagreetotheeula' -d ~ sc2.zip \
|
||||||
|
&& rm sc2.zip
|
||||||
|
RUN wget https://github.com/deepmind/pysc2/releases/download/v1.2/mini_games.zip -O mini_games.zip \
|
||||||
|
&& unzip -d ~/StarCraftII/Maps mini_games.zip \
|
||||||
|
&& rm mini_games.zip
|
||||||
|
RUN pip3 install pysc2
|
||||||
|
|
||||||
|
# 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/StarCraftII /root/StarCraftII
|
||||||
|
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 pysc2 && pip3 install -e .[all] && rm -rf /root/.cache
|
||||||
|
COPY . /root/src
|
||||||
141
docker/Makefile
Normal file
141
docker/Makefile
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
# REGISTRY=gcr.io
|
||||||
|
REGISTRY=docker.io
|
||||||
|
ORGANIZATION=nervana
|
||||||
|
IMAGE=coach
|
||||||
|
CONTEXT = $(realpath ..)
|
||||||
|
|
||||||
|
BUILD_ARGUMENTS=
|
||||||
|
RUN_ARGUMENTS=
|
||||||
|
ifdef http_proxy
|
||||||
|
BUILD_ARGUMENTS+=--build-arg http_proxy=$(http_proxy)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef https_proxy
|
||||||
|
BUILD_ARGUMENTS+=--build-arg https_proxy=$(https_proxy)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef MUJOCO_KEY
|
||||||
|
KEY_NAME=${CONTEXT}/mjkey.txt
|
||||||
|
ifneq ("$(wildcard ${KEY_NAME})", "")
|
||||||
|
UNAME_S := $(shell uname -s)
|
||||||
|
ifeq ($(UNAME_S),Linux)
|
||||||
|
MUJOCO_KEY:=$(shell cat ${KEY_NAME} | base64 -w 0)
|
||||||
|
endif
|
||||||
|
ifeq ($(UNAME_S),Darwin)
|
||||||
|
MUJOCO_KEY:=$(shell cat ${KEY_NAME} | base64)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
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 --tb=short
|
||||||
|
|
||||||
|
# Functional Tests
|
||||||
|
ifdef FUNCTIONAL_PRESETS
|
||||||
|
FUNCTIONAL_PRESETS:=-k "${FUNCTIONAL_PRESETS}"
|
||||||
|
endif
|
||||||
|
ifndef FUNCTIONAL_PRESETS
|
||||||
|
FUNCTIONAL_PRESETS=
|
||||||
|
endif
|
||||||
|
FUNCTIONAL_TESTS=python3 -m pytest rl_coach/tests -s -v -k ${FUNCTIONAL_PRESETS} -m functional_test
|
||||||
|
|
||||||
|
# Golden Tests
|
||||||
|
ifdef GOLDEN_PRESETS
|
||||||
|
GOLDEN_PRESETS:=-k "${GOLDEN_PRESETS}"
|
||||||
|
endif
|
||||||
|
ifndef GOLDEN_PRESETS
|
||||||
|
GOLDEN_PRESETS=
|
||||||
|
endif
|
||||||
|
GOLDEN_TESTS=python3 -m pytest rl_coach/tests -m golden_test -v ${GOLDEN_PRESETS}
|
||||||
|
# example specifying a couple presets:
|
||||||
|
# GOLDEN_TESTS=python3 -m pytest rl_coach/tests -m golden_test -v -k "Mujoco_NAF or Doom_Basic_DQN"
|
||||||
|
# example specifying all golden tests using the mujoco environment
|
||||||
|
# GOLDEN_TESTS=python3 -m pytest rl_coach/tests -m golden_test -v -k "Mujoco"
|
||||||
|
|
||||||
|
# Trace Tests
|
||||||
|
ifdef TRACE_PRESETS
|
||||||
|
TRACE_PRESETS := -p $(TRACE_PRESETS)
|
||||||
|
else
|
||||||
|
TRACE_PRESETS :=
|
||||||
|
endif
|
||||||
|
TRACE_TESTS=python3 rl_coach/tests/trace_tests.py -prl ${TRACE_PRESETS}
|
||||||
|
|
||||||
|
ifndef DOCKER
|
||||||
|
DOCKER = docker
|
||||||
|
endif
|
||||||
|
|
||||||
|
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/*
|
||||||
|
|
||||||
|
shell: build
|
||||||
|
${DOCKER} run ${RUN_ARGUMENTS} -it ${IMAGE} /bin/bash
|
||||||
|
|
||||||
|
unit_tests: build
|
||||||
|
${DOCKER} run ${RUN_ARGUMENTS} -it ${IMAGE} ${UNIT_TESTS}
|
||||||
|
|
||||||
|
integration_tests: build
|
||||||
|
${DOCKER} run ${RUN_ARGUMENTS} -it ${IMAGE} ${INTEGRATION_TESTS}
|
||||||
|
|
||||||
|
functional_tests: build
|
||||||
|
${DOCKER} run ${RUN_ARGUMENTS} -it ${IMAGE} ${FUNCTIONAL_TESTS}
|
||||||
|
|
||||||
|
golden_tests: build
|
||||||
|
${DOCKER} run ${RUN_ARGUMENTS} -it ${IMAGE} ${GOLDEN_TESTS}
|
||||||
|
|
||||||
|
trace_tests: build
|
||||||
|
${DOCKER} run ${RUN_ARGUMENTS} -it ${IMAGE} ${TRACE_TESTS}
|
||||||
|
|
||||||
|
run: build
|
||||||
|
${DOCKER} run ${RUN_ARGUMENTS} -it ${IMAGE}
|
||||||
|
|
||||||
|
run_training_worker: build
|
||||||
|
${DOCKER} run ${RUN_ARGUMENTS} -it ${IMAGE} python3 rl_coach/training_worker.py --preset CartPole_DQN_distributed
|
||||||
|
|
||||||
|
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 /
|
||||||
|
|
||||||
|
stop_kubernetes:
|
||||||
|
kubectl delete service --ignore-not-found redis-service
|
||||||
|
kubectl delete pv --ignore-not-found nfs-checkpoint-pv
|
||||||
|
kubectl delete pvc --ignore-not-found nfs-checkpoint-pvc
|
||||||
|
kubectl delete deployment --ignore-not-found redis-server
|
||||||
|
kubectl get jobs | grep train | awk "{print $\1}" | xargs kubectl delete jobs
|
||||||
|
kubectl get jobs | grep worker | awk "{print $\1}" | xargs kubectl delete jobs
|
||||||
|
|
||||||
|
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}/${ORGANIZATION}/${IMAGE}
|
||||||
|
${DOCKER} push ${REGISTRY}/${ORGANIZATION}/${IMAGE}
|
||||||
|
|
||||||
|
unit_tests_without_docker:
|
||||||
|
cd .. && ${UNIT_TESTS}
|
||||||
|
|
||||||
|
integration_tests_without_docker:
|
||||||
|
cd .. && ${INTEGRATION_TESTS}
|
||||||
|
|
||||||
|
functional_tests_without_docker:
|
||||||
|
cd .. && ${FUNCTIONAL_TESTS}
|
||||||
|
|
||||||
|
golden_tests_without_docker:
|
||||||
|
cd .. && ${GOLDEN_TESTS}
|
||||||
|
|
||||||
|
trace_tests_without_docker:
|
||||||
|
cd .. && ${TRACE_TESTS}
|
||||||
35
docker/README.md
Normal file
35
docker/README.md
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
## `Dockerfile.starcraft_environment`
|
||||||
|
* `docker build -f docker/Dockerfile.starcraft_environment .` from the parent dir to create the image
|
||||||
|
* contains StarcraftII environment and Coach.
|
||||||
|
|
||||||
|
## `Dockerfile.carla_environment`
|
||||||
|
* `docker build -f docker/Dockerfile.carla_environment .` from the parent dir to create the image
|
||||||
|
* contains CARLA driving simulator environment and Coach.
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
from rl_coach.agents.actor_critic_agent import ActorCriticAgentParameters
|
from rl_coach.agents.actor_critic_agent import ActorCriticAgentParameters
|
||||||
from rl_coach.agents.policy_optimization_agent import PolicyGradientRescaler
|
from rl_coach.agents.policy_optimization_agent import PolicyGradientRescaler
|
||||||
from rl_coach.architectures.embedder_parameters import InputEmbedderParameters
|
from rl_coach.architectures.embedder_parameters import InputEmbedderParameters
|
||||||
from rl_coach.base_parameters import VisualizationParameters
|
from rl_coach.base_parameters import VisualizationParameters, PresetValidationParameters
|
||||||
from rl_coach.core_types import TrainingSteps, EnvironmentEpisodes, EnvironmentSteps
|
from rl_coach.core_types import TrainingSteps, EnvironmentEpisodes, EnvironmentSteps
|
||||||
from rl_coach.environments.starcraft2_environment import StarCraft2EnvironmentParameters
|
from rl_coach.environments.starcraft2_environment import StarCraft2EnvironmentParameters
|
||||||
from rl_coach.exploration_policies.additive_noise import AdditiveNoiseParameters
|
from rl_coach.exploration_policies.additive_noise import AdditiveNoiseParameters
|
||||||
@@ -53,5 +53,17 @@ env_params = StarCraft2EnvironmentParameters(level='CollectMineralShards')
|
|||||||
env_params.feature_screen_maps_to_use = [5]
|
env_params.feature_screen_maps_to_use = [5]
|
||||||
env_params.feature_minimap_maps_to_use = [5]
|
env_params.feature_minimap_maps_to_use = [5]
|
||||||
|
|
||||||
|
########
|
||||||
|
# Test #
|
||||||
|
########
|
||||||
|
preset_validation_params = PresetValidationParameters()
|
||||||
|
preset_validation_params.test = True
|
||||||
|
preset_validation_params.min_reward_threshold = 50
|
||||||
|
preset_validation_params.max_episodes_to_achieve_reward = 200
|
||||||
|
preset_validation_params.num_workers = 1
|
||||||
|
|
||||||
|
|
||||||
graph_manager = BasicRLGraphManager(agent_params=agent_params, env_params=env_params,
|
graph_manager = BasicRLGraphManager(agent_params=agent_params, env_params=env_params,
|
||||||
schedule_params=schedule_params, vis_params=VisualizationParameters())
|
schedule_params=schedule_params,
|
||||||
|
vis_params=VisualizationParameters(),
|
||||||
|
preset_validation_params=preset_validation_params)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from collections import OrderedDict
|
|||||||
from rl_coach.agents.ddqn_agent import DDQNAgentParameters
|
from rl_coach.agents.ddqn_agent import DDQNAgentParameters
|
||||||
from rl_coach.architectures.embedder_parameters import InputEmbedderParameters
|
from rl_coach.architectures.embedder_parameters import InputEmbedderParameters
|
||||||
from rl_coach.architectures.head_parameters import DuelingQHeadParameters
|
from rl_coach.architectures.head_parameters import DuelingQHeadParameters
|
||||||
from rl_coach.base_parameters import VisualizationParameters
|
from rl_coach.base_parameters import VisualizationParameters, PresetValidationParameters
|
||||||
from rl_coach.core_types import TrainingSteps, EnvironmentEpisodes, EnvironmentSteps
|
from rl_coach.core_types import TrainingSteps, EnvironmentEpisodes, EnvironmentSteps
|
||||||
from rl_coach.environments.starcraft2_environment import StarCraft2EnvironmentParameters
|
from rl_coach.environments.starcraft2_environment import StarCraft2EnvironmentParameters
|
||||||
from rl_coach.filters.action.box_discretization import BoxDiscretization
|
from rl_coach.filters.action.box_discretization import BoxDiscretization
|
||||||
@@ -53,6 +53,16 @@ env_params = StarCraft2EnvironmentParameters(level='CollectMineralShards')
|
|||||||
env_params.feature_screen_maps_to_use = [5]
|
env_params.feature_screen_maps_to_use = [5]
|
||||||
env_params.feature_minimap_maps_to_use = [5]
|
env_params.feature_minimap_maps_to_use = [5]
|
||||||
|
|
||||||
|
########
|
||||||
|
# Test #
|
||||||
|
########
|
||||||
|
preset_validation_params = PresetValidationParameters()
|
||||||
|
preset_validation_params.test = True
|
||||||
|
preset_validation_params.min_reward_threshold = 50
|
||||||
|
preset_validation_params.max_episodes_to_achieve_reward = 200
|
||||||
|
preset_validation_params.num_workers = 1
|
||||||
|
|
||||||
|
|
||||||
graph_manager = BasicRLGraphManager(agent_params=agent_params, env_params=env_params,
|
graph_manager = BasicRLGraphManager(agent_params=agent_params, env_params=env_params,
|
||||||
schedule_params=schedule_params, vis_params=VisualizationParameters())
|
schedule_params=schedule_params, vis_params=VisualizationParameters(),
|
||||||
|
preset_validation_params=preset_validation_params)
|
||||||
|
|||||||
Reference in New Issue
Block a user