计算化学公社

 找回密码 Forget password
 注册 Register
Views: 1523|回复 Reply: 13
打印 Print 上一主题 Last thread 下一主题 Next thread

[CP2K] CP2K-2026.2 Apptainer(singularity) 镜像分享 (2026-07-17更新)

[复制链接 Copy URL]

10

帖子

1

威望

358

eV
积分
388

Level 3 能力者

本帖最后由 s8ga 于 2026-7-17 14:50 编辑

1. 前言
  站内的 CP2K Singularity 镜像都比较老了,最近需要频繁的更换计算节点,所以编译了一份带 全部依赖的CP2K 容器镜像,方便在不同服务器上使用。
  使用了 podman构建
CP2K 然后使用 apptainer(singularity 的开源版本)打包 sif
1.1 使用环境要求
  • 单机:
    不需要root、需要足够高的内核版本 (3.8+)
    无法在docker内嵌套运行 (可以在 wsl / kvm / vmware 等虚拟化方案内运行)
  • 集群:
    没尝试过

1.2 镜像列表
  文件下载链接: https://pan.baidu.com/s/1AdlUGY40yEmDj-M32Q37Xw?pwd=s8ga
  • cp2k-opensource-2025.2 (260501添加) (regtest 通过)
    标准 2025.2 build
  • cp2k-opensource-2025.2-force-avx512 (260501添加) (260514更新) (regtest 通过)
    解决了使用 avx2处理器 上构建的 cp2k在  avx512处理器 上使用时
    Setting real_kernel for ELPA failed 的问题 (强制编译 ELPA的 AVX512内核就好了)
    260514更新 - 强制openBLAS也编译AVX512内核
  • cp2k-mkl-2025.2-experimental (260501添加) (regtest 通过) (实验性)
    使用的是Openmpi + mkl 构建方式
    存在经验性修补内容,不推荐在生产环境中使用
    与Opensource速度基本相同
  • cp2k-rocm-2026.1-gfx942 (260501添加) (实验性)
    AMD Mi300X 加速版本 (未经充分测试)
  • cp2k-opensource-2026.1-force-avx512 (regtest 通过) (260514添加)
    2026.1 build
  • cp2k_opensource-2026.2-force-avx512 (regtest通过) (260717添加)
    2026.2 build

1.3 下个release

2.使用指南
  • 先将 镜像 下载好,并将你选择的 sif文件 和 apptainer-1.4.5-3.el8-x86_64.run放入服务器你选择的位置
    1. # 1.首先切换到你放置文件的目录
    2. cd "Your preferred location"

    3. # 2.给run文件添加可执行权限
    4. chmod +x apptainer-1.4.5-3.el8-x86_64.run

    5. # 3.解压apptainer
    6. ./apptainer-1.4.5-3.el8-x86_64.run

    7. # 4.将apptainer source到PATH中
    8. # 请根据屏幕上面的提示 source指定文件
    9. # (仅供参考) source /tmp/apptainer-test/apptainer-bundle/activate-apptainer.sh

    10. # 5.你可以使用 apptainer run 来启动镜像 (下面的例子仅供参考 - 只是显示了cp2k的版本号/编译信息)
    11. apptainer run cp2k-opensource_2025.2-force-avx512.sif mpirun cp2k.psmp --version | head -n10
    12. # 或者是使用screen + apptainer shell 方式启动
    13. screen apptainer shell cp2k-opensource_2025.2-force-avx512.sif

    14. # 具体使用方式
    15. # apptainer exec cp2k-opensource_2025.2-force-avx512.sif mpirun -np <Input thread count> cp2k.psmp -i [Your Input].inp -o [Your Output].out
    16. # 或者是使用screen + apptainer shell 方式启动
    17. apptainer shell cp2k-opensource_2025.2-force-avx512.sif
    18. # <在新的shell内部>
    19. mpirun -np <Input thread count> cp2k.psmp -i [Your Input].inp -o [Your Output].out

    20. ######################################

    21. # 6.如果你想运行cp2k的regtest
    22. apptainer shell cp2k-opensource_2025.2-force-avx512.sif
    23. # 然后在容器内部运行
    24. python /opt/cp2k/tests/do_regtest.py  --mpiranks 2 --ompthreads 2 --maxtasks $(nproc) --keepalive --workbasedir /tmp --mpiexec "mpirun $MPI_RUNVAR -np {N}" $(dirname $(which cp2k.psmp)) psmp
    复制代码
  • 如果用户重新登录了,只要找到 4提示的sh文件位置,source后正常使用
    如果你想看更形象一点的使用demo的话,可以查看这个 Demo
3. 构建镜像
(更详细的信息 请参照 构建程序链接)
(构建过程所有文件已经开源)

构建机要求:
需要有podman, uv,同时需要有良好的网络连接

推荐使用 Debian / WSL2 或 VMWare 进行编译

  1. 前置条件
  2. # 0. cd 到 clone下来的目录
  3. # cd HPC-Container-Factory

  4. # 1. Python 依赖
  5. uv venv venv
  6. uv pip install -r requirements.txt --python ./venv/bin/python

  7. # 2. 需要 Podman
  8. podman info

  9. # 3. 需要 clone spack
  10. # 下载 Spack v1.1.0 release tarball
  11. mkdir -p assets
  12. curl -fSL -o assets/spack-v1.1.0.tar.gz \
  13.   https://github.com/spack/spack/releases/download/v1.1.0/spack-1.1.0.tar.gz

  14. # 解压出 spack-src/(bootstrap 阶段需要)
  15. tar -xzf assets/spack-v1.1.0.tar.gz -C assets/
  16. mv assets/spack-1.1.0 assets/spack-src

  17. # 4. 激活环境
  18. source ./activate.sh

  19. # 5. 准备离线资源 (spack 源代码包)
  20. python generate.py assets --env cp2k-opensource-2025.2-force-avx512
  21. # 预计输出
  22. # [OK]    All packages available in mirror

  23. # 6. 构建
  24. python generate.py build --app-version cp2k-opensource-2025.2-force-avx512 --network-host
  25. # 构建过程较慢 大概需要45 min +
  26. # 预计输出
  27. # Successfully tagged localhost/cp2k-opensource:2025.2-force-avx512

  28. # 7. 转换为 SIF文件
  29. python generate.py build-sif --app-version  cp2k-opensource-2025.2-force-avx512
  30. # 首次使用需要安装apptainer (需要一些时间)
  31. # 产出文件在 artifacts

  32. # 8. 运行
  33. source ./activate.sh
  34. apptainer shelll artifacts/cp2k-opensource_2025.2-force-avx512.sif

  35. # 9. [可选] 打包apptainer 便于分发至其他机器
  36. python generate.py pack-apptainer
  37. # 产物在 artifact/apptainer-<version>-x86_64.run
复制代码


如果有需要的话,构建产物可以随意分享(MIT协议)

Happy Computing!



评分 Rate

参与人数
Participants 6
威望 +1 eV +15 收起 理由
Reason
reid + 5 赞!
mt13 + 1 谢谢
ZzzJy + 1
guoguoping199 + 5 好物!
dixin + 3 谢谢分享
sobereva + 1

查看全部评分 View all ratings

1641

帖子

0

威望

5401

eV
积分
7042

Level 6 (一方通行)

2#
发表于 Post on 2026-5-6 16:41:23 | 只看该作者 Only view this author
本帖最后由 牧生 于 2026-5-6 16:52 编辑

我跑一个任务,报MPI的问题,但我无法解决。
此外,不知道为何,我的9950X3D,架构被自动认作intel的Haswell


第一个
apptainer exec cp2k-mkl_2025.2-experimental.sif mpirun -np 1 cp2k.psmp -i OPT.inp -o OPT.out
SIRIUS 7.9.0, git hash: https://api.github.com/repos/ele ... git/ref/tags/v7.9.0
--------------------------------------------------------------------------
MPI_ABORT was invoked on rank 0 in communicator MPI_COMM_WORLD
  Proc: [[5169,1],0]
  Errorcode: 1

NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.
You may or may not see output from other processes, depending on
exactly when Open MPI kills them.
--------------------------------------------------------------------------
--------------------------------------------------------------------------
prterun has exited due to process rank 0 with PID 0 on node jing calling
"abort". This may have caused other processes in the application to be
terminated by signals sent by prterun (as reported here).
--------------------------------------------------------------------------




第二个

apptainer exec cp2k-rocm_2026.1-gfx942.sif mpirun -np 6 cp2k.psmp -i OPT.inp -o OPT.out
Core not found: ZEN4
Core: Haswell
Core not found: ZEN4
Core: Haswell
Core not found: ZEN4
Core: Haswell
Core not found: ZEN4
Core: Haswell
Core not found: ZEN4
Core: Haswell
Core not found: ZEN4
Core: Haswell
Inconsistency in warp sizes: Cuda/Hip indicates warp size = 64, while the gpu_properties files indicates warp_size = 32.
Inconsistency in warp sizes: Cuda/Hip indicates warp size = 64, while the gpu_properties files indicates warp_size = 32.
Inconsistency in warp sizes: Cuda/Hip indicates warp size = 64, while the gpu_properties files indicates warp_size = 32.
Inconsistency in warp sizes: Cuda/Hip indicates warp size = 64, while the gpu_properties files indicates warp_size = 32.
Inconsistency in warp sizes: Cuda/Hip indicates warp size = 64, while the gpu_properties files indicates warp_size = 32.
Inconsistency in warp sizes: Cuda/Hip indicates warp size = 64, while the gpu_properties files indicates warp_size = 32.
--------------------------------------------------------------------------
MPI_ABORT was invoked on rank 0 in communicator MPI_COMM_WORLD
  Proc: [[46349,1],0]
  Errorcode: 1

NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.
You may or may not see output from other processes, depending on
exactly when Open MPI kills them.
--------------------------------------------------------------------------
--------------------------------------------------------------------------
prterun has exited due to process rank 0 with PID 0 on node jing calling
"abort". This may have caused other processes in the application to be
terminated by signals sent by prterun (as reported here).
--------------------------------------------------------------------------



第三个apptainer exec cp2k-opensource_2025.2-force-avx512.sif mpirun -np 6 cp2k.psmp -i OPT.inp -o OPT.out
Core not found: ZEN4
Core: Haswell
Core not found: ZEN4
Core: Haswell
Core not found: ZEN4
Core: Haswell
Core not found: ZEN4
Core: Haswell
Core not found: ZEN4
Core: Haswell
Core not found: ZEN4
Core: Haswell
SIRIUS 7.9.0, git hash: https://api.github.com/repos/ele ... git/ref/tags/v7.9.0
--------------------------------------------------------------------------
MPI_ABORT was invoked on rank 0 in communicator MPI_COMM_WORLD
  Proc: [[33067,1],0]
  Errorcode: 1

NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.
You may or may not see output from other processes, depending on
exactly when Open MPI kills them.
--------------------------------------------------------------------------
--------------------------------------------------------------------------
prterun has exited due to process rank 0 with PID 0 on node jing calling
"abort". This may have caused other processes in the application to be
terminated by signals sent by prterun (as reported here).
--------------------------------------------------------------------------








又菜又爱玩

10

帖子

1

威望

358

eV
积分
388

Level 3 能力者

3#
 楼主 Author| 发表于 Post on 2026-5-6 22:19:26 | 只看该作者 Only view this author
本帖最后由 s8ga 于 2026-5-7 06:20 编辑
牧生 发表于 2026-5-6 16:41
我跑一个任务,报MPI的问题,但我无法解决。
此外,不知道为何,我的9950X3D,架构被自动认作intel的Haswe ...

我确定 第二 第三个 的Core not found
情况是与OpenBLAS有关的

第一部分的Core not found 是因为
你可能设置了
OPENBLAS_CORETYPE 环境变量 为 ZEN4

当corename里面没有ZEN4的时候 openblas的默认dynamic逻辑
corename

就会根据cpu能力选择kernel

OpenBLAS的编译等级被我设定为了 x86_64_v3 (只支持到AVX2)
所以说才会打印成 Core: Haswell

(fallback kernel到 Haswell)

但是 我也有点好奇 为什么cp2k 会直接 call mpi_abort
如果没有隐私问题的话 你可以将out文件上传一下

正常来说cp2k在mpi abort之前会将 call stack打印出来的
ref: src/common/cp_error_handling.F:67-73

---------
关于 Core not found的问题 你可以先排查一下环境变量
比如说使用
apptainer --cleanenv exec 尝试一次


---------
这也提醒我了 需要强制openblas编译 AVX512内核 这样可以在更好的平台获得加速
---------

对于第一个mkl的问题,我实在是没什么能帮上的,如果有选择的话,可以
重新编译为带debuginfo的 release
使用gdb给
cp2k的 src/mpiwrap/message_passing.F:1225 的 mp_abort() 打上端点查看调用栈
很抱歉我这边没有ZEN4环境 (我在用没有avx的intel cpu)

第二个关于显卡的问题我大概也没什么办法 :(
最近有点忙



1641

帖子

0

威望

5401

eV
积分
7042

Level 6 (一方通行)

4#
发表于 Post on 2026-5-12 18:45:19 | 只看该作者 Only view this author
本帖最后由 牧生 于 2026-5-12 18:53 编辑

MKL和opensource版本的都正常运行了,只不过我机子本身的速度较慢。

ZEN4的问题,是我疏忽了,9950X3D是ZEN5,在bashrc里面改成ZEN5就好了。


又菜又爱玩

10

帖子

1

威望

358

eV
积分
388

Level 3 能力者

5#
 楼主 Author| 发表于 Post on 2026-5-14 11:36:34 | 只看该作者 Only view this author
本帖最后由 s8ga 于 2026-5-14 11:43 编辑
牧生 发表于 2026-5-12 18:45
MKL和opensource版本的都正常运行了,只不过我机子本身的速度较慢。

ZEN4的问题,是我疏忽了,9950X3D是 ...

其实我不推荐设置这个环境变量
应该让 openBLAS 的 dynamic dispatch 功能自动设定

因为 openBLAS 的 Zen kernel 是没有 avx512加速的

10

帖子

1

威望

358

eV
积分
388

Level 3 能力者

6#
 楼主 Author| 发表于 Post on 2026-7-17 14:54:32 | 只看该作者 Only view this author
本帖最后由 s8ga 于 2026-7-18 03:48 编辑

cp2k-2026.2 的镜像已经上传 (2026/7/17)
祝各位好运~

评分 Rate

参与人数
Participants 1
eV +3 收起 理由
Reason
南北多歧路 + 3 GJ!

查看全部评分 View all ratings

166

帖子

0

威望

1554

eV
积分
1720

Level 5 (御坂)

7#
发表于 Post on 2026-7-29 00:01:24 | 只看该作者 Only view this author
能帮忙pull个2026.2支持AVX2指令集的镜像不,服务器有点老,不支持avx512,谢谢

10

帖子

1

威望

358

eV
积分
388

Level 3 能力者

8#
 楼主 Author| 发表于 Post on 2026-7-29 13:16:28 | 只看该作者 Only view this author
本帖最后由 s8ga 于 2026-7-29 13:26 编辑
reid 发表于 2026-7-29 00:01
能帮忙pull个2026.2支持AVX2指令集的镜像不,服务器有点老,不支持avx512,谢谢

-force-avx512 后缀的镜像均支持在avx2机器上运行
后缀的意义是 强制openblas/elpa/fftw 编译avx512的内核 让这个库在avx2上能运行 avx512上有加速

166

帖子

0

威望

1554

eV
积分
1720

Level 5 (御坂)

9#
发表于 Post on 2026-7-29 14:54:56 | 只看该作者 Only view this author
s8ga 发表于 2026-7-29 13:16
-force-avx512 后缀的镜像均支持在avx2机器上运行
后缀的意义是 强制openblas/elpa/fftw 编译avx512的内 ...

这个2026.2版本能正常运行,感谢!但是速度慢,用时大约是我根据卢老师用toolchain编辑的2025.2版本的3倍。不知什么原因

250

帖子

2

威望

964

eV
积分
1254

Level 4 (黑子)

10#
发表于 Post on 2026-7-29 15:03:08 | 只看该作者 Only view this author
注意CP2K当前在CMAKE_BUILD_TYPE非Generic时是强制加“-march=native -mtune=native”来利用机器支持的最高指令集的,所以如果不在CMake阶段设置"-DCMAKE_BUILD_TYPE=Generic"的话在AVX512上编译出来的CP2K不可能在AVX2机器上正常运行。

目前上游正在讨论将“-march=native -mtune=native”这类本该由用户控制的flag移出内部CMake编译选项。

评分 Rate

参与人数
Participants 1
eV +5 收起 理由
Reason
s8ga + 5

查看全部评分 View all ratings

Failed to load the content due to unknown reasons.

26

帖子

0

威望

1279

eV
积分
1305

Level 4 (黑子)

11#
发表于 Post on 2026-7-29 18:41:05 | 只看该作者 Only view this author
reid 发表于 2026-7-29 14:54
这个2026.2版本能正常运行,感谢!但是速度慢,用时大约是我根据卢老师用toolchain编辑的2025.2版本的3倍 ...

我本地测试的没有速度的区别,甚至比我自己编译的还快,不管是toolchain还是古法编译出来的sif,你可以检查一下你的核心调用是否跟之前一致
我才是旅途的终点!

10

帖子

1

威望

358

eV
积分
388

Level 3 能力者

12#
 楼主 Author| 发表于 Post on 2026-7-29 19:15:49 | 只看该作者 Only view this author
本帖最后由 s8ga 于 2026-7-30 21:02 编辑
UW_0728. 发表于 2026-7-29 15:03
注意CP2K当前在CMAKE_BUILD_TYPE非Generic时是强制加“-march=native -mtune=native”来利用机器支持的最高 ...

感谢您的提醒,我这边的构建机是avx2的,没有暴露出这个问题,正在准备修

26/07/10 更新:
已经修复了 现在通过在cmake选项最后强制追加build type为generic来解决问题

166

帖子

0

威望

1554

eV
积分
1720

Level 5 (御坂)

13#
发表于 Post on 2026-7-29 19:49:31 | 只看该作者 Only view this author
南北多歧路 发表于 2026-7-29 18:41
我本地测试的没有速度的区别,甚至比我自己编译的还快,不管是toolchain还是古法编译出来的sif,你可以检 ...

调了下参数,速度正常了,因为第一次用apptainer,不熟。感谢!

166

帖子

0

威望

1554

eV
积分
1720

Level 5 (御坂)

14#
发表于 Post on 2026-7-29 19:52:06 | 只看该作者 Only view this author
s8ga 发表于 2026-7-29 13:16
-force-avx512 后缀的镜像均支持在avx2机器上运行
后缀的意义是 强制openblas/elpa/fftw 编译avx512的内 ...

因为第一次用apptainer,不熟,调了参数后正常了,感谢提供的sif!可能是因为网络原因,toolchain和spack都试了,都不行,还是您这个方便

本版积分规则 Credits rule

手机版 Mobile version|北京科音自然科学研究中心 Beijing Kein Research Center for Natural Sciences|京公网安备 11010502035419号|计算化学公社 — 北京科音旗下高水平计算化学交流论坛 ( 京ICP备14038949号-1 )|网站地图

GMT+8, 2026-8-13 08:52 , Processed in 3.030719 second(s), 24 queries , Gzip On.

快速回复 返回顶部 返回列表 Return to list