facebookresearch / hydra

Hydra is a framework for elegantly configuring complex applications
https://hydra.cc
MIT License
8.79k stars 631 forks source link

Sequentially sweep multiple parameters with multi-run #2790

Closed nuomizai closed 1 year ago

nuomizai commented 1 year ago

I appreciate the multirun functions in hydra. However, I found with this function, the parameters are simultaneously configured with multiple parallel process. However, with the resource constraint, I want to configure the parameters sequentially. To be specific, my command is as follows

python train.py --multirun seed=0,1,2

I want to run the code with seed=1 after the code with seed=0 finished. Does anyone can help?

my config.yaml

hydra:
  run:
    dir: ./exp_local/${now:%Y.%m.%d}/${hydra.job.override_dirname}/${seed}
  sweep:
    dir: ./exp_local
    subdir: ${now:%Y.%m.%d}/${hydra.job.override_dirname}/${seed}
  job:
    config:
      override_dirname:
        exclude_keys:
          - seed
  launcher:
    timeout_min: 4300
    cpus_per_task: 10
    gpus_per_node: 8
    tasks_per_node: 1
    mem_gb: 160
    nodes: 1
odelalleau commented 1 year ago

Different launchers have different behavior. I’m pretty sure you can achieve this with either the submitit local launcher or the joblib one (can’t remember which one exactly)

nuomizai commented 1 year ago

Different launchers have different behavior. I’m pretty sure you can achieve this with either the submitit local launcher or the joblib one (can’t remember which one exactly)

Thanks for your reply. However, I found the joblib launcher is specifically for parallel tasks joblib. And now I'm using the submitit local launcher, but it also ran the tasks parallelly. So is there someway to use the submitit local launcher but to run the tasks sequentially?

nuomizai commented 1 year ago

Different launchers have different behavior. I’m pretty sure you can achieve this with either the submitit local launcher or the joblib one (can’t remember which one exactly)

Thanks for your help! I solved it. I found in the hydra document that

By default, Hydra runs your multi-run jobs locally and serially. Other launchers are available as plugins for launching in parallel and on different clusters. 

So if I don't override the launcher, the multiple runs would be executed serially.

my config.yaml

defaults:
  - _self_
  - task@_global_: quadruped_walk
  - agent@_global_: svea
#  - override hydra/launcher: submitit_local