Skip to content

jaiken17/slurm-script-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

slurm-script-example

This repository is an example for how to set up scripts to submit an array of SLURM jobs (all running the same program) each with their own initial parameters. These scripts are written to work on Digital Research Alliance of Canada (DRAC) HPC clusters, but should work on other systems that use the SLURM scheduler.

The Basic Pieces

  • slurm_starts.sh is the BASH script that will submit the SLURM jobs. It contains the location to the template directory and the file that contains each run name and its initial parameters. This script is submitted to the SLURM scheduler and run by each job in the array.

  • make_wds.py is the python script that handles reading the initial parameters file and copying the template directory to generate the new working directories.

  • params.txt is the initial parameters file. Each line contains the run's name and its three initial parameters.

  • prog_run.sh is the program run script. This script is what is used by slurm_stars.sh to run the program. In this example (running a python program), it is very simplistic.

  • template_wd is the template directory that contains the python program and its template initial parameters file.

  • template_wd/example_prog.py is the python program. This program numerically solves the equations of motion for projectile motion until the projectile hits the ground ($y_f\approx 0$). All the relevant data is output to output.data This program was generated by AI as it is just an example.

  • template/initial_conditions.txt is the template initial parameters file. This file is read by template_wd/example_prog.py to generate the simulation. It contains the placeholder values 'PARAM1', 'PARAM2', and 'PARAM3' which are to be changed by the make_wds.py script in the new run directories.

How to Run

  1. Generate the initial parameters file (params.txt here). This can be done by hand for small numbers of runs.

  2. Set the job run time, name, number of CPUs, amount of RAM, and number of jobs in the array in slurm_start.sh. Also set TEMPLATE_DIR and PARAMS_FILE.

  3. Set param_placeholders and files_to_replace in make_wds.py.

  4. Configure prog_run.sh to run your desired program.

  5. Submit the slurm_start.sh file to the scheduler using:

sbatch slurm_start.sh

About

An example repository to show how to set up scripts to submit an array of SLURM jobs for use on DRAC clusters

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors