ALRhub / clusterduck

clusterduck is a hydra launcher plugin for running jobs in batches on a SLURM cluster. It is intended for small tasks on clusters where jobs have exclusive access to a node, such that submitting a single task to a node would be wasteful.
12 stars 1 forks source link

Adding manual commands to the job #8

Closed ScheiklP closed 1 year ago

ScheiklP commented 1 year ago

In my setup, I need to execute some bash commands before actually starting the training. For example sourcing the bashrc, activating the conda environment, etc. Is there a way to tell the job "please run this sh script, before running python3 script.py"?

nicolas-schreiber commented 1 year ago

In the hydra->launcher dict you could add a list called setup with the bash commands for fully setting up your environment.

For reference: https://hydra.cc/docs/plugins/submitit_launcher/ https://github.com/facebookincubator/submitit/blob/83898f0a3d9d20a2d5efbc215a3e4d708701f3c4/submitit/slurm/slurm.py#L498C15-L498C15

ScheiklP commented 1 year ago

So that would be something like:

hydra:
   launcher:
      setup:
         - "source $HOME/.bashrc"
         - "conda activate sofa"

?

nicolas-schreiber commented 1 year ago

Yes, exactly, I have not really tried it yet, but the documentation and the code seem to confirm it

balazsgyenes commented 1 year ago

Yes exactly. The lines don't even need to be quoted.

There is a branch in development with an example of this usage actually, but even so, the documentation is in submitit.