PokemonRedExperiments icon indicating copy to clipboard operation
PokemonRedExperiments copied to clipboard

Add Dockerfile

Open Max-We opened this issue 2 years ago • 3 comments
trafficstars

I created a simple Dockerfile that installs all required python & system dependencies and runs one of the python scripts (currently run_baseline_parallel.py, but this can easily be adapted). This pull request is related to #111

In case we want to support multiple commands (not just run_baseline_parallel.py) it would be appropriate to create multiple Dockerfiles or an entry point script.

Max-We avatar Oct 30 '23 09:10 Max-We

Hi! You've tested this dockerfile, does it need things like ffmpeg for example? Also I wonder if starting a container to run a single command makes sense, does this create a good workflow for running experiments that doesn't result in deleting results after each run or having many stale containers sitting around? Just thinking through these things ...

PWhiddy avatar Oct 30 '23 17:10 PWhiddy

You've tested this dockerfile, does it need things like ffmpeg for example?

For the installation (pip), it does not, however I haven't tried training an entire model with it.

Also I wonder if starting a container to run a single command makes sense

What workflows do you have in mind?

Max-We avatar Oct 31 '23 03:10 Max-We

I was struggling getting this to run under python 3.12. so I decided to give this docker image a go. I made a few small tweaks which don't feel worth contributing but are maybe worth noting here:

Dockerfile

FROM python:3.10-bookworm

# Set the working directory in docker
WORKDIR /pokemon

# Install system dependencies
RUN apt-get update && apt-get install -y \
  build-essential \
  git && \
  # Clean up apt cache to reduce image size.
  apt-get clean && \
  rm -rf /var/lib/apt/lists/*

RUN apt-get update && apt-get install -y \
  ffmpeg && \
  # Clean up apt cache to reduce image size.
  apt-get clean && \
  rm -rf /var/lib/apt/lists/*

RUN mkdir baselines

COPY baselines/requirements.txt baselines

# Install Python dependencies
RUN pip install --no-cache-dir -r baselines/requirements.txt

RUN pip install websockets

# Copy source-code
# COPY . .

WORKDIR /pokemon/baselines

# Command to run at container start
CMD [ "python", "run_baseline_parallel_fast.py" ]

The main differences are:

  • Changed the final workdir so it can find the rom
  • Don't copy all the source into the image, instead mount the local dir at runtime

I then run it using this docker-compose

docker-compose.yaml

version: "3.4"
services:
  pokemonredexperiments:
    image: joshhsoj1902/pokemonredexperiments:latest
    volumes:
      - ./:/pokemon
    restart: always

And for complete clarity here are the build & run commands:

    docker build --progress=plain -t joshhsoj1902/pokemonredexperiments:latest .

	docker compose up

I don't know if this is completely working or not since I wasn't able to get it to run outside of docker, but I was able to get things to show up in https://pwhiddy.github.io/pokerl-map-viz/. in terms of the session screenshots, The "curframe" screenshots work fine, but the reward frames screenshots are usually black/white boxes (with a few exceptions, so maybe it's actually working)

I look forward to playing with this more!


Edit: I just updated the dockerfile to install ffmpeg and the video generation seems to work (for anyone just getting started it's off by default, look for the save_video setting in the env setup). Sometimes it crashes on startup but usually it runs fine (I've only really ran it for about 30 min at this point, but if I don't update this post now I'll forget)

joshhsoj1902 avatar Jun 25 '24 13:06 joshhsoj1902