CP2K
Description
CP2K is a package for atomistic simulations of solid state, liquid, molecular, and biological systems offering a wide range of computational methods with the mixed Gaussian and plane waves approaches.
More information about CP2K and the documentation are found on cp2k.org
Availability
CP2K is freely available for all users under the GNU General Public License (GPL).
Modules
CP2K is an MPI-parallel application. Use mpirun when launching CP2K.
The following versions are available via the unified GWDG Modules.
List of Modules
| Node Type | Module Names | Requirements (Load First) |
|---|---|---|
| Grete (GPU) | cp2k/2024.1 cp2k/2025.1 | gcc/13.2.0 openmpi/5.0.7 |
| Emmy (CPU) | cp2k/2023.2 cp2k/2024.1 cp2k/2025.1 cp2k/2026.1 | gcc/11.5.0 openmpi/4.1.7 |
| Emmy (CPU) | cp2k/2023.2 cp2k/2024.1 cp2k/2025.1 cp2k/2026.1 | gcc/14.2.0 openmpi/4.1.7 |
Remark: cp2k needs special attention when running on GPUs.
You need to check if, for your problem, a considerable acceleration is expected. E.g., for the following test cases, a performance degradation has been reported: www.cp2k.org/performance:piz-daint-h2o-64, www.cp2k.org/performance:piz-daint-h2o-64-ri-mp2, www.cp2k.org/performance:piz-daint-lih-hfx, www.cp2k.org/performance:piz-daint-fayalite-fist
GPU pinning is required (see the example of a job script below). Don’t forget to make executable the script that takes care of the GPU pinning. In the example, this is achieved with:
chmod +x gpu_bind.sh
Using cp2k as a library
Starting from version 2023.2, cp2k has been compiled enabling the option that allows it to be used as a library: libcp2k.a can be found inside $CP2K_LIB_DIR. The header libcp2k.h is located in $CP2K_HEADER_DIR, and the module files (.mod), eventually needed by Fortran users, are in $CP2K_MOD_DIR.
For more details, please refer to the documentation.
#!/bin/bash
#SBATCH --time=12:00:00
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=24
#SBATCH --cpus-per-task=4
#SBATCH --partition=standard96s
#SBATCH --job-name=cp2k
export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}
module load gcc/14.2.0 openmpi/4.1.7 cp2k/2025.1
srun cp2k.psmp input > output#!/bin/bash
#SBATCH --partition=grete
#SBATCH --time=12:00:00
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=4
#SBATCH --cpus-per-task=16
#SBATCH --gpus-per-node=4
#SBATCH --job-name=cp2k
export SLURM_CPU_BIND=none
export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}
export OMP_PLACES=cores
export OMP_PROC_BIND=close
module load gcc/13.2.0 openmpi/5.0.7 cp2k/2025.1
# gpu_bind.sh should be placed in the same directory where cp2k will be executed
# Don't forget to make it executable: chmod +x gpu_bind.sh
mpirun --bind-to core --map-by numa:PE=${SLURM_CPUS_PER_TASK} ./gpu_bind.sh cp2k.psmp input > output#!/bin/bash
export CUDA_VISIBLE_DEVICES=$OMPI_COMM_WORLD_LOCAL_RANK
$@Depending on the problem size, it may happen that the code stops with a segmentation fault due to insufficient stack size or due to threads exceeding their stack space. To circumvent this, we recommend inserting in the jobscript:
export OMP_STACKSIZE=512M
ulimit -s unlimited