Skip to content

Your first job, on a Slurm cluster in containers

By the end of this you'll have submitted a two-node job with dunscaith and watched it finish. Then you'll have Slurm take the nodes away from a second job halfway through, and watch dunscaith put it back in the queue without you.

You don't need a cluster of your own. The one here is three containers on your machine, made by sind: a controller, which is also the node you log in to, and two workers. Allow about fifteen minutes. Most of that is one download.

What this cluster is not

The jobs here are shell loops, and there are no GPUs. It's a cut-down copy of the cluster dunscaith's acceptance suite runs against on every merge request. dunscaith hasn't yet run a job on Kubeflow, on a production cluster, or on real GPUs.

What you need

  • A Linux machine with Docker Engine 28 or newer, and permission to use it. This was written on Linux with Docker Engine 29, and nothing else has been tried.
  • Go 1.27 or newer, to build sind and dunscaith.
  • About 3 GB of free memory, and 1.3 GB of disk for the node image.

Install sind and check Docker will do

go install github.com/GSI-HPC/sind/cmd/sind@v0.12.0
sind doctor

sind doctor prints a line for each thing it checks. It starts like this:

✓ Docker Engine: 29.7.2 (>= 28.0)
✓ Docker daemon: rootful, no userns-remap
✓ Docker host: this machine (unix:///var/run/docker.sock)
✓ cgroupv2: nsdelegate enabled (/sys/fs/cgroup)

You want a tick on those four. A cross against inotify further down is fine: that limit only matters for a cluster of ten nodes or more.

Make the cluster

Make a directory to work in. Its data directory becomes /data on every node, which is how files get on and off the cluster.

mkdir -p dunscaith-tutorial/data/bin dunscaith-tutorial/data/out
cd dunscaith-tutorial
chmod 777 data/out

The jobs run as a cluster user, not as you, and write their output to data/out. That's why it's opened up.

Now describe the cluster and create it. The first time, this pulls the node image, which is 1.3 GB. After that it takes a few seconds.

cat > cluster.yaml <<EOF
kind: Cluster
name: tutorial
defaults:
  image: ghcr.io/gsi-hpc/sind-node:25.11.8
  cpus: 1
  memory: 512m
storage:
  dataStorage:
    type: hostPath
    hostPath: $PWD/data
slurm:
  main: |
    PartitionName=main Nodes=ALL Default=YES MaxTime=INFINITE State=UP PriorityTier=1
    PartitionName=high Nodes=ALL MaxTime=INFINITE State=UP PriorityTier=10
    PreemptType=preempt/partition_prio
    PreemptMode=REQUEUE
nodes:
  - role: controller
    memory: 1g
  - role: worker
    count: 2
EOF
sind create cluster --config cluster.yaml

The slurm block gives the cluster two partitions. A partition is Slurm's name for a queue of nodes. Both of these cover the same two workers, and high outranks main: a job sent to high takes the nodes from a job running in main. That's a preemption, and you'll cause one later.

Check that Slurm sees both workers:

docker exec sind-tutorial-controller sinfo
PARTITION AVAIL  TIMELIMIT  NODES  STATE NODELIST
main*        up   infinite      2   idle worker-[0-1]
high         up   infinite      2   idle worker-[0-1]
all          up   infinite      2   idle worker-[0-1]

Both should say idle. If they don't yet, give it a few seconds and ask again. The all partition is one sind adds itself.

Add a user to run jobs as

On a real cluster you'd log in as yourself. The node image has no ordinary user, so add one, with the same ID on every node:

for node in controller worker-0 worker-1; do
  docker exec sind-tutorial-$node useradd -u 2000 -m trainer
done

It prints nothing.

Put dunscaith on the cluster

Build dunscaith into data/bin, where every node can see it:

GOBIN="$PWD/data/bin" CGO_ENABLED=0 go install gitlab.com/phpboyscout/dunscaith/cmd/dunscaith@main

This builds from the default branch. A release that links the Slurm adapter works too: put its tag in place of main. v0.1.0 does not link it. CGO_ENABLED=0 makes a binary that needs nothing from the node image. Allow a minute or two the first time. It prints only what Go downloads.

Open two shells on the login node

dunscaith runs on the node you'd log in to, which here is the controller. Open a shell there as trainer:

docker exec -it -u trainer -w /home/trainer -e USER=trainer -e HOME=/home/trainer sind-tutorial-controller bash

docker exec sets neither USER nor HOME, which a real login would, so the command sets them. Then put dunscaith on the path:

export PATH=/data/bin:$PATH

Now open a second terminal and do both again, so you have two shells on the login node. You'll want the second one later, and you won't have long to open it then. Everything from here to the clean-up is typed in one of the two.

Tell dunscaith about the cluster

In the first shell:

mkdir -p ~/.dunscaith
cat > ~/.dunscaith/config.yaml <<'EOF'
cluster:
  name: tutorial
  adapter: slurm
  config:
    output: {dir: /data/out}
record:
  root: /dev/shm/dunscaith-trainer
  ephemeral: true
supervise:
  poll: 5s
EOF

cluster.adapter: slurm is the setting that matters: it says which scheduler to drive. The rest is there because this cluster is made of containers:

  • output.dir puts each job's output on /data, because these nodes share /data and not their home directories.
  • record.root and record.ephemeral keep dunscaith's records of your jobs in memory. It refuses to keep them on a container's own disk. On a real login node they go on disk and you'd set neither. Choose a record backing has the detail.
  • supervise.poll has dunscaith look at a job every five seconds, not every thirty, so you aren't kept waiting.

Submit a job and watch it finish

A job is a file. This one prints five lines on each of two nodes:

cat > hello.yaml <<'EOF'
version: 1
name: hello
command: [srun, sh, -c, "for i in 1 2 3 4 5; do echo step $i on $(hostname); sleep 2; done"]
nodes: 2
gpusPerNode: 0
timeLimit: 10m
EOF
dunscaith submit hello.yaml

Slurm runs the command once, on the first of the job's nodes. srun is what starts it on both.

submit sends the job to Slurm and then stays, supervising it, until the job has an outcome. Here that's about fifteen seconds:

submitted 01M7DSS5QMB7WHEDTRPVAMEQZ6
  spec digest e71ec3ef88fc0839a660cc2c97db66e033f39582ea9ea8b6a2ea83af4ecc39a3
  uncovered: preempted, node-lost, out-of-memory, time-limit, non-zero-exit, launch-failed, no-capacity, requeued, unknown; each ends the job Failed with an escalation
  workDir: the backend's default
  procsPerNode: the backend's default
  records under /dev/shm/dunscaith-trainer do not survive a pod restart (record.ephemeral)
supervising 01M7DSS5QMB7WHEDTRPVAMEQZ6 in the foreground; it ends with this terminal unless run under tmux, screen or nohup
2026-11-14T19:50:50Z 01M7DSS5QMB7WHEDTRPVAMEQZ6: pending -> succeeded (none)
job 01M7DSS5QMB7WHEDTRPVAMEQZ6: succeeded (none)

The first line has the job's ID. Yours will differ, and you'll use it below. uncovered lists the ways a job can end that this file has no rule for. Any of them would end the job as failed, with a message saying so. The last line is the outcome.

The line before it goes straight from pending to succeeded. submit prints a line when the job's recorded state changes, and starting to run isn't one of those changes. status is where you see a job running, and you'll use it below.

Now look at what the job printed. Put your own job's ID in place of this one:

cat /data/out/01M7DSS5QMB7WHEDTRPVAMEQZ6/*.out
step 1 on worker-0
step 1 on worker-1
step 2 on worker-0
step 2 on worker-1
step 3 on worker-0
step 3 on worker-1
step 4 on worker-0
step 4 on worker-1
step 5 on worker-0
step 5 on worker-1

And list shows every job of yours, with the host that owns it, its last state and the cause:

dunscaith list
01M7DSS5QMB7WHEDTRPVAMEQZ6  controller   succeeded  none

Give a job a rule for being preempted

The second job runs for about eighty seconds, and it says what to do if Slurm takes its nodes away:

cat > train.yaml <<'EOF'
version: 1
name: train
command: [srun, sh, -c, "for i in $(seq 40); do echo step $i on $(hostname); sleep 2; done"]
nodes: 2
gpusPerNode: 0
timeLimit: 10m
recovery:
  rules:
    - on: [preempted]
      action: resubmit
      budget: 2
EOF
dunscaith submit train.yaml

The rule reads: when the job is preempted, send it to Slurm again as the same job, and do that at most twice.

submitted 01M7DSSNY9N24BW07JEEGDQ4HS
  spec digest d0ef40a9fdfbf7ed81245e865139165b7b209b3f0469a04876be58279a2e0d06
  rule 0: supervisor
  uncovered: node-lost, out-of-memory, time-limit, non-zero-exit, launch-failed, no-capacity, requeued, unknown; each ends the job Failed with an escalation
  workDir: the backend's default
  procsPerNode: the backend's default
  records under /dev/shm/dunscaith-trainer do not survive a pod restart (record.ephemeral)
supervising 01M7DSSNY9N24BW07JEEGDQ4HS in the foreground; it ends with this terminal unless run under tmux, screen or nohup

The receipt has a new line, rule 0: supervisor, and preempted has gone from uncovered. It's the supervisor, this submit, that will act on the rule. So leave it running, and move to the second shell before the eighty seconds are up. If the job finishes first, submit it again.

Look at the job while it runs

In the second shell, with your job's ID:

dunscaith status 01M7DSSNY9N24BW07JEEGDQ4HS
job       01M7DSSNY9N24BW07JEEGDQ4HS
state     running (none)
cleanup   clear
rule      [preempted] resubmit budget 2: supervisor
submission 1  canonical 4  executions 1  abandoned false
supervision supervised; last loop 2026-11-14T19:51:11Z
records do not survive a pod restart (record.ephemeral)

state is what the job is doing now. submission 1 is the first time it was sent to Slurm, and canonical is Slurm's own number for it. Slurm numbers every job it is given, the adapter's own probe jobs included, so yours may differ here and in the output below. The supervision line says the submit in your first shell is watching, and when it last looked.

Preempt it

Still in the second shell, send Slurm a job of its own. This one goes to the high partition and asks for both nodes, so Slurm has to take them from yours:

sbatch -p high -N 2 -J urgent -o /dev/null --wrap "srun sleep 20"
Submitted batch job 6

Give it a few seconds, then look at Slurm's queue:

squeue
             JOBID PARTITION     NAME     USER ST       TIME  NODES NODELIST(REASON)
                 6      high   urgent  trainer  R       0:03      2 worker-[0-1]
                 7      main dj-01M7D  trainer PD       0:00      2 (Resources)

urgent is running (R) on both workers. Below it is a job whose name starts dj-. That's yours, sent again by dunscaith and waiting (PD) for the nodes.

The first shell says the same thing. A line appeared within seconds of the preemption, and a second one once urgent had finished and your job had run to its end:

2026-11-14T19:51:16Z 01M7DSSNY9N24BW07JEEGDQ4HS: pending -> recovering (none)
2026-11-14T19:52:57Z 01M7DSSNY9N24BW07JEEGDQ4HS: recovering -> succeeded (none)
job 01M7DSSNY9N24BW07JEEGDQ4HS: succeeded (none)

See that it was one job, run twice

The job kept its ID. Its output directory has two sets of files, s1 for the first submission and s2 for the second:

ls /data/out/01M7DSSNY9N24BW07JEEGDQ4HS
s1-4-r0.err
s1-4-r0.out
s1-4.slurm
s1.manifest
s2-7-r0.err
s2-7-r0.out
s2-7.slurm
s2.manifest

Look at where each one stopped:

tail -n 2 /data/out/01M7DSSNY9N24BW07JEEGDQ4HS/s1-*.out /data/out/01M7DSSNY9N24BW07JEEGDQ4HS/s2-*.out
==> /data/out/01M7DSSNY9N24BW07JEEGDQ4HS/s1-4-r0.out <==
step 11 on worker-0
step 11 on worker-1

==> /data/out/01M7DSSNY9N24BW07JEEGDQ4HS/s2-7-r0.out <==
step 40 on worker-1
step 40 on worker-0

Here the first run had reached step 11 when Slurm stopped it. Yours will have got as far as it had when you preempted it. The second run went to step 40, and it started again from step 1: this job keeps no checkpoint, so there was nothing to pick up from.

Clean up

Type exit in both shells. Then, on your own machine, in dunscaith-tutorial:

docker exec sind-tutorial-controller sh -c 'rm -rf /data/out/*'
sind delete cluster tutorial
cd ..
rm -r dunscaith-tutorial

The first line is there because the jobs' output belongs to the cluster user, so your own rm couldn't remove it. This deletes the cluster and everything you made in this tutorial.

Where to go next