Slurm Demo: Difference between revisions

From Stat DS Computing Wiki
Jacobg2 (talk | contribs)
No edit summary
Jacobg2 (talk | contribs)
No edit summary
Line 1: Line 1:
This page will walk you through submitting a job via SLURM.
This page will walk you through submitting a job via SLURM.


'''Log Into the Head Node.'''
== '''Log Into the Head Node.''' ==


1 - Log in to the head node server using your StatDS computing account through your terminal. (If you forget your password, reset it here.) This cluster is used for demonstration purposes only. Actual compute jobs are not meant to be submitted to this cluster.
1 - Log in to the head node server using your StatDS computing account through your terminal. (If you forget your password, reset it here.) This cluster is used for demonstration purposes only. Actual compute jobs are not meant to be submitted to this cluster.
Line 20: Line 20:




'''Run Batch Submit Scripts'''
== '''Run Batch Submit Scripts''' ==


1 - Modify the “submit_bash.sh” script
1 - Modify the “submit_bash.sh” script
Line 55: Line 55:




'''Error Example Script'''
== '''Error Example Script''' ==
In addition to the regular output file, SLURM produces a dedicated file that contains any errors in your script. In some cases this is the only file that will contain any output.
In addition to the regular output file, SLURM produces a dedicated file that contains any errors in your script. In some cases this is the only file that will contain any output.


Line 62: Line 62:




    To see an example, submit the job with a syntax error.
To see an example, submit the job with a syntax error.
     ''sbatch submit_err.sh''
     ''sbatch submit_err.sh''


    View the contents of the error output file.
View the contents of the error output file.
     “cat” out the err file once completed.
     “cat” out the err file once completed.



Revision as of 16:08, 16 July 2025

This page will walk you through submitting a job via SLURM.

Log Into the Head Node.

1 - Log in to the head node server using your StatDS computing account through your terminal. (If you forget your password, reset it here.) This cluster is used for demonstration purposes only. Actual compute jobs are not meant to be submitted to this cluster.

    ssh statdsuser@ood.stat.cmu.edu

2 - Copy the Slurm Demo folder to your home directory. Do not run these files without moving them to your own working directory.

   cp -r /share/slurmdemo ~/slurmdemo

3 - Navigate to your new Slurm Demo directory.

   cd ~/slurmdemo

4 - View the contents of the Slurm Demo directory.

   ls -l


Run Batch Submit Scripts

1 - Modify the “submit_bash.sh” script You may use any text editor (vim, vi, nano, etc). In this example nano will be used.

   nano submit_bash.sh

2 - Change these three lines and make them more specific to you.

   #SBATCH --job-name=yourjobuniquename
   - This is the name of your job.
   #SBATCH --output=yourjoboutputfile_%j.out
   - This is the name of your job’s output file. Any intentional output generated from your job will be placed into this file. The “%j” will add the job’s unique JobID to the name.
   #SBATCH --error=yourjoberrorfile_%j.err
   - This is the name of your job’s error file. Any unintentional errors generated in the script will be placed into this file. The “%j” will add the job’s unique JobID to the name.


3 - Run the submit script

   sbatch submit_bash.sh

4 - View Running Jobs

   (Every job)
   squeue
   (Only your jobs)
   squeue -u $USER

5 - View the output file once the script is finished (use your unique outfile name)

   cat outputfile.out


Error Example Script

In addition to the regular output file, SLURM produces a dedicated file that contains any errors in your script. In some cases this is the only file that will contain any output.

    - This error file name is declared in your submit script as shown…
    #SBATCH --error=yourjoberrorfile_%j.err


To see an example, submit the job with a syntax error.

    sbatch submit_err.sh

View the contents of the error output file.

   “cat” out the err file once completed.







Requesting Additional Resources

SLURM allows you to request multiple CPU cores, a specified amount of RAM, and even GPUs if they are available. Requesting more than 1 CPU is especially important when paralyzing tasks.Below is an example submit script that shows how to declare each.

  1. !/bin/bash
  2. SBATCH --partition selectedpartition
  3. SBATCH --ntasks 1
  1. number of CPUs you need:
  2. SBATCH --cpus-per-task 1
  1. Amount of RAM in GB
  2. SBATCH --mem 1G
  1. Number of GPUs
  2. SBATCH --gres=gpu:1