Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dockerfile #128

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Add Dockerfile #128

wants to merge 2 commits into from

Conversation

Max-We
Copy link

@Max-We Max-We commented Oct 30, 2023

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.

@PWhiddy
Copy link
Owner

PWhiddy commented Oct 30, 2023

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 ...

@Max-We
Copy link
Author

Max-We commented Oct 31, 2023

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?

@joshhsoj1902
Copy link

joshhsoj1902 commented Jun 25, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants