Startup scripts work only on Slurm clusters that run Slinky v1.0. To check which version your cluster runs, see Slurm configuration.
Script types at a glance
Scripts fall into three categories based on when they run. Node init scripts run once when a node starts up:- Worker init script: Runs on each Slurm worker at boot. Install system packages, configure drivers, or pull container images.
- Login init script: Runs on the login node at startup. Install CLI tools and packages for interactive SSH sessions.
- Worker prolog: Runs on each worker node before a job starts. Set up directories, load datasets into local scratch, or export environment variables.
- Worker epilog: Runs on each worker node after a job ends. Clean up scratch files, flush logs, or reset node state.
- Controller prolog: Runs on the Slurm controller (
slurmctld) at job allocation. Validate job parameters, send notifications, or log job metadata centrally. - Controller epilog: Runs on the Slurm controller (
slurmctld) at job completion. Log results, trigger downstream pipelines, or send completion notifications.
- Extra slurm.conf: Custom lines appended to
slurm.confon all nodes. Use this for scheduler tuning, prolog flags, or partition overrides.
Node init scripts
Worker init script
Runs on each Slurm worker node at boot, before the node accepts jobs. Use it to install packages or configure the environment that all jobs on this node depend on. Common use cases:- Install system packages (
apt-get install -y sox ffmpeg). - Install the AWS CLI or other data-transfer tools.
- Pull container images or download shared assets.
- Configure environment variables that apply to every job.
Login init script
Runs on the login node at startup. The login node is where users SSH in to submit jobs and inspect results, so this script installs tools for interactive use. Common use cases:- Install CLI utilities for data exploration.
- Set up shared Python environments.
- Configure shell defaults for all users.
Job lifecycle scripts
Worker prolog
Runs as root on each allocated worker node before any user processes launch. Common use cases:- Create per-job scratch directories on local NVMe.
- Stage input data from shared storage to local disk.
- Export environment variables for the job.
- Verify GPU health before the job runs.
The worker prolog runs when the job is allocated, because the cluster’s default
PrologFlags=Contain implies Alloc. A PrologFlags line in Extra slurm.conf replaces that default rather than adding to it, so keep Contain in yours (for example, PrologFlags=Alloc,Contain).Worker epilog
Runs on each allocated worker node after the job ends. The script runs as root and executes after all user processes have terminated. Common use cases:- Remove per-job scratch directories.
- Flush job logs to shared storage.
- Reset GPU state or clear shared memory.
- Kill orphaned processes.
Controller prolog
Runs on the Slurm controller (slurmctld) at job allocation, before the job reaches the worker nodes. Use this for centralized setup that does not need to run on every node.
Common use cases:
- Log job metadata to a central database.
- Send a Slack or webhook notification when a job starts.
- Validate job parameters before workers are assigned.
Controller epilog
Runs on the Slurm controller (slurmctld) at job completion. Use this for centralized teardown or post-job automation.
Common use cases:
- Log job completion and exit status.
- Trigger a downstream pipeline (fine-tuning, evaluation, deployment).
- Send a completion notification.
Extra slurm.conf
Adds your lines verbatim toslurm.conf on all nodes, after the default configuration.
Common use cases:
- Add partitions or raise limits such as
MaxArraySize. - Tune scheduler parameters.
- Configure accounting or job completion plugins.
View configured startup scripts
Configured scripts appear on the cluster details page as.sh files (and extra_slurm.conf for the extra configuration block). Select a file name to open a read-only dialog with the script contents and a copy button.
Add startup scripts to a new cluster
- On the GPU clusters page, select Create cluster and set Orchestration to Slurm.
- Under Cluster add-ons, set Startup Scripts to Yes. The text boxes below the toggle become editable.
- Enter each script you need in its text box (Worker Prolog, Worker Epilog, Login Init Script, Worker Init Script, Extra slurm.conf, Controller Prolog, or Controller Epilog). Each script can be up to 64 KB. Every script except Extra slurm.conf must start with
#!/bin/bash,#!/usr/bin/env bash,#!/bin/sh, or#!/usr/bin/env sh. - Complete the rest of the form, select Create Cluster, and then select Confirm & Create.
Update startup scripts on an existing cluster
To update scripts in the console:- On the cluster details page, select Edit Configuration.
- Change the scripts, and then select Save.
cluster_config.slurm_startup_scripts to the cluster update API. The API also requires cluster_config.load_balancer in the same request.
When a change takes effect depends on the script type:
- Extra slurm.conf: Takes effect on the running cluster through a live
scontrol reconfigure. Workers briefly re-register with the controller, but running jobs aren’t interrupted. - Prolog and epilog scripts: Take effect on a worker only when its pod restarts, because each worker fetches its scripts through Slurm’s configless mechanism at pod startup. Until then, new jobs on that worker keep using the old scripts, even though the underlying ConfigMaps update immediately. To apply the update without ending running jobs, drain the workers, wait for their jobs to finish, and then restart their pods with
kubectl delete pods -n slurm -l app.kubernetes.io/name=slurmd. - Init scripts: Take effect the next time each worker or login pod starts or restarts, because init scripts run at pod startup.
Failure handling
Script failures have different consequences depending on which script fails. Worker prolog failure (non-zero exit):- The node is set to
DRAINstate. - The job is requeued (batch jobs only). Interactive jobs (
salloc,srun) are cancelled.
- The node is set to
DRAINstate. - A drained node does not accept new jobs until an admin resumes it.
- The job is requeued (batch jobs) or cancelled (interactive jobs).
- The node is not affected.
- The failure is logged but has no other effect on the job or node.
Best practices
- Keep scripts short and fast, because long-running scripts delay job scheduling.
- Use
set -ein init scripts so the script stops at the first failed command instead of continuing silently. - Don’t call Slurm commands such as
squeue,scontrol, orsacctmgrfrom prolog or epilog scripts. They can cause deadlocks and degrade scheduler performance. - Use the
SLURM_JOB_IDandSLURM_JOB_USERenvironment variables to scope cleanup and logging to the correct job.
Troubleshooting
Node stuck in DRAIN state after script failure
A worker prolog or epilog that returns a non-zero exit code drains the node. Fix:-
Find the drained node with
sinfo -R. -
Check that worker’s slurmd log (
/var/log/slurm/slurmd.log) for the script’s error. - Fix the script.
-
As a project admin, resume the node from the login node:
Init script packages not available in jobs
The worker init script runs at node boot, not at job start. If the script’s package install fails silently, jobs on that node don’t have the expected tools. Fix:- SSH into a worker node and verify the package is installed.
- Add
set -eto your init script to catch failures.