Running Spine Toolbox projects on HPC systems

Introduction

This tutorial demonstrates how to run Spine Toolbox project involving GAMS workflows on a High-Performance Computing (HPC) system using the Slurm scheduler.

The guide assumes you have access to a Linux-based HPC cluster with a shared filesystem and Slurm installed. You also need basic familiarity with the Linux command line and a valid GAMS license for real use cases. However, this tutorial can be completed with a demo license for GAMS.

You will learn the full workflow:

Local machine → Cluster login → Upload files → Submit job → Monitor → Retrieve results

HPC without container support

If your HPC system does not provide Apptainer, the recommended first step is to contact your HPC support or administration team and request that Apptainer be installed. It is widely supported on HPC systems and is the preferred approach for running reproducible containerized workflows.

If installing Apptainer is not possible, you can still run Spine Toolbox projects directly on the HPC environment. In this case, you must ensure that all required software (e.g., GAMS) is available and correctly configured in your environment.

Verifying GAMS installation

First, check whether GAMS is available:

gams ?

If GAMS is installed correctly, this command prints version and usage information.

Accessing GAMS on HPC

Option 1: Using a module

Many HPC systems provide GAMS via environment modules:

module avail gams
module load gams

Verify that GAMS is available:

which gams

Option 2: User installation

If GAMS is not provided by your HPC:

  1. Download the Linux version from the GAMS website

  2. Extract it into your home or project directory

  3. Add it to your PATH:

export PATH=$HOME/gams:$PATH

Ensure that your license file (e.g., gamslice.txt) is available.

Running Spine Toolbox without Apptainer

When running without containers, Spine Toolbox executes directly in the HPC environment. This means:

  • All required tools (GAMS and any dependencies) must be installed and available in your environment

  • Paths to executables must be correctly configured

  • Environment variables (e.g., PATH) must be set before running jobs

A minimal Slurm workflow follows the same structure as the container-based approach, but without the apptainer exec command.

Example Slurm script

#!/bin/bash
#SBATCH --job-name=spinetoolbox_no_container
#SBATCH --output=logs/%j.log
#SBATCH --error=logs/%j.log
#SBATCH --time=00:30:00
#SBATCH --cpus-per-task=1
#SBATCH --mem=4G

set -euo pipefail

PROJECT_DIR="$HOME/spinetoolbox/projects/gams_on_hpc_tutorial"

echo "Running Spine Toolbox without container..."

# Load modules if needed (example)
# module load gams
# module load python

# Ensure required tools are available
which gams
which spinetoolbox

# Run Spine Toolbox project
spinetoolbox --execute-only "$PROJECT_DIR"

echo "Run completed successfully."

Ensure that:

  • The spinetoolbox command is available in your environment

  • The GAMS executable is discoverable (i.e., which gams works)

  • Any required input files and licenses are accessible

Note

Running without containers may lead to differences in behavior across systems due to variations in installed software and libraries. Using Apptainer is strongly recommended whenever possible for reproducibility.

Common Issues and Troubleshooting

Error on sbatch

If you see the following error when trying to run sbatch run_on_hpc.sh:

sbatch: error: Batch script contains DOS line breaks (\r\n)
sbatch: error: instead of expected UNIX line breaks (\n).

You need to change the line endings into Unix/Linux line breaks. You can do this in your hpc with the command:

dos2unix run_on_hpc.sh

License Errors

  • Ensure license file is accessible on compute nodes

  • Check environment variables if needed:

export GAMSLICE=/path/to/gamslice.txt

File Not Found

  • Verify paths are correct relative to the SLURM working directory

  • Use:

echo $PWD

Job Stuck in Queue

  • Cluster is full

  • Resource request too large

Memory Errors

Increase memory:

#SBATCH --mem=16G