SLURM Demo: Difference between revisions
No edit summary |
|||
| (10 intermediate revisions by one other user not shown) | |||
| Line 1: | Line 1: | ||
[[Category:Remote Server Access]] | |||
[[Category:Wright Cluster]] | |||
[[Category:PSC]] | |||
This page will walk you through submitting a job using SLURM. It will also cover basic Linux usage. | This page will walk you through submitting a job using SLURM. It will also cover basic Linux usage. | ||
| Line 9: | Line 14: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
ssh statdsuser@ood.stat.cmu.edu | ssh statdsuser@ood.stat.cmu.edu | ||
</syntaxhighlight>2 - Copy the SLURM | </syntaxhighlight>2 - Copy the SLURM demo folder to your home directory. Do not run these files without moving them to your own working directory.<syntaxhighlight lang="bash"> | ||
cp -r /share/slurmdemo ~/slurmdemo | cp -r /share/slurmdemo ~/slurmdemo | ||
</syntaxhighlight>3 - Navigate to your new SLURM Demo directory.<syntaxhighlight lang="bash"> | </syntaxhighlight>3 - Navigate to your new SLURM Demo directory.<syntaxhighlight lang="bash"> | ||
| Line 20: | Line 25: | ||
====== This section will demonstrate submitting a job using SLURM. ====== | ====== 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. | 1 - Modify the “submit_bash.sh” script. Make sure that you are in the correct directory that has the SLURM demo files from the section above. | ||
* ''You may use any text editor (vim, vi, nano, etc). In this example nano will be used.''<syntaxhighlight lang="bash"> | * ''You may use any text editor (vim, vi, nano, etc). In this example nano will be used.''<syntaxhighlight lang="bash"> | ||
| Line 37: | Line 42: | ||
3 - Run the submit script.<syntaxhighlight lang="bash"> | 3 - Run the submit script.<syntaxhighlight lang="bash"> | ||
sbatch submit_bash.sh | sbatch submit_bash.sh | ||
</syntaxhighlight>4 - Once you submit your job, you can view the status of it by running the command below. This will show your jobs | </syntaxhighlight>4 - Once you submit your job, you can view the status of it by running the command below. This will only show your jobs.<syntaxhighlight lang="bash"> | ||
squeue -u $USER | squeue -u $USER | ||
</syntaxhighlight>5 - To view every running job, run the command below.<syntaxhighlight lang="bash"> | </syntaxhighlight>5 - To view every running job, run the command below.<syntaxhighlight lang="bash"> | ||
| Line 43: | Line 48: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
6 - Once your job has finished, view the output file | 6 - Once your job has finished, view the contents of your output file. Use your unique output file name as modified in step 2.<syntaxhighlight lang="bash"> | ||
cat yourjoboutputfile_%j.out | cat yourjoboutputfile_%j.out | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== 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. | |||
Rename the error file in your own submit_err.sh. Modify the line shown below. <syntaxhighlight lang="bash"> | |||
#SBATCH --error=yourjoberrorfile_%j.err</syntaxhighlight> | |||
To see an example, run "submit_err.sh". This job runs a Python script with a syntax error.<syntaxhighlight lang="bash"> | |||
sbatch submit_err.sh | |||
</syntaxhighlight>View the contents of the error output file.<syntaxhighlight lang="bash"> | |||
cat nameofyourerrfile.err | |||
</syntaxhighlight> | |||
== Additional Information == | |||
====== 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.<syntaxhighlight lang="bash"> | |||
!/bin/bash | |||
SBATCH --partition selectedpartition | |||
SBATCH --ntasks 1 | |||
##number of CPUs you need: | |||
SBATCH --cpus-per-task 6 | |||
##Amount of RAM in GB | |||
SBATCH --mem 10G | |||
##Number of GPUs | |||
SBATCH --gres=gpu:1 | |||
</syntaxhighlight>For more information about SLURM, [https://info.stat.cmu.edu/index.php?title=Slurm visit this page here]. | |||
Latest revision as of 03:33, 29 June 2026
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.edu2 - 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 ~/slurmdemo3 - Navigate to your new SLURM Demo directory.
cd ~/slurmdemo4 - View the contents of the SLURM Demo directory.
ls -l2 - 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 demo files from the section above.
- You may use any text editor (vim, vi, nano, etc). In this example nano will be used.2 - Change these three lines and make them more specific to you.
nano submit_bash.sh
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.sh4 - Once you submit your job, you can view the status of it by running the command below. This will only show your jobs.
squeue -u $USER5 - To view every running job, run the command below.
squeue6 - Once your job has finished, view the contents of your output file. Use your unique output file name as modified in step 2.
cat yourjoboutputfile_%j.out3 - 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.
Rename the error file in your own submit_err.sh. Modify the line shown below.
#SBATCH --error=yourjoberrorfile_%j.errTo see an example, run "submit_err.sh". This job runs a Python script with a syntax error.
sbatch submit_err.shView the contents of the error output file.
cat nameofyourerrfile.err
Additional Information
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 6
##Amount of RAM in GB
SBATCH --mem 10G
##Number of GPUs
SBATCH --gres=gpu:1For more information about SLURM, visit this page here.