Guide · SLURM · VASP · 14 min read
How do I fix a job that ran out of memory or walltime?
Checked against the docs · SLURM documentation 26.05 and VASP wiki · Last checked 11 November 2026 · Spot a mistake? Tell us
Short answer
Ask sacct how the job ended. OUT_OF_MEMORY means it needed more memory than it had; ask for more per node with --mem, spread the job over more nodes, put fewer ranks on each node, or (in VASP) lower KPAR and raise NCORE. TIMEOUT means it reached its walltime; continue from where it stopped (in VASP, copy CONTCAR to POSCAR) with a longer walltime, within the partition's limit.
Which one was it?
A job on a SLURM cluster gets two budgets when it starts: an amount of memory (the RAM its processes may hold, per node or per core) and a walltime (the longest it may run, by the clock on the wall). Run past either and SLURM ends the job. They look alike from the outside, a job that stopped without finishing, but they have different fixes, so the first step is to know which one it was.
Ask SLURM's accounting record, from the login node:
sacct -j 123456 --format=JobID,JobName,State,Elapsed,Timelimit,ReqMem,MaxRSS,ExitCode(The job id is an example.) The State column says how each part of the job ended:
OUT_OF_MEMORY: in the SLURM docs' words, the job "experienced out of memory error".TIMEOUT: "terminated due to reaching the time limit".
The other columns tell you by how much:
ElapsedagainstTimelimit: how long it ran against how long it was allowed. For aTIMEOUTthey are the same, or nearly.MaxRSSagainstReqMem: the largest resident set size (the memory actually held in RAM) of the job's tasks, against the memory the job asked for.
sacct prints one line for the job and one per step (each srun in the script, plus the batch step that runs the script itself). Read every line: one step can end OUT_OF_MEMORY while another says something else.
The job's own log helps too. Each of these failures has its own page with the messages to look for: the job ran out of memory and the job was canceled at its time limit.
Why do these two cost so much?
Walltime is lost work. When the time limit is reached, the SLURM docs say every task is sent a signal to stop (SIGTERM), then killed (SIGKILL) a short interval later (30 seconds unless the site sets KillWait differently). Your program has seconds to tidy up, and anything since its last saved point is gone. You also waited in the queue for it. A job that runs out of time at hour 47 of 48 costs almost the whole allocation.
Memory ends the job wherever it is. A job that crosses its memory limit is stopped at that moment, after the whole wait in the queue and whatever it had done since its last saved point. The SLURM docs also warn that a job exceeding its memory can affect other processes and the machine's health, which is why sites enforce the limit.
Neither is a mistake in your science. The calculation can be right and still not fit. The fix is in the request, the parallel setup, or how the run is split up.
How much memory does my job get?
You ask for memory in the job script in one of two ways (they cannot be combined):
| Option | What it asks for | When it fits |
|---|---|---|
--mem=<size> | Memory per node. | Clusters that give out whole nodes. |
--mem-per-cpu=<size> | Memory per allocated CPU (core). | Clusters that give out individual cores. |
The size is in mebibytes unless you add a unit: --mem=120G, --mem-per-cpu=3800M. --mem=0 is a special case that gives the job all the memory on each node.
If you ask for nothing, the site decides. The defaults come from the cluster's configuration (DefMemPerNode or DefMemPerCPU, which can also be set per partition), with maximums MaxMemPerNode and MaxMemPerCPU. The configuration's own default for each is 0, meaning unlimited, but your site may set them, so a job that asks for nothing can get much less than the node has. To see what yours does:
scontrol show config | grep -i mem # the cluster-wide defaults and maximums
scontrol show partition standard # a partition's own settings (the name is an example)
sinfo -o "%P %c %m" # each partition's CPUs and memory per node, in MiBThree details from the sbatch page that catch people:
- With
--mem-per-cpu, the CPUs allocated count, not the tasks. If the cluster allocates whole cores, sockets or nodes, a job can be given more CPUs than it has tasks, and its memory is per CPU allocated. - SLURM's own helper counts. The
slurmstepdprocess that SLURM runs beside each step is included in the job's memory use, typically 20 to 200 MiB. - Enforcement is a site setting. Memory limits are only strictly enforced if the cluster is configured to (with cgroups, or
OverMemoryKill). On a cluster that does not enforce them, a job that uses too much is not stopped by SLURM at its limit, and can run the node itself short of memory.
How much memory does VASP need, and how do nodes and tasks change it?
VASP tells you. The VASP wiki's Not enough memory page points to the line in OUTCAR where VASP reports the memory one rank uses (a rank is one MPI process, one copy of VASP; usually one per core):
grep "total amount of memory used by VASP MPI-rank0" OUTCARBelow it, VASP breaks the amount down: wavefun (the wavefunctions, the orbitals), nonlr-proj (the non-local projectors), grid (charge density, potentials and other 3D arrays), fftplans and base (the program and its libraries). The wiki says the wavefunctions are usually the largest part. That number is for rank 0; take it as a guide to what each rank holds.
What grows the memory. The wiki's Memory requirements page gives the wavefunctions' size as NKDIM × NBANDS × NRPLWV × 16 bytes: the number of k-points, times the number of bands, times the number of plane waves per band, times 16 bytes per complex number. So a bigger cell (more bands and more plane waves), a higher ENCUT (more plane waves) and a denser k-point mesh (more k-points) all raise it.
How the request changes it. Memory per node is, roughly, the ranks on that node times the memory each rank needs. The wiki's guidance gives the levers:
- More ranks share the work. "By increasing the number of cores, the memory requirements per core can be reduced significantly." Spreading a job over more nodes, with the same ranks per node, gives each rank less to hold and the job more memory in total.
- Fewer ranks per node leave each rank more of the node's memory. It helps most when the parts every rank holds a full copy of fill the node; it costs speed, because cores sit idle. The wiki does not say when this helps more than adding a node; a short test of each on your system settles it.
KPARmultiplies memory.KPARsplits the ranks into groups that each work on their own k-points. The wiki: only the calculation is distributed, not the storage of the orbitals, soKPAR = 1gives the smallest memory per core. The KPAR page says the same: the data is not distributed additionally over k-points.NCORElowers memory. With a largerNCORE(more ranks working together on each band), the projectors are shared within each group instead of stored in full on every rank. The wiki suggests raising it for large cells ("say to 4, 8 potentially to or even beyond the number of cores per node").LREAL = Auto(projection in real space) also lowers the memory per core. The LREAL page recommends it for cells of more than about 30 atoms, and only theAutosetting.- scaLAPACK (a parallel linear-algebra library VASP can be built with) spreads a matrix of size
NBANDS × NBANDSover the ranks working on one k-point; without it, every rank stores the whole matrix. Whether your build uses it is a question for whoever compiled VASP on your cluster.
How do I use my cores well in VASP? explains NCORE and KPAR in full.
What should I change first?
Start from what sacct said. These are starting points, in the order that usually costs least.
If it ran out of memory (OUT_OF_MEMORY):
| Try | How | What it costs |
|---|---|---|
| 1. Ask for the memory the node has | On a whole-node cluster, --mem=0 (all of it) or a --mem close to the node's memory from sinfo -o "%P %m". If you used --mem-per-cpu, raise it within MaxMemPerCPU. | Nothing, if the node had more than the default gave you. |
2. Lower KPAR (VASP) | KPAR = 1 uses the least memory per core. | Speed, if the k-point parallelism was helping. |
3. Raise NCORE (VASP) | A factor of the cores per node, larger than before. | Little: for large cells the wiki says it can also be faster. |
4. LREAL = Auto (VASP, cells over about 30 atoms) | In the INCAR. | The wiki: a change in the energy of up to 1 meV per atom; keep one setting for every run you compare. |
| 5. Add nodes | --nodes=2 with the same --ntasks-per-node. | More core-hours from your allocation; a larger request may wait longer. |
| 6. Fewer ranks per node | Lower --ntasks-per-node; keep NCORE a factor of it. | Idle cores, which many clusters charge for anyway. |
| 7. A large-memory partition | --partition= your cluster's large-memory partition. | Often a longer wait, sometimes a higher charge. |
If it ran out of walltime (TIMEOUT): continue from where it stopped (next section), with a walltime sized from how far it got. If the job needs more time than the partition allows, either split it into shorter jobs that each continue from the last, or use a partition with a longer limit.
Size the walltime from the run itself. Look at how long one step took and how many steps are left. The VASP wiki suggests watching the LOOP+ timer, which times each ionic step including the forces:
grep LOOP+ OUTCAR | tail -3Multiply a typical step's time by the steps you expect, and add a margin. Then compare with the partition's limit (sinfo -o "%P %l"): a request over it never starts (see Why is my job still waiting?).
What it depends on:
- The cluster's memory model: whole nodes (
--mem) or individual cores (--mem-per-cpu), and its defaults. - The size of the calculation: cell,
ENCUT, k-points and bands set what VASP must hold. - The parallel setup:
KPAR,NCOREand the ranks per node decide how it is spread. - The partition's limits: its memory per node and its maximum walltime.
How do I continue a VASP job that ran out of walltime?
Your positions are safe. The VASP wiki says CONTCAR is written after each ionic step, in the same format as POSCAR, so a relaxation stopped by SLURM still has its last positions. For a relaxation that has not converged, the wiki says to copy CONTCAR to POSCAR before continuing. Keep the old files: continue in a new folder.
mkdir ../TiO2-relax-2
cp INCAR KPOINTS POTCAR job.sh ../TiO2-relax-2/
cp CONTCAR ../TiO2-relax-2/POSCAR(The folder names are examples.) For molecular dynamics, CONTCAR also holds the velocities and the predictor-corrector coordinates needed to continue; the wiki warns that to continue in a different ensemble, the predictor-corrector block must be removed, or the run crashes.
The wavefunctions may not be. The LWAVE page says the wavefunctions are written to WAVECAR at the end of a run. A job SLURM stopped did not reach its end, so its WAVECAR may be missing or left from an earlier point. Without a usable WAVECAR, the ISTART page says VASP falls back to starting the orbitals from scratch (ISTART = 0). Whether to reuse WAVECAR and CHGCAR, and which ISTART to set when the cell has changed, are in Should I start fresh or continue a run?.
Stop it yourself next time. If you can see a job will not finish in time, write a STOPCAR file in its run folder:
echo "LSTOP = .TRUE." > STOPCARThe wiki says VASP then stops at the next ionic step. (LABORT = .TRUE. stops at the next electronic step instead, so WAVECAR and CHGCAR might hold unconverged results; the wiki says to use LSTOP where possible.)
You cannot extend a running job yourself. The scontrol docs say only a privileged user can increase a running job's time limit. If a long job is close to its end, ask your cluster's administrators; otherwise let it stop and continue it.
For LAMMPS, the same idea uses restart files: see How do I keep long LAMMPS runs safe?.
How do I know the fix worked?
- The new job ended
COMPLETED.sacct -j <new job id> --format=JobID,State,Elapsed,Timelimit,ReqMem,MaxRSSagain. - It had room.
MaxRSSwell underReqMem(rememberReqMemmay be per node or per CPU, andMaxRSSis per task);Elapsedwell underTimelimit. - VASP agrees. The memory line in
OUTCARtimes the ranks per node fits the node's memory with a margin. - A continued run started where the last one stopped. Its first
POSCARmatches the oldCONTCAR, and its first energies continue the old run's rather than starting over.
COMPLETED only means the job's exit code was zero on all nodes; read VASP's own output to know whether the relaxation converged.
What goes wrong?
| Mistake | What you would see | What to do |
|---|---|---|
| Relying on the cluster's default memory | OUT_OF_MEMORY soon after the start, though the node has plenty. | Ask for memory explicitly: --mem per node, or --mem-per-cpu. |
A large KPAR on a big cell | OUT_OF_MEMORY; the OUTCAR memory line grows with KPAR. | KPAR = 1 or 2, and compare the memory line. |
Mixing --mem and --mem-per-cpu | A request SLURM cannot honour: the sbatch docs call the options mutually exclusive. | Use one. |
| Asking for more memory than any node has | The job is rejected, or waits. The docs: if the memory can't be satisfied by any node in the partition, the job is rejected. | Check the nodes' memory with sinfo -o "%P %m"; use a large-memory partition. |
Continuing from the original POSCAR after a TIMEOUT | The relaxation starts again from the beginning. | Copy CONTCAR to POSCAR in a new folder. |
| Resubmitting with the same walltime | A second TIMEOUT at the same point. | Size the walltime from LOOP+ and the steps left, or split the run. |
| A walltime over the partition's limit | The job waits with (PartitionTimeLimit), possibly for ever. | Stay within the limit, or change partition. |
Assuming TIMEOUT lost everything | Starting from scratch, wasting the hours already run. | Check CONTCAR: it is written after every ionic step. |
Try it
Try it: find the line that asks for the wrong amount
Each job script below should ask for what its comment line says the job needs, and one #SBATCH line gets it wrong. Choose the line you think it is. The answers come from the sbatch manual; the job and program names are examples.
Script 1.
#!/bin/bash
# needs ten hours
#SBATCH --job-name=fe-relax
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=32
#SBATCH --time=10:00
srun vasp_stdThe problem is line 6, #SBATCH --time=10:00: sbatch reads 10:00 as minutes:seconds, so this asks for ten minutes. The formats it accepts are minutes, minutes:seconds, hours:minutes:seconds, days-hours, days-hours:minutes and days-hours:minutes:seconds. When the limit is reached, each task is sent SIGTERM and then SIGKILL. #SBATCH --time=10:00:00.
Script 2.
#!/bin/bash
# needs about 64 GB on its node
#SBATCH --job-name=fe-relax
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=32
#SBATCH --mem=64
srun vasp_stdThe problem is line 6, #SBATCH --mem=64: --mem is the memory per node, and its default unit is mebibytes, so --mem=64 asks for 64 MiB. Other units take a suffix: K, M, G or T. #SBATCH --mem=64G.
Script 3.
#!/bin/bash
# needs about 64 GB on its node
#SBATCH --job-name=fe-relax
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=32
#SBATCH --mem=64G
#SBATCH --mem-per-cpu=2G
srun vasp_stdThe problem is line 7, #SBATCH --mem-per-cpu=2G: The manual says --mem, --mem-per-cpu and --mem-per-gpu are mutually exclusive. --mem is per node; --mem-per-cpu is per allocated CPU. Delete the --mem-per-cpu line: --mem=64G already asks for what the comment says.
Before you submit, pre-flight checks your resources. When a job stops because it ran out of memory or walltime, Monitor says which, from the job's log, and Continue from here starts a new run from where the old one stopped, with its restart files.