Slurm Demo: Difference between revisions

From Stat DS Computing Wiki
Jacobg2 (talk | contribs)
Created page with "This page will walk you through submitting a job via SLURM. '''Log Into the Head Node. '''Log in to the head node server using your StatDS computing account through your term..."
 
No edit summary
 
(27 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Category:Wright Cluster]]
[[Category:PSC]]
[[Category:Remote Server Access]]
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.
== Aquire SLURM Demo Files ==
'''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, [https://util.stat.cmu.edu/passwordreset/ reset it here.])


Copy the Slurm Demo folder to your home directory.
''This cluster is used for demonstration purposes only. Actual compute jobs are not meant to be submitted to this cluster.''
Do not run these files without moving them to your own working directory.


cp -r /share/slurmdemo ~/slurmdemo
    ''ssh statdsuser@ood.stat.cmu.edu''


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


cd ~/slurmdemo
    ''cp -r /share/slurmdemo ~/slurmdemo''


View the contents of the Slurm Demo directory.
3 - Navigate to your new Slurm Demo directory.


ls -l
    ''cd ~/slurmdemo''


4 - View the contents of the Slurm Demo directory.


Run Batch Submit Scripts
    ''ls -l''
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
== Run Batch Submit Scripts ==


Change these three lines and make them more specific to you.  
1 - Modify the “submit_bash.sh” script. You may use any text editor (vim, vi, nano, etc). Nano will be used in this example.


#SBATCH --job-name=yourjobuniquename
    ''nano submit_bash.sh''
This is the name of your job.  


#SBATCH --output=yourjoboutputfile_%j.out
2 - Change these three lines and make them more specific to you.  
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
Name of your job.
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.
    #SBATCH --job-name=yourjobuniquename


Name of your job’s output file. Any output generated from your job will be placed into this file. The “%j” will add the job’s unique JobID to the name.


    #SBATCH --output=yourjoboutputfile_%j.out


Run the submit script
Name of your job’s error file. Any errors generated in the script will be placed into this file. The “%j” will add the job’s unique JobID to the name.
    #SBATCH --error=yourjoberrorfile_%j.err
   


sbatch submit_bash.sh
3 - Run the submit script.


View Running Jobs
    ''sbatch submit_bash.sh''
(Every job)
squeue
(Only your jobs)
squeue -u $USER


View the output file once the script is finished (use your unique outfile name)
4 - View Running Jobs.
    (Every job)
    ''squeue''
    (Only your jobs)
    ''squeue -u $USER''


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


    ''cat outputfile.out''


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.


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




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 yourjoberrorfile_%j.err
 
 
 
 
 
 
 
 
 
 
 
 


Requesting Additional Resources
== 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.
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.


#!/bin/bash
    #!/bin/bash
#SBATCH --partition selectedpartition
    #SBATCH --partition selectedpartition
#SBATCH --ntasks 1
    #SBATCH --ntasks 1


# number of CPUs you need:
    # # Number of CPUs you need:
#SBATCH --cpus-per-task 1
    #SBATCH --cpus-per-task 1


# Amount of RAM in GB
    # # Amount of RAM in GB
#SBATCH --mem 1G
    #SBATCH --mem 1G


# Number of GPUs
    # # Number of GPUs
#SBATCH --gres=gpu:1
    #SBATCH --gres=gpu:1

Latest revision as of 03:20, 29 June 2026


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

Aquire SLURM Demo Files

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). Nano will be used in this example.

   nano submit_bash.sh

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

Name of your job.

   #SBATCH --job-name=yourjobuniquename

Name of your job’s output file. Any output generated from your job will be placed into this file. The “%j” will add the job’s unique JobID to the name.

   #SBATCH --output=yourjoboutputfile_%j.out

Name of your job’s error file. Any errors generated in the script will be placed into this file. The “%j” will add the job’s unique JobID to the name.

   #SBATCH --error=yourjoberrorfile_%j.err
   

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.

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 yourjoberrorfile_%j.err

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.

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