oliviercoen
02/02/2026, 11:49 AM.
├── test.nf
├── test.config
└── bin/
└── test.sh
with:
• test.nf
#!/usr/bin/env nextflow
process shouldThrowOOM {
cpus 4
memory '1 GB'
conda "conda-forge::python=3.14.2"
container "${ workflow.containerEngine in ['singularity', 'apptainer'] && !task.ext.singularity_pull_docker_container ?
'<https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/24/24d21af99eae8df9f2347bc7b137c8f10ccc905211c8a4e08761af491f3dd884/data>':
'community.wave.seqera.io/library/python:3.14.2--41251566046f8583' }"
input:
script:
"""
test.sh
"""
}
workflow {
shouldThrowOOM( )
}
• test.config
profiles {
conda {
conda.enabled = true
docker.enabled = false
singularity.enabled = false
podman.enabled = false
shifter.enabled = false
charliecloud.enabled = false
conda.channels = ['conda-forge', 'bioconda']
apptainer.enabled = false
}
docker {
docker.enabled = true
conda.enabled = false
singularity.enabled = false
podman.enabled = false
shifter.enabled = false
charliecloud.enabled = false
apptainer.enabled = false
docker.runOptions = '-u $(id -u):$(id -g)'
}
singularity {
singularity.enabled = true
singularity.autoMounts = true
conda.enabled = false
docker.enabled = false
podman.enabled = false
shifter.enabled = false
charliecloud.enabled = false
apptainer.enabled = false
}
apptainer {
apptainer.enabled = true
apptainer.autoMounts = true
conda.enabled = false
docker.enabled = false
singularity.enabled = false
podman.enabled = false
shifter.enabled = false
charliecloud.enabled = false
}
}
• test.sh
#!/usr/bin/env python3
from multiprocessing import Pool
def worker(num):
return num * 2
if __name__ == '__main__':
with Pool(processes=10) as pool:
pool.map(worker, range(3 * int(1E8)))
I made on purpose a python script that should take more than 1GB, while I am allocating only 1GB to the process.
Results:
If I run test.nf with docker:
nextflow run <http://test.nf|test.nf> -c test.config -profile docker
the run fails with an OOM (error 137).
If I run it with conda:
nextflow run <http://test.nf|test.nf> -c test.config -profile conda
it succeeds but it takes like 10GB of RAM (seen with htop). It's "normal" since you cannot basically limit resource allocation with a process launched through conda. Although ideally it's be really nice to able to do that.
I would expect apptainer to behave similarly to docker, since it's a container engine.
However, when I run test.nf with apptainer or singularity:
nextflow run <http://test.nf|test.nf> -c test.config -profile <apptainer / singularity>
the behaviour is the same as for conda!! It does not fail but consumes a lot of RAM to run the process.
I saw the same problem but for the number of CPUs used by a process when I ran apptainer.
Do you know what is happening? Should we add additional arguments when using apptainer / singularity?
Thanks a lotNiklas Schandry
02/02/2026, 12:04 PMNiklas Schandry
02/02/2026, 12:05 PM--memory ${task.memory} in the runOptionsNiklas Schandry
02/02/2026, 12:06 PMNiklas Schandry
02/02/2026, 12:09 PMoliviercoen
02/02/2026, 12:12 PMoliviercoen
02/02/2026, 12:15 PMapptainer exec \
--cpus 4 \
--memory 1GB \
<https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/24/24d21af99eae8df9f2347bc7b137c8f10ccc905211c8a4e08761af491f3dd884/data> bin/test.sh
it does raise an OOM, so the problem comes from NextflowNiklas Schandry
02/02/2026, 12:16 PM--memory ${task.memory} in apptainer.runOptions ?Niklas Schandry
02/02/2026, 12:16 PMNiklas Schandry
02/02/2026, 12:16 PMoliviercoen
02/02/2026, 12:17 PMNiklas Schandry
02/02/2026, 12:17 PM--cpus ${task.cpus}Niklas Schandry
02/02/2026, 12:17 PMNiklas Schandry
02/02/2026, 12:17 PMJames Fellows Yates
02/02/2026, 12:18 PMJames Fellows Yates
02/02/2026, 12:18 PMlocal exececutorJames Fellows Yates
02/02/2026, 12:18 PMdocker/podman does have better limitations, implying other container engines does notNiklas Schandry
02/02/2026, 12:19 PMNiklas Schandry
02/02/2026, 12:19 PMoliviercoen
02/02/2026, 12:20 PMNiklas Schandry
02/02/2026, 12:20 PMNiklas Schandry
02/02/2026, 12:21 PMoliviercoen
02/02/2026, 12:22 PMNiklas Schandry
02/02/2026, 12:22 PMNiklas Schandry
02/02/2026, 12:23 PMrunOptionsNiklas Schandry
02/02/2026, 12:24 PMNiklas Schandry
02/02/2026, 12:25 PMapptainer --memory throws an erroroliviercoen
02/02/2026, 12:26 PMoliviercoen
02/02/2026, 12:26 PMEvangelos Karatzas
02/02/2026, 12:27 PMEvangelos Karatzas
02/02/2026, 12:28 PMNiklas Schandry
02/02/2026, 12:29 PMNiklas Schandry
02/02/2026, 12:35 PMoliviercoen
02/02/2026, 12:43 PMNiklas Schandry
02/02/2026, 12:59 PMBen Sherman
02/02/2026, 5:54 PM/proc, but we never felt that it was worth doing. OOM killers are tricky to get right
Also because you can just run the local task with Docker or Podman and get that behavior
Looking at the Nextflow codebase, it seems DockerBuilder is adding the --memory option whereas SingularityBuilder / ApptainerBuilder are not
So if it's as simple as adding --memory to the apptainer command generated by Nextflow, then let's do itBen Sherman
02/02/2026, 5:55 PMNiklas Schandry
02/02/2026, 6:15 PM--memory to apptainer would be good, but having it always would cause problems for me. I'm using unprivileged apptainer with slurm,. apptainer uses cgroups for memory which I cannot dopontus
02/02/2026, 6:50 PMpontus
02/02/2026, 6:52 PMBen Sherman
02/02/2026, 6:59 PMexecutor.$apptainer.memoryLimits to make it opt-inoliviercoen
02/02/2026, 7:12 PM