Slurm Script Beginner CPU

logo glicid

The Slurm script generally follows this format:

#!/bin/bash
# Declaring Slurm Configuration Options

# Loading Software/Libraries

# Running Code

1. Sample Slurm Script

For example, let’s create a sample Slurm job script and submit the job to the cluster. First, create an empty file using vim editor(or your favourite editor) and insert the following script and save it using .slurm or .sh extension (for example, myjob.slurm or myjob.sh):

#!/bin/bash

#SBATCH --job-name=myjob        # Name for your job
#SBATCH --comment="Run My Job"  # Comment for your job

#SBATCH --output=%x_%j.out      # Output file
#SBATCH --error=%x_%j.err       # Error file

#SBATCH --time=0-00:05:00       # Time limit
#SBATCH --ntasks=2              # How many tasks per node
#SBATCH --cpus-per-task=2       # Number of CPUs per task
#SBATCH --mem-per-cpu=10g       # Memory per CPU
#SBATCH --qos=short             # priority/quality of service

# Command to run
hostname                        # Run the command hostname

In this example, we run the bash command hostname.