Package: slacc
SLurm on vACC (slacc)"Take it easy and let the VACC work for you." - the wise gradIsn't it fun to have a nice GPU in your computer and to experiment left and right? You just write some python scripts
and then launch them on your machine, wait, repeat. Life is simple and beautiful.But then inevitably it happens. You want to launch more scripts, longer scripts, test different parameters...So you have to go beg the SLURM gods to assist you. Evil bash scripts start popping up everywhere, requesting resources, launching jobs....Wouldn't it be nice to just abstract that pain away and remain in python land?PrerequisitesPython >=3.9That's it.InstallationStep 1. Get the thing.pipinstallslaccNote: as of May 2023 thespacksoftware on the VACC doesn't like python 3.10, so it is suggested to installslaccin a 3.9 environment
If you are usingconda(recommended) you can use grab an installer for 3.9 from theminicondapageThis will make your condabaseenvironment use python 3.9Alternatively you can create an custom environment withconda create -n <pick_a_name> python=3.9and runpip install slaccin this new environment.Step 2. Customize the thing.After installingslacc(it should be quick since there are no dependencies) runsconfigThis will copy the defaultconfig.jsonfile that ships withslacc, to$HOME/.config/slacc/config.json.
Feel free to customize it to your needs, or keep it as it is. The most important thing is to make sure that the conda environments declared in config.json{ 
  "dggpu":{ "env": "conda activate dgenv",
            ...
}match the ones available on your system.How does it work?This package provides 2 main commands you can use in your CLI:slaunchandsinteract(plussconfigto make a copy default configs)1. Slurm LAUNCH (slaunch)This is a wrapper around SLURM'ssbatchto make it way easier to launch python scripts asynchronously.Let's say that you wanted to run this locally:pythontrain.py--lr=0.01then to run the same thing on the VACC you would do:slaunchdggputrain.py--lr=0.01Voilá!Behind the scenes, the launcher created an sbatch script for you like:#!/bin/bash#SBATCH --time=2-00:00:00#SBATCH --account=myproject#SBATCH --partition=big-gpu#SBATCH --gres=gpu:p100:1#SBATCH --mem=8000condaactivatedgenv
pythontrain.py--lr=0.01Even better, it makes it easy to launch parameter sweeps as a job array.Basic Usage:warning: Before using, you will want to edit the resource configs to suit your needs, as described in theResource Configurationssection.It has the following syntax:slaunch [-h] [--runs RUNS] [--argfile ARGFILE] [-d RUNDIR] [-f] RESOURCE SCRIPT [FLAGS...]whereRESOURCEis the name of an entry inconfig.json(seeResource Configurations).For example, this:slaunchdggpu--runs2dummy_gpujob.py--epochs=10--seed42is equivalent to twice running this:pythondummy_gpujob.py--epochs=10--seed42Furthermore, any settings accepted bysbatchmay be supplied on the command line. These will override the options
provided byconfig.json, if given. For example, to add more memory to an existing config:slaunch dggpu --mem=64G dummy_gpujob.pyNOTE:Thesbatchoptions must be supplied in--name=valuefashion, with an
equals sign;--name valuewillnotparse correctly. For any other options
(including script flags) you may use either format.Run DirectoryA recommended way to run jobs is to isolate different experiments to separate folders, so that all the related inputs
and outputs can be stored in one place. This can be done with the-d/--rundiroption:slaunchdggpu-dexperiments/my-next-breakthroughtrain.py--configtrain-config.ymlIn this example, all experiments are stored in the corresponding repository, under theexperiments/folder. The script
runs in this folder, where it expects to find atrain-config.ymlfile. Say the script also generates atrained_models/folder. After running, the experiment folder will contain:__ experiments/my-next-breakthrough/
  |__ train-config.yml
  |__ slurm-12345678.out
  |__ trained_models/
     |__ model-1000.pth
     |__ model-2000.pth
     |__ ...Running Job Arraysslaunchcan also run a full sweep of jobs as a single job array.:warning:Careful with program outputs when using this method!For instance, if you are running a program that outputs trained models, you will need to supply each run with a
separate output folder so they don't overwrite each other.You can run the same exact job N times via-r/--runs:slaunchbdgpu--runs10eval.py--lr0.01--num-steps10--plotsOr you can run a sweep over different configurations, by providing each configuration as a separate line in an
"argfile":slaunchbdgpu--argfilesweep-args.txteval.py--plotsWhere the argfile looks something like this:--lr 0.1  --num-steps 10 -o outfile1
--lr 0.1  --num-steps 15 -o outfile2
--lr 0.03 --num-steps 10 -o outfile3
--lr 0.03 --num-steps 15 -o outfile4
--lr 0.01 --num-steps 10 -o outfile5
--lr 0.01 --num-steps 15 -o outfile6In both cases, these will be launched as ajob array, making it easier to
track and manage the jobs as a single unit.2. Slurm INTERACTive (sinteract)This is a wrapper aroundsrunthat allows you to easily start an interactive shell on one of the SLURM nodes.  The
shell you launch will be granted the resources of theresource configyou provide.Example:sinteractbdgpuResource ConfigurationsTheconfig.jsonfile provides a list of pre-defined resource configurations which the user can use to launch their
SLURM jobs. This is helpful to save sets ofsbatchorsrunoptions that the user uses frequently.You will want
to edit these to add your own configurations which are suitable for your common tasks.However, if you need to change
minor things like the amount of memory from job to job, you can always adjust that on the command line.Each entry has the following structure:{
  NAME:
    ENV
    RESOURCES
}NAME: a unique identifier for the config.ENV: specifies how to set up virtual environments, if needed.RESOURCES: specifies the options to pass to SLURM.Here is a concrete example:{"dggpu":{"env":"conda activate dgenv","resources":{"time":"2-00:00:00","partition":"big-gpu","cpus-per-task":1,"gres":"gpu:v100:1","mem":"8000"}},"bigcpu":{"env":"conda activate myenv","device":"cpu","resources":{"time":"1-00:00:00","partition":"bluemoon","cpus-per-task":1,"mem":"8000"}}}A few default configurations are provided as part of the packageconfig.json.:warning: There are 3 places where slacc looks for configuration files. If the same resource is defined in multiple places, only the one with highest priority is considered:(LOW PRIO)Defaultsprovided by slacc (use this if you are happy with the defaults and don't want to change anything)(MED PRIO) $HOME/.config/slacc/config.json (use this if you want to create custom configurations that you are planning to re-use)(MAX PRIO) Directory containing the job script, e.g. when launching ~/scratch/agi_net/train.py looks for ~/scratch/agi_net/config.json (use this if you want each individual run to use a different configuration):hammer_and_wrench: Usesconfigto copy the default settings to $HOME/.config/slacc/config.json.