How to use Quantum ESPRESSO Apptainer image?
In preamble, you need to have Apptainer installed on your machine; see this link for more details.
This tutorial focuses on using the Quantum Espresso container image available at this address. By following this link, you will get an Apptainer image (.sif
file format) allowing you to create containers running Quantum Espresso.
For more information on Apptainer containers, please look at this page.
To have a quick look at Apptainer’s main commands, you may refer to this tutorial.
This image is a relocatable and renamable file we recommend putting in a dedicated directory to easily find it. While it can be any directory, in this tutorial we will assume you put it in $HOME/apptainer-images
:
To illustrate the different commands, a set of Quantum Espresso input files is available in the form of an archive via this link. The archive contains the necessary files to perform an energy calculation for an organic system containing carbon, magnesium, sulfur, nitrogen, and hydrogen. The files are as follows:
qe-tutorial.in
is the main input file for Quantum Espresso, containing the parameters necessary to perform the calculation. The atom positions as well as the definition of the simulation box are also in this file. Finally, we specify where to find the pseudopotentials to describe the exchange-correlation interactions within the system (see below).- The
pseudo
directory contains the pseudopotential file to model interactions between Silicon atoms in the system (Si.pz-vbc.UPF
).
In this tutorial, we will assume that the input files contained in this archive are in the current directory:
Disclaimer
The commands presented here are for using the
pw.x
executable of Quantum Espresso. This is also the executable called by default by theapptainer run
command. In the case where you want to call another executable, it is necessary to useapptainer exec <options> <image> <executable-name>
.
One liner command
For impatient folks, here is how to launch a parallel Quantum Espresso computation using the container image (previously downloaded and stored in $HOME/apptainer-images/quantum-espresso.sif
). In the case where the current directory contains all mandatory Quantum Espresso input files:
Detailed usage for the Quantum Espresso container
This section presents different ways to use the Quantum Espresso image. For more details about Apptainer commands, please look at this tutorial.
Using the Quantum Espresso container
To run Quantum Espresso without any container, one would use the following command:
where all Quantum Espresso input files (including qe-tutorial.in
, the main input) are stored in the current directory.
To do the same inside a container, we can run three equivalent commands. In each case, we suppose the Apptainer image quantum-espresso.sif
can be found at $HOME/apptainer-images/quantum-espresso.sif
.
- One can use
apptainer exec
to execute a specific command in the container.
- One can use
apptainer run
to call the container’s default command, namely thepw.x
executable. We also append instructions at the end of the command allowing to locate Quantum Espresso input file.
- One can eventually execute the image as a binary, which is strictly identical to using
apptainer run
.
Using the Quantum Espresso container for parallel runs
The $HOME/apptainer-images/quantum-espresso.sif
image embedds a parallelized (through OpenMP and MPI) version of Quantum Espresso.
In the case where no containerization would be used, the typical Quantum Espresso call would look like:
Using the container, the same command becomes
Remark
Without any specification, Quantum Espresso uses by default all available OpenMP threads (or, if applicable, the number defined by the
OMP_NUM_THREADS
environment variable on the host machine) and splitts MPI processes over all available cores.
In the previous command, we use the mpirun
command provided by the embedded version of OpenMPI within the container to communicate directly with the hardware of the host machine. This embedded usage has a major advantage, as we only use the tools installed in the container: it works on all host machines without requiring installation. However, the version of OpenMPI within the container is not built to run optimally on all host machines, but to provide satisfactory performance on as wide a range of machines as possible. Typically, in the case of Quantum Espresso, we observe that CPU usage peaks between 85 and 90% with embedded parallelization. Moreover, this parallelization mode also does not allow distributed computing across multiple compute nodes. While ease of portability at the expense of slightly degraded performance may be suitable for conducting simple tests on a local machine, this is not the case on a high-performance computing infrastructure.
In cases where numerical performance is crucial, it is recommended to use a hybrid parallelization mode, where we use the OpenMPI version of the host machine as an intermediary between that of the container and the hardware of the host machine. For more details, please refer to the dedicated page.
Display help
To display the container’s help message (supposing the image is stored at $HOME/apptainer-images/quantum-espresso.sif
):
To display the container’s meta-data (code owner, version, image author, …):
Partial or total isolation
By default, Apptainer does not fully isolate the container from the host system. One can either have partial or total isolation using respectively the flags --no-mount
or --no-home
and --containall
(see this link for more information).
Whenever --containall
is activated, the directory on the host machine containing Quantum Espresso input-files cannot be accessed from the container!
It is then required to manually mount the current directory ($PWD
) to the one where we are located by default in the container ($HOME
) using the --bind
flag. For instance:
in the case where Quantum Espresso input files are in the current directory ($PWD
).
Exercices
First exercice
How to use the container image to run a Quantum Espresso computation?
Data
- The image is located at:
$HOME/apptainer-images/quantum-espresso.sif
- Input files (including the main input file
qe-tutorial.in
) are located in the current directory:$PWD
Possible answers:
apptainer run $HOME/apptainer-images/quantum-espresso.sif -in qe-tutorial.in
- or
apptainer exec $HOME/apptainer-images/quantum-espresso.sif pw.x -in qe-tutorial.in
- or
$HOME/apptainer-images/quantum-espresso.sif -in qe-tutorial.in
Second exercice
How to use the container image to run a Quantum Espresso computation (1 OpenMP thread and 16 MPI cores)?
Data
- The image is located at:
$HOME/apptainer-images/quantum-espresso.sif
- Input files (including the main input file
qe-tutorial.in
) are located in the current directory:$PWD
Example of a possible answer:
where --env OMP_NUM_THREADS=1
is mandatory, as without it the container uses by defalut all the available threads.
Third exercice
How to use the container image to run a Quantum Espresso computation (2 OpenMP threads and 8 MPI cores) which is fully isolated from the host system?
Data
- The image is located at:
$HOME/apptainer-images/quantum-espresso.sif
- Input files (including the main input file
qe-tutorial.in
) are located at:$HOME/quantum-espresso-examples/exercice/
Example of a possible answer: