• Home
  • Accessing Our Facilities
    • Apply for Access
    • HPC Resource List
    • Our Staff
    • Our Research Projects
    • Our Research Software

    • Contributions & Costings
    • HPC Driving Test
  • Documentation
    • Documentation Home
    • Getting Started
    • Advanced Topics
    • Training & Workshops
    • FAQ
    • Policies & Procedures
    • Using the Wiki

    • Data & Report Terminology
    • About this website

    • Reports
  • My Account
    • My HPC Projects
HPC Support
Trace: • gaussian • samplecontainers

Sample Container Definitions

This page provides a number of sample Apptainer definition files which you may wish to make use of when developing your own container solutions for Comet if an option is not already in our software pages or directly named in our software and existing containers list.

Please ensure that you read the Apptainer guide for Comet first.

Remember to set the APPTAINER_TMPDIR variable before creating a container:

$ export APPTAINER_TMPDIR=/scratch/

This ensures that temporary files are created under /scratch on the local drive, so it should be (a) faster, and (b) not run out of space by using the system /tmp directory.

Generic Container Helper

You can customise this helper script (which we will call helper.sh for simplicity) for any container image you create - just adjust the path and filename to your image.

#!/bin/bash
module load apptainer
IMAGE_NAME=/path/to/your/container.sif

container.run() {
    # Run a command inside the container...
    # automatically bind the /scratch and /nobackup dirs
    # pass through any additional parameters given on the command line
    apptainer exec --nv --bind /scratch:/scratch --bind /nobackup:/nobackup ${IMAGE_NAME} $@
}

We always recommend using the container helper to run applications inside the container, as you don't then have to remember all of the various apptainer exec options each time. To run my_app from inside your container, then just:

$ source helper.sh
$ container.run my_app


Ubuntu LTS

This uses the officially published Ubuntu docker image. This uses Ubuntu Noble - or 24 LTS. Multiple versions of Ubuntu are available; see the listed tags: https://hub.docker.com/_/ubuntu

Bootstrap: docker
From: ubuntu:noble

%post
	# Prevent interactive prompts
	export DEBIAN_FRONTEND=noninteractive

	# Update & install only necessary packages
	apt-get update
    
	# Base stuff everything will need
	apt-get install -y aptitude wget zip git less vim
	
	# Remove any downloaded package files - so they don't remain in the built image	
	apt-get clean
%environment

%runscript

Build as:

$ module load apptainer
$ apptainer build ubuntu.sif ubuntu.def

The base image size as defined above is ~120MB as the default image is very basic.


Ubuntu LTS with Development Tools

This uses the officially published Ubuntu docker image and adds C, C++, Fortran and Python development tools. Multiple versions of Ubuntu are available; see the listed tags: https://hub.docker.com/_/ubuntu

This example also ensures that compilers are using the most updated version and are configured to generate code tuned for the AMD Epyc CPU architecture of Comet.

If you are compiling software from C or C++ source code, then we would always recommend using GCC 14 using the supplied CFLAGS parameters to generate the most optimal binaries for Comet.

Bootstrap: docker
From: ubuntu:noble

%post
	# Prevent interactive prompts
	export DEBIAN_FRONTEND=noninteractive

	# Update & install only necessary packages
	apt-get update
    
	# Base stuff everything will need
	apt-get install -y aptitude wget zip git less vim apt-utils autoconf automake build-essential cmake gcc-14 g++-14 gfortran-14 git less unzip vim wget python3 python3-pip

	# For anything we compile during the image build
	export CFLAGS="-O3 -march=znver5 -pipe"
	export CXXFLAGS="-O3 -march=znver5 -pipe"

	update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 20
	update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 20
	update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-14 20
		
	# Remove any downloaded package files and any Python cached packages - so they don't remain in the built image	
	apt-get clean
	pip3 cache purge

%environment
	# For anything we build after the image is created using the installed compilers
	export CFLAGS="-O3 -march=znver5 -pipe"
	export CXXFLAGS="-O3 -march=znver5 -pipe"

%runscript

Build as:

$ module load apptainer
$ apptainer build ubuntu_dev.sif ubuntu_dev.def

The final image size as defined above is ~350MB with the additional software included over the base image.


Nvidia CUDA/CUDNN

This uses the official Nvidia docker image (itself based on top of Ubuntu LTS). There are multiple versions available, see the tags list at: https://hub.docker.com/r/nvidia/cuda

Bootstrap: docker
From: nvidia/cuda:12.8.1-cudnn-devel-ubuntu24.04

%post
   export DEBIAN_FRONTEND=noninteractive
   apt-get update
   apt-get install -y aptitude wget zip git less vim
   apt-get clean		
%environment

%runscript

The base Nvidia image already includes most of the development tools (Python, GCC) and libraries, hence the lack of additional software in the apt-get line.

Build as:

$ module load apptainer
$ apptainer build nvidia_cuda.sif nvidia_cuda.def

Final image size is approximately 5.9GB.


Back to Software

Previous Next

HPC Support

Table of Contents

Table of Contents

  • Sample Container Definitions
      • Generic Container Helper
    • Ubuntu LTS
    • Ubuntu LTS with Development Tools
    • Nvidia CUDA/CUDNN

HPC Service

  • News & Changes

Main Content Sections

  • Documentation Home
  • Getting Started
  • Advanced Topics
  • Training & Workshops
  • FAQ
  • Policies & Procedures
  • Using the Wiki
  • Contact us & Get Help

Documentation Tools

  • Wiki Login
  • RSE-HPC Team Area
Developed and operated by
Research Software Engineering
Copyright © Newcastle University
Contact us @rseteam