Getting started

From DSV Slurm documentation
Revision as of 13:11, 21 May 2026 by Erth9960(AT)su.se (talk | contribs) (Submitting your job)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This document should help you get started with logging in to the cluster and running a "Hello world" script as a slurm job.

Accessing the cluster

First you need to apply for access to the cluster if you haven't already, see this page for details. Once you have been granted access, you will need to configure a VPN connection in order to be able to communicate with the server. Students can set up a VPN connection at https://vpn-student.dsv.su.se.

When your VPN connection is up and running, you connect to the cluster using an SSH client and your SU credentials. The server address is olympus.dsv.su.se.

me@mylaptop:~$ ssh erth9960@olympus.dsv.su.se
erth9960@olympus's password: 
Linux slurm-login 6.1.0-44-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.164-1 (2026-03-09) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Wed Apr 15 14:01:10 2026 from vpn-student-wgi.dsv.su.se
erth9960@slurm-login:~$

When you have successfully logged in, you can move on to running your first Slurm job.

Running code as a slurm job

Running code on slurm is always an asynchronous process. In other words you submit a job to the queue, Slurm schedules the job for execution when relevant resources are available, and any output from your job is recorded in a file.

Preparing your script

Write the following code into a file named hello-slurm.sh

#!/bin/bash
#SBATCH --job-name=testjob
#SBATCH --partition=cpu

echo "Hello $HOSTNAME"

The initial #SBATCH comments are special commands read by Slurm, passing instructions about how to execute your job. Here we only choose a name for the job and which partition to run it on. An incomplete list of useful sbatch arguments is available here.

$HOSTNAME is an environment variable that contains the name of the server the code is running on.

Submitting your job

Once you have saved your script, you queue it for execution by running the following command:

sbatch hello-slurm.sh

You should see output similar to this:

Submitted batch job 1928

Since the script does very little work it will probably execute immediately, but if it doesn't you can see its place in the queue by running the command squeue. You can also see details about your job by running scontrol show job NN, where NN is the job ID that was printed (1928 in this example).

Reading job output

Since the job is run asynchronously, the output from your job will not be printed to your terminal as usual but written to a file. We don't specify a filename to use, so slurm will use the default name. The default name is slurm-NN.out, where NN is the job ID.

You can read the resulting file with any tool that can read text files, such as cat:

erth9960@slurm-login:~$ cat slurm-1928.out
Hello slurm-node-cpu-01

Here you can see that the code executed on slurm-node-cpu-01, as opposed to slurm-login which is where your terminal session is running.

Further reading

A more ambitious example job, which deals with a slightly more complex Python scenario is available at https://gitea.dsv.su.se/erth9960/slurm-gpu-test.