Skip to content

samuelstanton/hydra-ray-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hydra-ray-demo

Demonstration of how to structure a project with Hydra for easy deployment with Ray.

Quickstart

python -m pip install -r requirements.txt
python main.py

The default behavior of the application is determined by config/main.yaml

Command-line configuration overrides

It's easy to override the default behavior of your application from the command line.

python main.py module=type_b

Any overrides will be stored in outputs/<DATE>/<TIME>, along with the program logs in case you come back later and can't remember what command was run.

Multirun

You can easily run configuration sweeps without any additional boilerplate using the -m option. By default the basic launcher will schedule and execute the configurations serially.

python main.py -m module=type_a,type_b

Launching configuration sweeps with Ray locally

You can use Ray to execute configurations in parallel. Thanks to the Hydra Ray plugin, you don't need to write any additional code!

python main.py -m hydra/launcher=ray module=type_a,type_b

Note: You must use the -m option when using anything other than the basic launcher.

Launching configuration sweeps with Ray on EC2

Ray can also spin up new clusters for you on EC2 and run your jobs in parallel. Here's the setup you'll need to do.

Setup Overview

  1. Install the AWS CLI
  2. Configure your AWS access credentials
  3. Raise your service quota (if necessary)
  4. Configure IAM roles for ray nodes

How to make a docker container

This part of the demo requires a docker image. Try running the demo first using the image I've created, then worry about making your own. Look at config/hydra/launcher/ray_aws.yaml to see configuration details.

cd /path/to/hydra-ray-demo
cd ..
docker build . -f hydra-ray-demo/Dockerfile --tag <DOCKERHUB_USER>/<IMAGE_NAME>:<TAG>
docker push <DOCKERHUB_USER>/<IMAGE_NAME>:<TAG>

Note: Keep the contents of the parent directory to a minimum for fastest build times.

After using docker for a while your storage will be quickly filled with fragments of previous images. Use docker system prune -f to clean that up.

Launching jobs

python main.py -m hydra/launcher=ray_aws module=type_a,type_b

Additional Resources

About

Demonstration of how to structure a project with Hydra for easy deployment with Ray

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published