Skip to main content
Print

Getting Started with SLURM: Running your first HPC Job on Linux

 

This step-by-step guide is designed for beginners who are new to Linux and want to run their first Slurm job on an HPC cluster. Follow these detailed instructions to successfully submit and monitor your first job.

Step 1 : Connect to ARCC2 HPC Cluster

Open a command prompt on your local machine and connect to the HPC cluster using the ssh command. Replace username with your UC username and connect to ARCC2 cluster. Enter your password when prompted.

ssh username@arcc2.uc.edu

Step 2 : Navigate to Your Home Directory

Once connected, navigate to your home directory or the directory of choice using the cd command. cd  stands for change directory: 

$ cd ~
$ cd /path/to/your/working/directory

Step 3: Create a Simple Slurm Job Script

Use a text editor (like nano or vim) to create a simple Slurm job script. For example, create a file named my_job.sh:

$ nano my_job.sh

the .sh format stands for script files. Insert the following content into the file:

#!/bin/bash
#SBATCH --job-name=my_first_job
#SBATCH --output=my_first_job.out
#SBATCH --error=my_first_job.err
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --time=00:01:00
#SBATCH --qos=proj-xxx
echo "Hello, HPC World!"

Let’s break down each line of the Slurm job script:

  1. #!/bin/bash: This line is called a shebang and is used to specify the interpreter for the script. In this case, it indicates that the script should be interpreted using the Bash shell.

  2. #SBATCH --job-name=my_first_job: This line sets the name of the job. In this example, the job name is set to “my_first_job.” This name is useful for identifying your job in the job queue and job status listings.

  3. #SBATCH --output=my_first_job.out: This line specifies the name of the file where the standard output (stdout) of your job will be written. In this case, it is set to “my_first_job.out.”

  4. #SBATCH --error=my_first_job.err: This line specifies the name of the file where the standard error (stderr) output of your job will be written. Any error messages or issues encountered during the job execution will be logged to this file. Here, it is set to “my_first_job.err.”

  5. #SBATCH --nodes=1: This line indicates the number of nodes required for the job. In this example, the job is requesting one node.

  6. #SBATCH --ntasks-per-node=1: This line specifies the number of tasks (or processes) to be run per node. In this case, the job is requesting one task per node.

  7. #SBATCH --time=00:01:00: This line specifies the maximum wall time the requested for the nodes. It is specified in the format hrs:mins:sec. In this case, it is 0 hours, 1 minute and 0 seconds.

  8. echo "Hello, HPC World!": This line is the actual command that will be executed as part of your job. In this simple example, it prints the message “Hello, HPC World!” to the standard output. You can replace this line with the actual commands and computations you want your job to perform.

After editing the job script, save the file and exit the editor. 

Step 4: Submit Your Slurm Job

$ sbatch my_job.sh

This command sends your job scripts  to the Slurm scheduler for processing and execution.

Step 5: Check the Job Status

To check the status of your submitted job, use the squeue command:

$ squeue -u username

Step 6: Monitor Job Output

Once your job completes, you can find the output in the files specified in your job script (my_first_job.out and my_first_job.err in this example). Use the cat command to view the content:

$ cat my_first_job.out
$ cat my_first_job.err

Congratulations! You’ve successfully run your first Slurm job on an ARCC2 HPC cluster. This basic example serves as a foundation for more complex and computationally intensive tasks in the HPC environment.

Table of Contents