Slurm Demo: Difference between revisions

From Stat DS Computing Wiki
Jacobg2 (talk | contribs)
No edit summary
Jacobg2 (talk | contribs)
No edit summary
Line 3: Line 3:
'''Log Into the Head Node.'''
'''Log Into the Head Node.'''


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
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.


Copy the Slurm Demo folder to your home directory.
''ssh statdsuser@ood.stat.cmu.edu''
Do not run these files without moving them to your own working directory.


cp -r /share/slurmdemo ~/slurmdemo
2 - Copy the Slurm Demo folder to your home directory. Do not run these files without moving them to your own working directory.


Navigate to your new Slurm Demo directory.
''cp -r /share/slurmdemo ~/slurmdemo''


cd ~/slurmdemo
3 - Navigate to your new Slurm Demo directory.


View the contents of the Slurm Demo directory.
''cd ~/slurmdemo''


ls -l
4 - View the contents of the Slurm Demo directory.


''ls -l''


Run Batch Submit Scripts
 
Modify the “submit_bash.sh” script
'''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.
You may use any text editor (vim, vi, nano, etc). In this example nano will be used.


nano submit_bash.sh
''nano submit_bash.sh''


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


#SBATCH --job-name=yourjobuniquename
#SBATCH --job-name=yourjobuniquename
This is the name of your job.  
- This is the name of your job.  


#SBATCH --output=yourjoboutputfile_%j.out
#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.
- 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
#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.
- 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.






Run the submit script
3 - Run the submit script


sbatch submit_bash.sh
''sbatch submit_bash.sh''


View Running Jobs
4 - View Running Jobs
(Every job)
(Every job)
squeue
''squeue''
(Only your jobs)
(Only your jobs)
squeue -u $USER
''squeue -u $USER''


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


cat outputfile.out
''cat outputfile.out''





Revision as of 14:24, 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.

  1. SBATCH --job-name=yourjobuniquename
- This is the name of your job. 
  1. 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.
  1. 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…

  1. 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