Hydra Submitit Launcher

1.2.0 · active · verified Thu Apr 16

The Hydra Submitit Launcher provides a plugin for Hydra applications, enabling them to launch jobs on various backend environments like Slurm, AWS Batch, or locally via Submitit. It integrates seamlessly with Hydra's configuration system. The current version is 1.2.0, with releases typically aligning with updates to Submitit or Hydra itself.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to set up a basic Hydra application to be launched using `submitit_local`. Users need to define a Hydra configuration file (e.g., `conf/config.yaml`) that specifies the `submitit_local` launcher. The `@hydra.main` decorator will then use this configuration to launch the `my_app` function as a Submitit job. For demonstration purposes, `submitit_local` is used; for production, `submitit_slurm` or other backends would be chosen after installing their respective dependencies (e.g., `pip install submitit[slurm]`).

import hydra
from omegaconf import DictConfig
import os

# To run this quickstart:
# 1. Ensure hydra-submitit-launcher is installed: `pip install hydra-submitit-launcher`
# 2. Create a directory named 'conf' in the same location as this script.
# 3. Create a file 'conf/config.yaml' with the following content:
#    ---
#    # conf/config.yaml
#    # @package _global_
#    defaults:
#      - override hydra/launcher: submitit_local
#      - _self_
#
#    hydra:
#      launcher:
#        submitit_local:
#          timeout_min: 1
#          cpus_per_task: 1
#          mem_gb: 1
#          nodes: 1
#    ---
# 4. Save this Python code as a .py file (e.g., my_app.py).
# 5. Run from your terminal: `python my_app.py`

@hydra.main(config_path='conf', config_name='config', version_base='1.3')
def my_app(cfg: DictConfig) -> None:
    print(f"Hello from a Submitit-launched job!")
    print(f"Working directory : {os.getcwd()}")
    print(f"Config: {cfg.pretty()}")
    # The actual job logic would go here. Submitit handles serialization
    # of the function and its arguments to the remote/local executor.

if __name__ == "__main__":
    my_app()

view raw JSON →