SLURM Demo: Difference between revisions

From Stat DS Computing Wiki
Jacobg2 (talk | contribs)
Jacobg2 (talk | contribs)
No edit summary
Line 52: Line 52:
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.


Modify the error file in your own submit.sh. <syntaxhighlight lang="bash">
To see an example, submit the job with a syntax error.<syntaxhighlight lang="bash">
#SBATCH --error=yourjoberrorfile_%j.err
</syntaxhighlight>To see an example, submit the job with a syntax error.<syntaxhighlight lang="bash">
sbatch submit_err.sh
sbatch submit_err.sh
</syntaxhighlight>View the contents of the error output file.<syntaxhighlight lang="bash">
</syntaxhighlight>View the contents of the error output file.<syntaxhighlight lang="bash">
cat nameofyourerrfile.err
cat nameofyourerrfile.err
</syntaxhighlight>
</syntaxhighlight>
Modify the error file in your own submit.sh. <syntaxhighlight lang="bash">
#SBATCH --error=yourjoberrorfile_%j.err</syntaxhighlight>

Revision as of 16:45, 27 August 2025

This page will walk you through submitting a job using SLURM. It will also cover basic Linux usage.

1 - Copy SLURM Demo Files

This section will cover copying example SLURM files to your own personal location.

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

2 - Submit SLURM Job

This section will demonstrate submitting a job using SLURM.

1 - Modify the “submit_bash.sh” script. Make sure that you are in the correct directory that has the SLURM files from the section above.

  • 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 - Once you submit your job, you can view the status of it by running the command below. This will show your jobs olny.

squeue -u $USER

5 - To view every running job, run the command below.

squeue

6 - Once your job has finished, view the output file once the script is finished. Use your unique output file name as modified in step 2.

cat yourjoboutputfile_%j.out

3 - Submit SLURM Job with an Error

This section will demonstrate submitting a job using SLURM that produces an error.

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.

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

sbatch submit_err.sh

View the contents of the error output file.

cat nameofyourerrfile.err

Modify the error file in your own submit.sh.

#SBATCH --error=yourjoberrorfile_%j.err