google-deepmind / meltingpot

A suite of test scenarios for multi-agent reinforcement learning.
Apache License 2.0
582 stars 118 forks source link

Proposal: docker python 3.10 support & pypi release #118

Closed elliottower closed 1 year ago

elliottower commented 1 year ago

Hi, just wanted to ask if it would be possible to add compatibility to python 3.10, as that is one of the supported versions for shimmy (see https://github.com/Farama-Foundation/Shimmy/pull/39).

Also it would be very helpful if meltingpot were published via pypi so that we could more easily download different versions for testing. I've been trying to modify the dockerfile to take in an ARG PYTHON_VERSION and then download the correct version from this repo'swheels based on that, but there doesn't appear to be a way to get the most recent release and I wouldn't want to hardcode a release when it seems the repo is still being actively updated. The dockerfile in the dev container in this repo also points to a hard coded pre-release for dm_lab2d (https://github.com/deepmind/lab2d/releases/tag/release_candidate_2022-03-24). If it's not possible to release via pypi it would be at least very helpful to get a dockerfile which will automatically point to the most recent release of meltingpot and ideally allows for the python version to be changed via environment variable.

For example, the other shimmy dockerfiles are spun up from python version, rather than nvidia cuda version:

ARG PYTHON_VERSION
FROM python:$PYTHON_VERSION

vs

# Use Nvidia Ubuntu 20 base (includes CUDA if a supported GPU is present)
# https://hub.docker.com/r/nvidia/cuda
FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu20.04@sha256:b754c43fe9d62e88862d168c4ab9282618a376dbc54871467870366cacfa456e

I'm not an expert on docker so am not sure if this is possible, but figured I would ask just in case.

elliottower commented 1 year ago

My guess is that the devcontainer/dockerfile isn't used internally as it's out of date, so I looked at the CI workflow and I'm trying to figure out if this could be adapted, would this download the most recent release? https://github.com/deepmind/meltingpot/blob/main/.github/workflows/ci.yml#L46

jagapiou commented 1 year ago

Hi Elliot,

Yep it would be totally fine to upgrade that Dockerfile to 3.10, as you say we don't currently use it internally, so whatever is helpful externally.

Re pypi, unfortunately dmlab2d isn't available on pypi so I don't think meltingpot can be either. In our tests (as you found) we build dmlab2d from the latest dmlab2d commit (see install-dmlab2d.sh). This occasionally leads to breaks when bazel updates etc.

I also note that the Dockerfile is using the old v1 assets.

Since our tests use install-dmlab2d.sh and install-meltingpot.sh and we keep them green, if the Dockerfile can use those for setup that would keep it in good shape. However, the build takes a long time, and I don't know how often that cost would be incurred.

J.

elliottower commented 1 year ago

Hi Elliot,

Yep it would be totally fine to upgrade that Dockerfile to 3.10, as you say we don't currently use it internally, so whatever is helpful externally.

Re pypi, unfortunately dmlab2d isn't available on pypi so I don't think meltingpot can be either. In our tests (as you found) we build dmlab2d from the latest dmlab2d commit (see install-dmlab2d.sh). This occasionally leads to breaks when bazel updates etc.

I also note that the Dockerfile is using the old v1 assets.

Since our tests use install-dmlab2d.sh and install-meltingpot.sh and we keep them green, if the Dockerfile can use those for setup that would keep it in good shape. However, the build takes a long time, and I don't know how often that cost would be incurred.

J.

Thanks for the info, makes sense about the shell scripts being the primary way to install. Would it be possible to update the devcontainer/dockerfile using the new assets? I can see the tests using the shell scripts makes sense for your end but for shimmy I think it would be ideal to just use a dockerfile with things pre-built, if that's possible. Or for example, having releases on here built for distribution (e.g., manylinux py39, py38, etc) similar to dmlab2d would be super helpful.

elliottower commented 1 year ago

Would it be possible to provide a docker image? The workflow using shell scripts now takes ~40 minutes, I've tried exporting after creating my own but have ran into some issues. I figure it makes more sense for this repo to have an up to date docker image anyways, versus shimmy CI building once and then exporting the image to its own cache (not accessible by other repos or users).

jagapiou commented 1 year ago

Updated the assets in the Dockerfile. I'm afraid I don't know anything about Docker, and it's very unlikely I'll have time to work on creating a Docker image.

I'm not sure what you mean by creating a meltingpot "release built for distribution". meltingpot is pure Python (3.9) and should be easy to install on any setup that has dmlab2d installed.

I think the bulk of the meltingpot workflow time is probably running the tests, would skipping them (or some of them) help? I could add a --notest flag to the install scripts if that helps you.

I found that it's usually the dmlab2d installation that's the slow/tricky bit. I've picked up a lot about how to get dmlab2d installed in some settings and I'm happy to share what I've learned on that front. But if I can't help, best to ask them for help with any dmlab2d issues.

elliottower commented 1 year ago

Updated the assets in the Dockerfile. I'm afraid I don't know anything about Docker, and it's very unlikely I'll have time to work on creating a Docker image.

I'm not sure what you mean by creating a meltingpot "release built for distribution". meltingpot is pure Python (3.9) and should be easy to install on any setup that has dmlab2d installed.

I think the bulk of the meltingpot workflow time is probably running the tests, would skipping them (or some of them) help? I could add a --notest flag to the install scripts if that helps you.

I found that it's usually the dmlab2d installation that's the slow/tricky bit. I've picked up a lot about how to get dmlab2d installed in some settings and I'm happy to share what I've learned on that front. But if I can't help, best to ask them for help with any dmlab2d issues.

Appreciate the help! A notest arg would be great, or maybe a separate shell script for the tests (shouldn’t need to test RLlib for example when installing). I can see if I can make a docker image though, will post here if I can get it working.

Wasn’t aware it was only 3.9, as I thought I saw something somewhere testing different Python versions down to 3.6, but that makes things easier.

elliottower commented 1 year ago

I tried making docker images just to test if that would make the workflow faster but they ended up being very large (900mb even compressed to tar.gz), so the provided devcontainer script is perfect. I had an issue running the dockerfile as is though, had to add this line to the top: RUN apt-get update --fix-missing

jagapiou commented 1 year ago

I'll submit a CL to split the install-x.sh into install-x.sh and test-x.sh.

jagapiou commented 1 year ago

It was once >=3.6 but it's >=3.9 now, let me know if you see any stale doc.

jagapiou commented 1 year ago

FYI: recently upgraded the docker to 3.10

elliottower commented 1 year ago

FYI: recently upgraded the docker to 3.10

Good to know, btw I also recently made a SB3 tutorial for PettingZoo and fixed some compatibility issues with SuperSuit, so I can make a PR updating the code here to use shimmy and the most up to date SB3

jagapiou commented 1 year ago

And pypi is released so I think this issue is now done.

@elliottower if you have a PR fixing up the petting zoo example, that would be great thanks.