计算化学公社

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

[CP2K] 在 Ubuntu 20.04 LTS 桌面系统 GNU 成功编译 CP2K-9.1

[复制链接 Copy URL]

1060

帖子

0

威望

3256

eV
积分
4316

Level 6 (一方通行)

本帖最后由 乐平 于 2022-4-28 16:32 编辑

CP2K 的编译一直困扰很多人,包括我在内。2021年初,我参考刘锦程博士的视频教程,在集群上(CentOS Linux release 7.4.1708 (Core),升级到了 GCC-9.3.1)用 Intel MKL 成功编译了 CP2K 7.1 版。但是之后的 CP2K-8.1,8.2 版始终编译不通。今年年初尝试编译 CP2K-9.1版,依旧是问题不断(http://bbs.keinsci.com/thread-27645-1-1.html)。也尝试了论坛上的 Docker,Singularity 方法 (http://bbs.keinsci.com/thread-25773-1-1.html),过程中似乎是顺利的,但是测试的时候死活运行不起来。也下载了楼主帖子中已经打包分享的 cp2k82-avx2-1.sif 和 cp2k82-avx512-1.sif,但是复制到集群上就是运行不起来(见 http://bbs.keinsci.com/thread-25773-9-1.html)。我承认我很笨,我不懂 Singularity。

在自己的工作站(CentOS 8.3 升级到 GCC-9.3.1)上也试过用 Intel MKL 编译 CP2K 9.1,依旧是失败。经过了大概一个月的纠结和折腾,我决定先用自己的工作站开刀,换系统!用 Ubuntu 20.04。
目前能免费下载的 Intel 编译器只有 OneAPI,但是编译 CP2K-9.1 的时候依旧有问题。于是我决定抛弃 Intel 编译器,直接用 GNU 吧。毕竟 CP2K 的 toolchain 里就有安装 GCC-11.2 的功能。

于是,接下来的事情就变得异常顺利!废话不多说,直接把我编译的过程都呈现出来,包括编译的路径。


全新的 Ubuntu 系统不自带编译器,需要自己安装

  1. huan@grape:~$ sudo apt-get install make build-essential g++ gfortran
复制代码

我们可以在任意位置编译 CP2K,比如我在 ~/Public 路径下用 tar jxvf 命令解压 cp2k-9.1.tar.bz2 压缩文件。我之前把该压缩文件放在 ~/SoftwareBACKUP/ 路径下。
  1. huan@grape:~/Public$ tar jxvf ~/SoftwareBACKUP/cp2k-9.1.tar.bz2
复制代码

然后把刚刚解压的 cp2k-9.1 改名为 cp2k91_GNU,以提示自己这个是纯 GNU 编译的,没有用到任何 Intel 的编译器。改名后进入此路径。
  1. huan@grape:~/Public$ mv cp2k-9.1/ cp2k91_GNU/ && cd cp2k91_GNU/tools/toolchain
复制代码

进入到~/Public/cp2k91_GUN/tools/toolchain 路径后,ls 查看当前路径下有什么文件。


  1. huan@grape:~/Public/cp2k91_GUN/tools/toolchain$ ls
  2. Dockerfile           Dockerfile.hip_cuda      install_cp2k_toolchain.sh       install_requirements_ubuntu.sh  scripts
  3. Dockerfile.cuda      Dockerfile.hip_rocm      install_requirements_fedora.sh  install_tensorflow.sh
  4. Dockerfile.cuda_mkl  Dockerfile.ubuntu_nompi  install_requirements.sh         README.md
复制代码

我们可以先运行 cp2k-9.1 自带的       install_requirements_ubuntu.sh 脚本,用来确认一下系统是否有预先需要的包。感叹一下程序设计者多贴心。

  1. huan@grape:~/Public/cp2k91_GNU/tools/toolchain$ sudo ./install_requirements_ubuntu.sh
  2. [sudo] password for huan:
  3. Installing Ubuntu packages...
  4. Selecting previously unselected package libopts25:amd64.
  5. (Reading database ... 182483 files and directories currently installed.)
  6. Preparing to unpack .../0-libopts25_1%3a5.18.16-3_amd64.deb ...
  7. Unpacking libopts25:amd64 (1:5.18.16-3) ...
  8. Selecting previously unselected package libopts25-dev:amd64.
  9. Preparing to unpack .../1-libopts25-dev_1%3a5.18.16-3_amd64.deb ...
  10. Unpacking libopts25-dev:amd64 (1:5.18.16-3) ...
  11. Selecting previously unselected package autogen.
  12. Preparing to unpack .../2-autogen_1%3a5.18.16-3_amd64.deb ...
  13. Unpacking autogen (1:5.18.16-3) ...
  14. Replaced by files in installed package libopts25-dev:amd64 (1:5.18.16-3) ...
  15. Selecting previously unselected package liberror-perl.
  16. Preparing to unpack .../3-liberror-perl_0.17029-1_all.deb ...
  17. Unpacking liberror-perl (0.17029-1) ...
  18. Selecting previously unselected package git-man.
  19. Preparing to unpack .../4-git-man_1%3a2.25.1-1ubuntu3.2_all.deb ...
  20. Unpacking git-man (1:2.25.1-1ubuntu3.2) ...
  21. Selecting previously unselected package git.
  22. Preparing to unpack .../5-git_1%3a2.25.1-1ubuntu3.2_amd64.deb ...
  23. Unpacking git (1:2.25.1-1ubuntu3.2) ...
  24. Selecting previously unselected package libtool-bin.
  25. Preparing to unpack .../6-libtool-bin_2.4.6-14_amd64.deb ...
  26. Unpacking libtool-bin (2.4.6-14) ...
  27. Setting up libtool-bin (2.4.6-14) ...
  28. Setting up libopts25:amd64 (1:5.18.16-3) ...
  29. Setting up liberror-perl (0.17029-1) ...
  30. Setting up git-man (1:2.25.1-1ubuntu3.2) ...
  31. Setting up libopts25-dev:amd64 (1:5.18.16-3) ...
  32. Setting up autogen (1:5.18.16-3) ...
  33. Setting up git (1:2.25.1-1ubuntu3.2) ...
  34. Processing triggers for libc-bin (2.31-0ubuntu9.7) ...
  35. Processing triggers for man-db (2.9.1-1) ...
  36. Processing triggers for install-info (6.7.0.dfsg.2-5) ...
  37. huan@grape:~/Public/cp2k91_GNU/tools/toolchain$
复制代码


然后,就是大家期待已久的安装预编译的各种库了。其实没有什么特别的,toolchain 里已经写好了。大家耐心查看一下      install_cp2k_toolchain.sh 脚本中的 --with-PKG 下面的说明,并对照 CP2K 官网上的内容(https://github.com/cp2k/cp2k/blob/master/INSTALL.md)就大体能知道哪些库是干什么的,以及哪些库是默认安装的。默认安装的库都可以不需要在编译过程中写出来。

我这里是希望验证这些库在 Ubuntu 20.04 LTS 桌面版能正常且顺利地安装,所以就尽可能都安装了。
  1. huan@grape:~/Public/cp2k91_GNU/tools/toolchain$ ./install_cp2k_toolchain.sh --with-gcc=install --with-openmpi=install --with-scalapack=install --with-libsmm=install --with-ptscotch=install --with-superlu=install --with-pexsi=install --with-quip=install --with-plumed=install
复制代码

请注意,我这里没有用 sudo,因为我在普通的路径下编译的。如果大家希望在 /opt 路径下编译,需要在命令前面加 sudo


接下来,就是自动编译的过程,我把所有的结果都呈现出来。

  1. huan@grape:~/Public/cp2k91_GNU/tools/toolchain$
  2. huan@grape:~/Public/cp2k91_GNU/tools/toolchain$ ./install_cp2k_toolchain.sh --with-gcc=install --with-openmpi=install --with-scalapack=install --with-libsmm=install --with-ptscotch=install --with-superlu=install --with-pexsi=install --with-quip=install --with-plumed=install
  3. MPI is detected and it appears to be OpenMPI
  4. You have chosen to install GCC, therefore MPI libraries will have to be installed too
  5. Compiling with 56 processes.
  6. ==================== Installing GCC ====================
  7. gcc-11.2.0.tar.gz is found
  8. Installing GCC from scratch into /home/huan/Public/cp2k91_GNU/tools/toolchain/install/gcc-11.2.0
  9. Step gcc took 377.00 seconds.
  10. ==================== Getting proc arch info using OpenBLAS tools ====================
  11. OpenBLAS-0.3.19.tar.gz is found
  12. OpenBLAS detected LIBCORE = skylakex
  13. OpenBLAS detected ARCH    = x86_64
  14. ==================== Installing CMake ====================
  15. cmake-3.22.1-Linux-x86_64.sh is found
  16. Installing from scratch into /home/huan/Public/cp2k91_GNU/tools/toolchain/install/cmake-3.22.1
  17. Step cmake took 1.00 seconds.
  18. ==================== Installing OpenMPI ====================
  19. openmpi-4.1.1.tar.gz: OK
  20. Checksum of openmpi-4.1.1.tar.gz Ok
  21. Installing from scratch into /home/huan/Public/cp2k91_GNU/tools/toolchain/install/openmpi-4.1.1
  22. Step openmpi took 462.00 seconds.
  23. ==================== Installing OpenBLAS ====================
  24. OpenBLAS-0.3.19.tar.gz is found
  25. Installing from scratch into /home/huan/Public/cp2k91_GNU/tools/toolchain/install/openblas-0.3.19
  26. Step openblas took 48.00 seconds.
  27. ==================== Installing FFTW ====================
  28. fftw-3.3.10.tar.gz is found
  29. Installing from scratch into /home/huan/Public/cp2k91_GNU/tools/toolchain/install/fftw-3.3.10
  30. Step fftw took 63.00 seconds.
  31. ==================== Installing LIBINT ====================
  32. libint-v2.6.0-cp2k-lmax-5.tgz is found
  33. Installing from scratch into /home/huan/Public/cp2k91_GNU/tools/toolchain/install/libint-v2.6.0-cp2k-lmax-5
  34. Step libint took 205.00 seconds.
  35. ==================== Installing LIBXC ====================
  36. libxc-5.1.7.tar.gz is found
  37. Installing from scratch into /home/huan/Public/cp2k91_GNU/tools/toolchain/install/libxc-5.1.7
  38. Step libxc took 54.00 seconds.
  39. ==================== Installing libsmm ====================
  40. Searching for an optimised libsmm binary from CP2K website
  41. No optimised binary found ...
  42. Searching for a generic libsmm binary from CP2K website
  43. A generic libsmm libsmm_dnn_x86_64-latest.a is available.
  44. Consider building and contributing to CP2K an optimized
  45. libsmm for your x86_64 skylakex using
  46. the toolkit in tools/build_libsmm provided in cp2k package
  47. libsmm_dnn_x86_64-latest.a: OK
  48. Checksum of libsmm_dnn_x86_64-latest.a Ok
  49. Step libsmm took 26.00 seconds.
  50. ==================== Installing Libxsmm ====================
  51. libxsmm-1.17.tar.gz is found
  52. Installing from scratch into /home/huan/Public/cp2k91_GNU/tools/toolchain/install/libxsmm-1.17
  53. Step libxsmm took 31.00 seconds.
  54. ==================== Installing ScaLAPACK ====================
  55. scalapack-2.1.0.tgz is found
  56. Installing from scratch into /home/huan/Public/cp2k91_GNU/tools/toolchain/install/scalapack-2.1.0
  57. Step scalapack took 23.00 seconds.
  58. ==================== Installing COSMA ====================
  59. COSMA-v2.5.1.tar.gz is found
  60. Installing from scratch into /home/huan/Public/cp2k91_GNU/tools/toolchain/install/COSMA-2.5.1
  61. Step cosma took 18.00 seconds.
  62. ==================== Installing ELPA ====================
  63. elpa-2021.11.001.tar.gz is found
  64. patching file nvcc_wrap
  65. Installing from scratch into /home/huan/Public/cp2k91_GNU/tools/toolchain/install/elpa-2021.11.001/cpu
  66. Step elpa took 244.00 seconds.
  67. ==================== Installing PT-Scotch ====================
  68. scotch_6.0.0.tar.gz is found
  69. Installing from scratch into /home/huan/Public/cp2k91_GNU/tools/toolchain/install/scotch-6.0.0
  70. Step ptscotch took 3.00 seconds.
  71. ==================== Installing SuperLU_DIST ====================
  72. superlu_dist_6.1.0.tar.gz is found
  73. Installing from scratch into /home/huan/Public/cp2k91_GNU/tools/toolchain/install/superlu_dist-6.1.0
  74. Step superlu took 9.00 seconds.
  75. ==================== Installing PEXSI ====================
  76. pexsi_v1.2.0.tar.gz is found
  77. Installing from scratch into /home/huan/Public/cp2k91_GNU/tools/toolchain/install/pexsi-1.2.0
  78. Step pexsi took 52.00 seconds.
  79. ==================== Installing QUIP ====================
  80. QUIP-b4336484fb65b0e73211a8f920ae4361c7c353fd.tar.gz is found
  81. Installing from scratch into /home/huan/Public/cp2k91_GNU/tools/toolchain/install/quip-b4336484fb65b0e73211a8f920ae4361c7c353fd
  82. Step quip took 217.00 seconds.
  83. ==================== Installing gsl ====================
  84. gsl-2.7.tar.gz is found
  85. Installing from scratch into /home/huan/Public/cp2k91_GNU/tools/toolchain/install/gsl-2.7
  86. Step gsl took 67.00 seconds.
  87. ==================== Installing PLUMED ====================
  88. plumed-2.7.3.tgz is found
  89. Installing from scratch into /home/huan/Public/cp2k91_GNU/tools/toolchain/install/plumed-2.7.3
  90. Step plumed took 45.00 seconds.
  91. ==================== Installing hdf5 ====================
  92. hdf5-1.12.0.tar.bz2 is found
  93. Installing from scratch into /home/huan/Public/cp2k91_GNU/tools/toolchain/install/hdf5-1.12.0
  94. Step hdf5 took 104.00 seconds.
  95. Step libvdwxc took 0.00 seconds.
  96. ==================== Installing spglib ====================
  97. spglib-1.16.2.tar.gz is found
  98. Installing from scratch into /home/huan/Public/cp2k91_GNU/tools/toolchain/install/spglib-1.16.2
  99. Step spglib took 5.00 seconds.
  100. ==================== Installing libvori ====================
  101. libvori-210412.tar.gz is found
  102. Installing from scratch into /home/huan/Public/cp2k91_GNU/tools/toolchain/install/libvori-210412
  103. Step libvori took 16.00 seconds.
  104. ==================== Installing spfft ====================
  105. SpFFT-1.0.5.tar.gz is found
  106. Installing from scratch into /home/huan/Public/cp2k91_GNU/tools/toolchain/install/SpFFT-1.0.5
  107. Step spfft took 5.00 seconds.
  108. ==================== Installing spla ====================
  109. SpLA-1.5.2.tar.gz: OK
  110. Checksum of SpLA-1.5.2.tar.gz Ok
  111. Installing from scratch into /home/huan/Public/cp2k91_GNU/tools/toolchain/install/SpLA-1.5.2
  112. Step spla took 11.00 seconds.
  113. ==================== Installing SIRIUS ====================
  114. sirius_7.3.0.tar.gz is found
  115. Installing from scratch into /home/huan/Public/cp2k91_GNU/tools/toolchain/install/sirius-7.3.0
  116. patching file cmake/cudalibs_target.cmake
  117. Step sirius took 48.00 seconds.
  118. ==================== generating arch files ====================
  119. arch files can be found in the /home/huan/Public/cp2k91_GNU/tools/toolchain/install/arch subdirectory
  120. Wrote /home/huan/Public/cp2k91_GNU/tools/toolchain/install/arch/local.ssmp
  121. Wrote /home/huan/Public/cp2k91_GNU/tools/toolchain/install/arch/local_static.ssmp
  122. Wrote /home/huan/Public/cp2k91_GNU/tools/toolchain/install/arch/local.sdbg
  123. Wrote /home/huan/Public/cp2k91_GNU/tools/toolchain/install/arch/local.psmp
  124. Wrote /home/huan/Public/cp2k91_GNU/tools/toolchain/install/arch/local.pdbg
  125. Wrote /home/huan/Public/cp2k91_GNU/tools/toolchain/install/arch/local_static.psmp
  126. Wrote /home/huan/Public/cp2k91_GNU/tools/toolchain/install/arch/local_warn.psmp
  127. Wrote /home/huan/Public/cp2k91_GNU/tools/toolchain/install/arch/local_coverage.pdbg
  128. ========================== usage =========================
  129. Done!
  130. Now copy:
  131.   cp /home/huan/Public/cp2k91_GNU/tools/toolchain/install/arch/* to the cp2k/arch/ directory
  132. To use the installed tools and libraries and cp2k version
  133. compiled with it you will first need to execute at the prompt:
  134.   source /home/huan/Public/cp2k91_GNU/tools/toolchain/install/setup
  135. To build CP2K you should change directory:
  136.   cd cp2k/
  137.   make -j 56 ARCH=local VERSION="ssmp sdbg psmp pdbg"

  138. arch files for GPU enabled CUDA versions are named "local_cuda.*"
  139. arch files for GPU enabled HIP versions are named "local_hip.*"
  140. arch files for coverage versions are named "local_coverage.*"

  141. Note that these pre-built arch files are for the GNU compiler, users have to adapt them for other compilers.
  142. It is possible to use the provided CP2K arch files as guidance.
  143. huan@grape:~/Public/cp2k91_GNU/tools/toolchain$
  144. huan@grape:~/Public/cp2k91_GNU/tools/toolchain$
复制代码


可以看到,过程很顺利,没有任何之前出现的 Error: (./scripts/stageXXinstall_YYY.sh   line ZZ)  Non-zero exit code detected 之类的幺蛾子。

然后就是按照上面的提示将 toolchain/install/arch/ 路径下的所有文件复制、粘贴到 cp2k91_GNU/arch/ 目录下,并 source 刚刚编译的库环境,再回到 cp2k91_GNU/ 路径下编译可执行程序的过程。

  1. huan@grape:~/Public/cp2k91_GNU/tools/toolchain$ cp install/arch/* /home/huan/Public/cp2k91_GNU/arch/
  2. huan@grape:~/Public/cp2k91_GNU/tools/toolchain$
  3. huan@grape:~/Public/cp2k91_GNU/tools/toolchain$
  4. huan@grape:~/Public/cp2k91_GNU/tools/toolchain$ source /home/huan/Public/cp2k91_GNU/tools/toolchain/install/setup
  5. huan@grape:~/Public/cp2k91_GNU/tools/toolchain$
  6. huan@grape:~/Public/cp2k91_GNU/tools/toolchain$ which mpirun
  7. /home/huan/Public/cp2k91_GNU/tools/toolchain/install/openmpi-4.1.1/bin/mpirun
  8. huan@grape:~/Public/cp2k91_GNU/tools/toolchain$
  9. huan@grape:~/Public/cp2k91_GNU/tools/toolchain$ cd ../..
  10. huan@grape:~/Public/cp2k91_GNU$ ls
  11. arch  benchmarks  data  exts  INSTALL.md  LICENSE  Makefile  README.md  REVISION  src  tests  tools
  12. huan@grape:~/Public/cp2k91_GNU$
  13. huan@grape:~/Public/cp2k91_GNU$ make -j 56 ARCH=local VERSION=psmp
复制代码


接下来的编译过程需要等待较长的时间,且有大量的输出。这里只能展示最后 N 行的结果。
  1. Updating archive /home/huan/Public/cp2k91_GNU/lib/local/psmp/libcp2kstart.a
  2. ar: creating /home/huan/Public/cp2k91_GNU/lib/local/psmp/libcp2kstart.a
  3. mpif90 -march=native -mtune=native -fno-omit-frame-pointer -g -O3 -funroll-loops  -fopenmp -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/openmpi-4.1.1/include'  -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/openblas-0.3.19/include' -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/fftw-3.3.10/include' -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/libint-v2.6.0-cp2k-lmax-5/include' -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/libxc-5.1.7/include' -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/libxsmm-1.17/include' -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/COSMA-2.5.1/include' -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/elpa-2021.11.001/cpu/include/elpa_openmp-2021.11.001/modules' -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/elpa-2021.11.001/cpu/include/elpa_openmp-2021.11.001/elpa' -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/scotch-6.0.0/include' -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/superlu_dist-6.1.0/include' -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/pexsi-1.2.0/include' -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/quip-b4336484fb65b0e73211a8f920ae4361c7c353fd/include' -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/gsl-2.7/include' -I/home/huan/Public/cp2k91_GNU/tools/toolchain/install/hdf5-1.12.0/include -I/home/huan/Public/cp2k91_GNU/tools/toolchain/install/spglib-1.16.2/include -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/SpFFT-1.0.5/include' -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/SpLA-1.5.2/include' -I/home/huan/Public/cp2k91_GNU/tools/toolchain/install/sirius-7.3.0/include -fbacktrace -ffree-form -fimplicit-none -std=f2008  -Werror=aliasing -Werror=ampersand -Werror=c-binding-type -Werror=intrinsic-shadow -Werror=intrinsics-std -Werror=line-truncation -Werror=tabs -Werror=target-lifetime -Werror=underflow -Werror=unused-but-set-variable -Werror=unused-variable -Werror=unused-dummy-argument -Werror=conversion -Werror=zerotrip -Wno-maybe-uninitialized -Wuninitialized -Wuse-without-only  -D__LIBXSMM  -D__parallel  -D__FFTW3  -D__LIBINT -D__LIBXC -D__HAS_smm_dnn -D__SCALAPACK -D__COSMA -D__ELPA  -D__LIBPEXSI -D__QUIP -D__GSL -D__PLUMED2 -D__HDF5 -D__SPGLIB -D__LIBVORI -D__SPFFT -D__SPLA -D__SIRIUS   -D__COMPILE_ARCH=""local"" -D__COMPILE_DATE=""Mon 07 Mar 2022 12:55:38 AM CST"" -D__COMPILE_HOST=""grape"" -D__COMPILE_REVISION=""git:d8d7100"" -D__DATA_DIR=""/home/huan/Public/cp2k91_GNU/data"" -Wl,--enable-new-dtags -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/openmpi-4.1.1/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/openmpi-4.1.1/lib'  -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/openblas-0.3.19/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/openblas-0.3.19/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/fftw-3.3.10/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/fftw-3.3.10/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/libint-v2.6.0-cp2k-lmax-5/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/libxc-5.1.7/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/libxc-5.1.7/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/libsmm/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/libsmm/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/libxsmm-1.17/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/libxsmm-1.17/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/scalapack-2.1.0/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/scalapack-2.1.0/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/COSMA-2.5.1/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/COSMA-2.5.1/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/elpa-2021.11.001/cpu/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/elpa-2021.11.001/cpu/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/scotch-6.0.0/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/scotch-6.0.0/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/superlu_dist-6.1.0/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/superlu_dist-6.1.0/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/pexsi-1.2.0/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/pexsi-1.2.0/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/quip-b4336484fb65b0e73211a8f920ae4361c7c353fd/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/quip-b4336484fb65b0e73211a8f920ae4361c7c353fd/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/gsl-2.7/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/gsl-2.7/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/plumed-2.7.3/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/plumed-2.7.3/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/hdf5-1.12.0/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/hdf5-1.12.0/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/spglib-1.16.2/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/spglib-1.16.2/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/libvori-210412/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/libvori-210412/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/SpFFT-1.0.5/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/SpFFT-1.0.5/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/SpLA-1.5.2/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/SpLA-1.5.2/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/sirius-7.3.0/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/sirius-7.3.0/lib'   -L/home/huan/Public/cp2k91_GNU/lib/local/psmp -o /home/huan/Public/cp2k91_GNU/exe/local/libcp2k_unittest.psmp libcp2k_unittest.o  -lcp2kstart -lcp2kmc -lcp2kswarm -lcp2kmotion -lcp2kthermostat -lcp2kemd -lcp2ktmc -lcp2kmain -lcp2kgrid -lcp2kgridcpu -lcp2kgridref -lcp2kgridcommon -ldbcsrarnoldi -ldbcsrx -lcp2kshg_int -lcp2keri_mme -lcp2kminimax -lcp2khfxbase -lcp2ksubsys -lcp2kxc -lcp2kao -lcp2kpw_env -lcp2kinput -lcp2kpw -lcp2kfft -lcp2kfpga -lcp2kfm -lcp2kcommon -lcp2koffload -lcp2kmpiwrap -lcp2kbase -L/home/huan/Public/cp2k91_GNU/lib/local/psmp/exts/dbcsr -ldbcsr -lsirius  -lspla -lspfft -lsymspg -lhdf5 -lhdf5_hl -lz -lplumed -ldl -lstdc++ -lz -ldl -lgsl -lgslcblas -lquip_core -latoms -lFoX_sax -lFoX_common -lFoX_utils -lFoX_fsys -lpexsi -lsuperlu_dist -lptscotchparmetis -lptscotch -lptscotcherr -lscotchmetis -lscotch -lscotcherr -lelpa_openmp -lcosma_prefixed_pxgemm -lcosma -lcosta  -lscalapack -lxsmmf -lxsmm -ldl -lpthread -lsmm_dnn -lxcf03 -lxc -lint2 -lfftw3_mpi -lfftw3 -lfftw3_omp   -lmpi  -lopenblas -lvori -lstdc++ -lstdc++
  4. mpif90 -march=native -mtune=native -fno-omit-frame-pointer -g -O3 -funroll-loops  -fopenmp -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/openmpi-4.1.1/include'  -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/openblas-0.3.19/include' -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/fftw-3.3.10/include' -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/libint-v2.6.0-cp2k-lmax-5/include' -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/libxc-5.1.7/include' -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/libxsmm-1.17/include' -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/COSMA-2.5.1/include' -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/elpa-2021.11.001/cpu/include/elpa_openmp-2021.11.001/modules' -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/elpa-2021.11.001/cpu/include/elpa_openmp-2021.11.001/elpa' -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/scotch-6.0.0/include' -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/superlu_dist-6.1.0/include' -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/pexsi-1.2.0/include' -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/quip-b4336484fb65b0e73211a8f920ae4361c7c353fd/include' -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/gsl-2.7/include' -I/home/huan/Public/cp2k91_GNU/tools/toolchain/install/hdf5-1.12.0/include -I/home/huan/Public/cp2k91_GNU/tools/toolchain/install/spglib-1.16.2/include -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/SpFFT-1.0.5/include' -I'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/SpLA-1.5.2/include' -I/home/huan/Public/cp2k91_GNU/tools/toolchain/install/sirius-7.3.0/include -fbacktrace -ffree-form -fimplicit-none -std=f2008  -Werror=aliasing -Werror=ampersand -Werror=c-binding-type -Werror=intrinsic-shadow -Werror=intrinsics-std -Werror=line-truncation -Werror=tabs -Werror=target-lifetime -Werror=underflow -Werror=unused-but-set-variable -Werror=unused-variable -Werror=unused-dummy-argument -Werror=conversion -Werror=zerotrip -Wno-maybe-uninitialized -Wuninitialized -Wuse-without-only  -D__LIBXSMM  -D__parallel  -D__FFTW3  -D__LIBINT -D__LIBXC -D__HAS_smm_dnn -D__SCALAPACK -D__COSMA -D__ELPA  -D__LIBPEXSI -D__QUIP -D__GSL -D__PLUMED2 -D__HDF5 -D__SPGLIB -D__LIBVORI -D__SPFFT -D__SPLA -D__SIRIUS   -D__COMPILE_ARCH=""local"" -D__COMPILE_DATE=""Mon 07 Mar 2022 12:55:38 AM CST"" -D__COMPILE_HOST=""grape"" -D__COMPILE_REVISION=""git:d8d7100"" -D__DATA_DIR=""/home/huan/Public/cp2k91_GNU/data"" -Wl,--enable-new-dtags -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/openmpi-4.1.1/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/openmpi-4.1.1/lib'  -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/openblas-0.3.19/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/openblas-0.3.19/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/fftw-3.3.10/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/fftw-3.3.10/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/libint-v2.6.0-cp2k-lmax-5/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/libxc-5.1.7/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/libxc-5.1.7/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/libsmm/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/libsmm/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/libxsmm-1.17/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/libxsmm-1.17/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/scalapack-2.1.0/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/scalapack-2.1.0/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/COSMA-2.5.1/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/COSMA-2.5.1/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/elpa-2021.11.001/cpu/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/elpa-2021.11.001/cpu/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/scotch-6.0.0/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/scotch-6.0.0/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/superlu_dist-6.1.0/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/superlu_dist-6.1.0/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/pexsi-1.2.0/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/pexsi-1.2.0/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/quip-b4336484fb65b0e73211a8f920ae4361c7c353fd/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/quip-b4336484fb65b0e73211a8f920ae4361c7c353fd/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/gsl-2.7/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/gsl-2.7/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/plumed-2.7.3/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/plumed-2.7.3/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/hdf5-1.12.0/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/hdf5-1.12.0/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/spglib-1.16.2/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/spglib-1.16.2/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/libvori-210412/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/libvori-210412/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/SpFFT-1.0.5/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/SpFFT-1.0.5/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/SpLA-1.5.2/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/SpLA-1.5.2/lib' -L'/home/huan/Public/cp2k91_GNU/tools/toolchain/install/sirius-7.3.0/lib' -Wl,-rpath='/home/huan/Public/cp2k91_GNU/tools/toolchain/install/sirius-7.3.0/lib'  -L/home/huan/Public/cp2k91_GNU/lib/local/psmp -o /home/huan/Public/cp2k91_GNU/exe/local/cp2k.psmp cp2k.o  -lcp2kstart -lcp2kmc -lcp2kswarm -lcp2kmotion -lcp2kthermostat -lcp2kemd -lcp2ktmc -lcp2kmain -lcp2kgrid -lcp2kgridcpu -lcp2kgridref -lcp2kgridcommon -ldbcsrarnoldi -ldbcsrx -lcp2kshg_int -lcp2keri_mme -lcp2kminimax -lcp2khfxbase -lcp2ksubsys -lcp2kxc -lcp2kao -lcp2kpw_env -lcp2kinput -lcp2kpw -lcp2kfft -lcp2kfpga -lcp2kfm -lcp2kcommon -lcp2koffload -lcp2kmpiwrap -lcp2kbase -L/home/huan/Public/cp2k91_GNU/lib/local/psmp/exts/dbcsr -ldbcsr -lsirius  -lspla -lspfft -lsymspg -lhdf5 -lhdf5_hl -lz -lplumed -ldl -lstdc++ -lz -ldl -lgsl -lgslcblas -lquip_core -latoms -lFoX_sax -lFoX_common -lFoX_utils -lFoX_fsys -lpexsi -lsuperlu_dist -lptscotchparmetis -lptscotch -lptscotcherr -lscotchmetis -lscotch -lscotcherr -lelpa_openmp -lcosma_prefixed_pxgemm -lcosma -lcosta  -lscalapack -lxsmmf -lxsmm -ldl -lpthread -lsmm_dnn -lxcf03 -lxc -lint2 -lfftw3_mpi -lfftw3 -lfftw3_omp   -lmpi  -lopenblas -lvori -lstdc++ -lstdc++
  5. /usr/bin/ld: /home/huan/Public/cp2k91_GNU/tools/toolchain/install/plumed-2.7.3/lib/libplumed.a(kernel.o): in function `PLMD::PlumedMain::readInputLines(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
  6. (.text+0xeca5e): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
  7. /usr/bin/ld: /home/huan/Public/cp2k91_GNU/tools/toolchain/install/plumed-2.7.3/lib/libplumed.a(kernel.o): in function `PLMD::PlumedMain::readInputLines(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
  8. (.text+0xeca5e): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
  9. cd /home/huan/Public/cp2k91_GNU/exe/local; ln -sf cp2k.psmp cp2k_shell.psmp
  10. cd /home/huan/Public/cp2k91_GNU/exe/local; ln -sf cp2k.psmp cp2k.popt
  11. huan@grape:~/Public/cp2k91_GNU$
  12. huan@grape:~/Public/cp2k91_GNU$
复制代码

可以看到,最后产生了两个软链接 ln -sf cp2k.psmp cp2k_shell.psmp , ln -sf cp2k.psmp cp2k.popt
cd 进入到 exe/local 路径下


  1. huan@grape:~/Public/cp2k91_GNU$
  2. huan@grape:~/Public/cp2k91_GNU$ cd exe/local/ && ll
  3. total 1.1G
  4. lrwxrwxrwx 1 huan huan    9 Mar  7 00:55 cp2k.popt -> cp2k.psmp*
  5. lrwxrwxrwx 1 huan huan    9 Mar  7 00:55 cp2k_shell.psmp -> cp2k.psmp*
  6. -rwxrwxr-x 1 huan huan 551M Mar  7 00:55 cp2k.psmp*
  7. -rwxrwxr-x 1 huan huan 551M Mar  7 00:55 libcp2k_unittest.psmp*
  8. -rwxrwxr-x 1 huan huan 910K Mar  7 00:55 xyz2dcd.psmp*
  9. -rwxrwxr-x 1 huan huan 960K Mar  7 00:55 dumpdcd.psmp*
  10. -rwxrwxr-x 1 huan huan 2.5M Mar  7 00:52 grid_unittest.psmp*
  11. -rwxrwxr-x 1 huan huan 2.5M Mar  7 00:52 grid_miniapp.psmp*
  12. -rwxrwxr-x 1 huan huan 2.0M Mar  7 00:51 graph.psmp*
  13. -rwxrwxr-x 1 huan huan 3.5M Mar  7 00:51 parallel_rng_types_unittest.psmp*
  14. -rwxrwxr-x 1 huan huan 120K Mar  7 00:51 memory_utilities_unittest.psmp*
  15. huan@grape:~/Public/cp2k91_GNU/exe/local$
复制代码

可以看到已经编译好的可执行程序。一切非常顺利!


接下来可以跑测试,看看编译是否有问题。命令如下:

  1. huan@grape:~/Public/cp2k91_GNU$ make -j 16 ARCH=local VERSION=psmp test
复制代码

这里请 root 用户注意,可能是 openmpi 限制了 root 用户运行造成的问题,在 /opt 路径下编译 CP2K 的朋友会遇到如下的警告

  1. *************************** Testing started ****************************
  2. --------------------------------------------------------------------------
  3. mpiexec has detected an attempt to run as root.

  4. Running as root is *strongly* discouraged as any mistake (e.g., in
  5. defining TMPDIR) or bug can result in catastrophic damage to the OS
  6. file system, leaving your system in an unusable state.

  7. We strongly suggest that you run mpiexec as a non-root user.

  8. You can override this protection by adding the --allow-run-as-root option
  9. to the cmd line or by setting two environment variables in the following way:
  10. the variable OMPI_ALLOW_RUN_AS_ROOT=1 to indicate the desire to override this
  11. protection, and OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 to confirm the choice and
  12. add one more layer of certainty that you want to do so.
  13. We reiterate our advice against doing so - please proceed at your own risk.
  14. --------------------------------------------------------------------------
复制代码
我为什么会知道呢,因为我最开始就是在 /opt 路径下编译的…… 编译的过程很顺利,但是却无法测试……  


按照文字提示,我添加了  --allow-run-as-root ,不行……
OMPI_ALLOW_RUN_AS_ROOT=1 以及  OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 ,不行……

我尝试了搜索解决方案,发现 Sob 老师的帖子 http://sobereva.com/409 ,尝试了添加
export OMPI_ALLOW_RUN_AS_ROOT=1
export OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1

还是不能运行 test ……


所以我才在 ~/Public 路径下重新编译了一遍。好在前面的编译过程很顺利,我才没有像之前那样沮丧。

不过好在,两个版本在运行自己的算例时,都能正常运行。很开心。

【一点建议】CP2K 官网提供了编译需要的各种库, https://www.cp2k.org/static/downloads/ 可供下载。
网络状况不好的情况下,预先把这些需要的库下载到本地,放在 cp2k91/tools/toolchain/build 路径下。
这样可以节约一些编译的时间,也会避免由于网络不畅导致编译中断的报错。

--------------------------------------------------------------------------------------------

我在 Ubuntu 20.04 LTS 桌面系统下编译成功之后,大家可能会想到,用同样的命令是否能在 CentOS 7 上编译成功呢?毕竟所有需要的库都是可以通过 toolchain 安装的。
于是,我又在集群上编译用同样的方法编译 CP2K-9.1 ,但是,呵呵呵,CentOS 7 再次报错了。
  1. (base) [huan@login01 toolchain]$ ./install_cp2k_toolchain.sh --with-gcc=install --with-openmpi=install --with-scalapack=install --with-libsmm=install --with-ptscotch=install --with-superlu=install --with-pexsi=install --with-quip=install --with-plumed=install
  2. WARNING: (./install_cp2k_toolchain.sh, line 329) No MPI installation detected (ignore this message in Cray Linux Environment or when MPI installation was requested).
  3. You have chosen to install GCC, therefore MPI libraries will have to be installed too
  4. Compiling with 40 processes.
  5. ==================== Installing GCC ====================
  6. gcc-11.2.0.tar.gz is found
  7. Installing GCC from scratch into /public/home/zhaoyan/cp2k91_GNU/tools/toolchain/install/gcc-11.2.0
  8. Step gcc took 725.00 seconds.
  9. ==================== Getting proc arch info using OpenBLAS tools ====================
  10. OpenBLAS-0.3.19.tar.gz is found
  11. make: Warning: File `Makefile.conf' has modification time 12 s in the future
  12. make: warning:  Clock skew detected.  Your build may be incomplete.
  13. OpenBLAS detected LIBCORE = haswell
  14. OpenBLAS detected ARCH    = x86_64
  15. ==================== Installing CMake ====================
  16. cmake-3.22.1-Linux-x86_64.sh is found
  17. Installing from scratch into /public/home/zhaoyan/cp2k91_GNU/tools/toolchain/install/cmake-3.22.1
  18. Step cmake took 8.00 seconds
  19. ==================== Installing OpenMPI ====================
  20. openmpi-4.1.1.tar.gz is found
  21. Installing from scratch into /public/home/zhaoyan/cp2k91_GNU/tools/toolchain/install/openmpi-4.1.1
  22. Step openmpi took 985.00 seconds.
  23. ==================== Installing OpenBLAS ====================
  24. OpenBLAS-0.3.19.tar.gz is found
  25. Installing from scratch into /public/home/zhaoyan/cp2k91_GNU/tools/toolchain/install/openblas-0.3.19
  26. Step openblas took 161.00 seconds.
  27. ==================== Installing FFTW ====================
  28. fftw-3.3.10.tar.gz is found
  29. Installing from scratch into /public/home/zhaoyan/cp2k91_GNU/tools/toolchain/install/fftw-3.3.10
  30. Step fftw took 164.00 seconds.
  31. ==================== Installing LIBINT ====================
  32. libint-v2.6.0-cp2k-lmax-5.tgz is found
  33. Installing from scratch into /public/home/zhaoyan/cp2k91_GNU/tools/toolchain/install/libint-v2.6.0-cp2k-lmax-5
  34. Step libint took 678.00 seconds.
  35. ==================== Installing LIBXC ====================
  36. libxc-5.1.7.tar.gz is found
  37. Installing from scratch into /public/home/zhaoyan/cp2k91_GNU/tools/toolchain/install/libxc-5.1.7
  38. Step libxc took 128.00 seconds.
  39. ==================== Installing libsmm ====================
  40. Searching for an optimised libsmm binary from CP2K website
  41. An optimized libsmm libsmm_dnn_haswell-2015-11-10.a is available
  42. libsmm_dnn_haswell-2015-11-10.a has already been downloaded.
  43. Step libsmm took 0.00 seconds.
  44. ==================== Installing Libxsmm ====================
  45. libxsmm-1.17.tar.gz is found
  46. Installing from scratch into /public/home/zhaoyan/cp2k91_GNU/tools/toolchain/install/libxsmm-1.17
  47. ERROR: (./scripts/stage4/install_libxsmm.sh, line 70) Non-zero exit code detected.
  48. (base) [huan@login01 toolchain]$
复制代码

查看 scripts/stage4/install_libxsmm.sh 的 70 行,是 make 报错
  1. 67       cd libxsmm-${libxsmm_ver}
  2. 68       # Avoid an unintended (incompatible) setting of FORTRAN
  3. 69       unset FORTRAN
  4. 70       make -j $(get_nprocs) \
  5. 71         CXX=$CXX \
  6. 72         CC=$CC \
  7. 73         FC=$FC \
  8. 74         PREFIX=${pkg_install_dir} \
  9. 75         > make.log 2>&1
  10. 76       make -j $(get_nprocs) \
  11. 77         CXX=$CXX \
  12. 78         CC=$CC \
  13. 79         FC=$FC \
  14. 80         PREFIX=${pkg_install_dir} \
  15. 81         install > install.log 2>&1
  16. 82       cd ..
复制代码

查找报错记录

  1. (base) [huan@login01 toolchain]$ find -name *.log
复制代码
会出来很多 .log 文件,我们需要看关于安装 libxsmm 有关的 .log,会发现有一个 ./build/libxsmm-1.17/make.log 文件
  1. ./build/libxc-5.1.7/make.log
  2. ./build/libxc-5.1.7/install.log
  3. ./build/libxc-5.1.7/configure.log
  4. ./build/libxc-5.1.7/config.log
  5. ./build/libxsmm-1.17/make.log
  6. ./build/libint-v2.6.0-cp2k-lmax-5/make.log
  7. ./build/libint-v2.6.0-cp2k-lmax-5/install.log
  8. ./build/libint-v2.6.0-cp2k-lmax-5/configure.log
  9. ./build/libint-v2.6.0-cp2k-lmax-5/config.log
复制代码

然后进入 build/libxsmm-1.17/ 路径下查看。最终我发现 make.log 文件最后记录错误为
  1. 2527 /tmp/ccE3IUdy.s:131284: Error: no such instruction: `vcvtne2ps2bf16 %zmm10,%zmm1,%zmm14'
  2. 2528 /tmp/ccE3IUdy.s:131305: Error: no such instruction: `vcvtne2ps2bf16 %zmm9,%zmm11,%zmm5'
  3. 2529 /tmp/ccE3IUdy.s:131310: Error: no such instruction: `vcvtne2ps2bf16 %zmm15,%zmm0,%zmm13'
  4. 2530 /tmp/ccE3IUdy.s:131316: Error: no such instruction: `vcvtne2ps2bf16 %zmm4,%zmm3,%zmm6'
  5. 2531 /tmp/ccE3IUdy.s:131322: Error: no such instruction: `vcvtne2ps2bf16 %zmm8,%zmm7,%zmm2'
  6. 2532 /tmp/ccE3IUdy.s:131328: Error: no such instruction: `vcvtne2ps2bf16 %zmm1,%zmm12,%zmm10'
  7. 2533 /tmp/ccE3IUdy.s:131334: Error: no such instruction: `vcvtne2ps2bf16 %zmm11,%zmm14,%zmm9'
  8. 2534 /tmp/ccE3IUdy.s:131340: Error: no such instruction: `vcvtne2ps2bf16 %zmm0,%zmm5,%zmm15'
  9. 2535 /tmp/ccE3IUdy.s:131351: Error: no such instruction: `vcvtne2ps2bf16 %zmm3,%zmm13,%zmm4'
  10. 2536 /tmp/ccE3IUdy.s:131355: Error: no such instruction: `vcvtne2ps2bf16 %zmm7,%zmm6,%zmm8'
  11. 2537 /tmp/ccE3IUdy.s:131360: Error: no such instruction: `vcvtne2ps2bf16 %zmm12,%zmm2,%zmm1'
  12. 2538 /tmp/ccE3IUdy.s:131365: Error: no such instruction: `vcvtne2ps2bf16 %zmm14,%zmm10,%zmm11'
  13. 2539 /tmp/ccE3IUdy.s:131370: Error: no such instruction: `vcvtne2ps2bf16 %zmm5,%zmm9,%zmm0'
  14. 2540 /tmp/ccE3IUdy.s:131376: Error: no such instruction: `vcvtne2ps2bf16 %zmm13,%zmm15,%zmm3'
  15. 2541 /tmp/ccE3IUdy.s:131380: Error: no such instruction: `vcvtne2ps2bf16 %zmm6,%zmm4,%zmm7'
  16. 2542 /tmp/ccE3IUdy.s:131384: Error: no such instruction: `vcvtne2ps2bf16 %zmm2,%zmm8,%zmm12'
  17. 2543 make: [obj/intel64/libxsmm_dnn_rnncell_forward.o] Error 1 (ignored)
  18. 2544 make: *** [obj/intel64/libxsmm_dnn_rnncell_forward.o] Error 1
复制代码

莫名奇妙啊!

libxsmm 是 CP2K toolchain 默认安装的库。同样的 toolchain 为什么 Ubuntu 20.04 可以正常编译通过,而 CentOS 7 却不行?


-------------------------------------------------------------------------------------------------------------------------------

现在回想一下,之前大家一直纠结和困扰的问题,很可能是因为系统太老旧的缘故造成的。CP2K 又是一个特别挑剔编译器的程序,编译器的小版本号不一样,都很可能造成编译不成功的现象。对于我们这样的普通用户,没有太深入的编程背景,很多情况下是束手无策的。

再次感叹,系统不能太旧,不然麻烦太多。装机器的时候能用较为新的系统就不要用老旧的系统。对于已有的集群,最好能在假期前联系工程师更新系统。

评分 Rate

参与人数
Participants 1
eV +3 收起 理由
Reason
hebrewsnabla + 3

查看全部评分 View all ratings

185

帖子

1

威望

4133

eV
积分
4338

Level 6 (一方通行)

67#
发表于 Post on 2022-4-29 07:04:09 | 只看该作者 Only view this author
乐平 发表于 2022-4-28 22:27
我用的不是 wsl Ubuntu,我是在自己的小工作站上安装的 Ubuntu 20.04 LST

CentOS 7 是课题组集群的系 ...

但也据说 openeuler 是基于 centos8 的,估计也会由于 glibc 版本过高没法移植 centos7

2301

帖子

1

威望

5473

eV
积分
7794

Level 6 (一方通行)

66#
发表于 Post on 2022-4-28 22:53:55 | 只看该作者 Only view this author
可以去华为社区,找他们优化的cp2k7.1
源码优化,
他们自己讲,至少30%以上。
High-Performance Computing for You
为您专属定制的高性能计算解决方案

更多讯息,请访问:
https://labitc.top
http://tophpc.top:8080
电邮: ask@hpc4you.top

1060

帖子

0

威望

3256

eV
积分
4316

Level 6 (一方通行)

65#
 楼主 Author| 发表于 Post on 2022-4-28 22:27:21 | 只看该作者 Only view this author
本帖最后由 乐平 于 2022-4-28 16:30 编辑
highlight 发表于 2022-4-28 10:33
由于 glibc 版本的缘故,使用 wsl ubuntu-20.04 编译出来的没法移植至 centos7,后者应该是现在大多数超 ...

我用的不是 wsl Ubuntu,我是在自己的小工作站上安装的 Ubuntu 20.04 LST

CentOS 7 是课题组集群的系统。
另外,微软商店里可以搜到华为开发的 OpenEuler,据说是基于 CentOS 开发的。

185

帖子

1

威望

4133

eV
积分
4338

Level 6 (一方通行)

64#
发表于 Post on 2022-4-28 16:33:47 | 只看该作者 Only view this author
乐平 发表于 2022-4-28 12:53
emmmmm 我是这个帖子的楼主,此帖到目前为止已经从 Ubuntu 正常安装到 CentOS 7 不正常安装各种填坑,哈 ...

由于 glibc 版本的缘故,使用 wsl ubuntu-20.04 编译出来的没法移植至 centos7,后者应该是现在大多数超算和服务器使用的发行版吧
或许我可以发个帖子说说咋在 wsl 里搞 centos7......

1060

帖子

0

威望

3256

eV
积分
4316

Level 6 (一方通行)

63#
 楼主 Author| 发表于 Post on 2022-4-28 12:53:55 | 只看该作者 Only view this author
highlight 发表于 2022-4-27 14:46
首先,提前恭喜一下,我印象里这是成功编译前的最后一个坑了

然后,丰富下描述:

emmmmm 我是这个帖子的楼主,此帖到目前为止已经从 Ubuntu 正常安装到 CentOS 7 不正常安装各种填坑,哈哈哈哈



1060

帖子

0

威望

3256

eV
积分
4316

Level 6 (一方通行)

62#
 楼主 Author| 发表于 Post on 2022-4-28 12:50:39 | 只看该作者 Only view this author
abin 发表于 2022-4-27 14:57
试试租用一台境外网络正常的裸金属服务器试试……我们遇到的很多奇葩问题,
开发者几乎不会遇到。

跟网络无关吧
我都是把所有依赖包下载好了,放到 build 目录下然后再安装的。

2301

帖子

1

威望

5473

eV
积分
7794

Level 6 (一方通行)

61#
发表于 Post on 2022-4-27 20:57:17 | 只看该作者 Only view this author
highlight 发表于 2022-4-27 20:46
首先,提前恭喜一下,我印象里这是成功编译前的最后一个坑了

然后,丰富下描述:

试试租用一台境外网络正常的裸金属服务器试试……我们遇到的很多奇葩问题,
开发者几乎不会遇到。
High-Performance Computing for You
为您专属定制的高性能计算解决方案

更多讯息,请访问:
https://labitc.top
http://tophpc.top:8080
电邮: ask@hpc4you.top

185

帖子

1

威望

4133

eV
积分
4338

Level 6 (一方通行)

60#
发表于 Post on 2022-4-27 20:46:16 | 只看该作者 Only view this author
乐平 发表于 2022-4-27 15:25
在 scripts/stage1/install_interlmpi 中将 mpiicc 修改为 mpicc ,将 mpiifort 改为 mpif90 ...

首先,提前恭喜一下,我印象里这是成功编译前的最后一个坑了

然后,丰富下描述:
在使用 toolchain 编译 cp2k 的全部依赖时,如果某一步报错,并不需要完全从头开始,做好相应的修改后再次运行脚本,如果前面成功编译的库存在 $pkg_install_dir/install_successful 就会直接跳过安装,只重新配置 setup
但现在的 9.1 版本编译到 spfft 时,若出现过如上的“报错中断——重运行脚本”过程,就可能会出现“卡住”的现象。此时监控系统状态,会看到内存正在被一点一点填满,但编译进度(log 输出)一点不动。之前版本似乎没有这个问题,而且并不是在所有时候都会出现。

最后,由于实在找不到原因(怀疑是某个库的 setup 没写全?),解决办法只能是清空 install 和 build,做好全部的脚本修改与环境设置,重新执行脚本。基本就可以通过。

PS:是否有大神可以解析下这个坑的成因?

2301

帖子

1

威望

5473

eV
积分
7794

Level 6 (一方通行)

59#
发表于 Post on 2022-4-27 18:35:12 | 只看该作者 Only view this author
本帖最后由 abin 于 2022-4-27 18:40 编辑
乐平 发表于 2022-4-27 15:25
在 scripts/stage1/install_interlmpi 中将 mpiicc 修改为 mpicc ,将 mpiifort 改为 mpif90 ...

推荐一个测试方案.

使用intel MPI 和 mpiicc, mpiifort, MKL
采用官方提供的Linux-x86-64-intel-mini.arch 试试,
测试算例能否全通过?
另,
从理论上讲, intel MPI 与 MPICH基本是一个东西.
mpiicc --> mpicc, 相当于, 使用intel MPI/MPICH + GNU编译器来处理....
所以, 我的建议是, 使用intelMPI, 又使用mpicc, 那么直接使用官方的GNU+MPICH就可以了.
当然官方, 也提供了GNU+MPICH+MKL的dockerfile.

也有测试说, PGI编译器又奇效呢....

如果侧重于多机器并行效率,
可以试试, MVAPICH: MPI over InfiniBand, Omni-Path, Ethernet/iWARP, and RoCE




High-Performance Computing for You
为您专属定制的高性能计算解决方案

更多讯息,请访问:
https://labitc.top
http://tophpc.top:8080
电邮: ask@hpc4you.top

1060

帖子

0

威望

3256

eV
积分
4316

Level 6 (一方通行)

58#
 楼主 Author| 发表于 Post on 2022-4-27 15:25:47 | 只看该作者 Only view this author
本帖最后由 乐平 于 2022-4-27 09:31 编辑

在 scripts/stage1/install_interlmpi 中将 mpiicc 修改为 mpicc ,将 mpiifort 改为 mpif90
并将 scripts/common_vars.sh 中 export MPICXX=${MPICXX:-mpic++} 改为 export MPICXX=${MPICXX:-mpicxx}

修改了install_cp2k_toolchain.sh 中 intelmpi 与 gcc 的冲突(即,注释掉相应的行)  


用了 oneAPI BaseKit 2022.1.2.146  和  HPCKit 2022.1.2.117

然后,卡在这一步
  1. ==================== Installing spfft ====================
  2. SpFFT-1.0.5.tar.gz is found
  3. Installing from scratch into /public1/apps/cp2k9_intelmpi/tools/toolchain/install/SpFFT-1.0.5
复制代码


也不报错,就一直卡着,停滞不前了……




2

帖子

0

威望

29

eV
积分
31

Level 2 能力者

57#
发表于 Post on 2022-4-26 04:44:12 | 只看该作者 Only view this author
本帖最后由 southcrux 于 2022-4-26 05:37 编辑
leeru 发表于 2022-4-21 12:48
psmp慢可能是并行环境的问题,如果使用的是IB卡互联,mpich似乎不支持IB卡,换openmpi就可以了。

谢谢!后来试了一下把运算节点增加到四个就能通过make test了,但是运行起来和学校编译的在另一个cluster上的版本相比还是慢了很多

185

帖子

1

威望

4133

eV
积分
4338

Level 6 (一方通行)

56#
发表于 Post on 2022-4-21 15:58:35 | 只看该作者 Only view this author
乐平 发表于 2022-4-21 12:24
oneAPI BaseKit 2022.1.2.146  和  HPCKit 2022.1.2.117 吗?


紫薯布丁

82

帖子

0

威望

596

eV
积分
678

Level 4 (黑子)

55#
发表于 Post on 2022-4-21 12:48:11 来自手机 | 只看该作者 Only view this author
southcrux 发表于 2022-4-21 11:15
老师们有遇到过psmp安装后速度很慢的问题吗?我这里编译过程和楼主差不多,只是没有安装elpa,以及使用的是 ...

psmp慢可能是并行环境的问题,如果使用的是IB卡互联,mpich似乎不支持IB卡,换openmpi就可以了。

1060

帖子

0

威望

3256

eV
积分
4316

Level 6 (一方通行)

54#
 楼主 Author| 发表于 Post on 2022-4-21 12:24:57 | 只看该作者 Only view this author
highlight 发表于 2022-4-21 06:13
我用 yum 安装的 oneapi 最新版,会不会是 2018 跟 gcc 11 有啥兼容问题呢?

oneAPI BaseKit 2022.1.2.146  和  HPCKit 2022.1.2.117 吗?

185

帖子

1

威望

4133

eV
积分
4338

Level 6 (一方通行)

53#
发表于 Post on 2022-4-21 12:13:03 | 只看该作者 Only view this author
乐平 发表于 2022-4-20 19:05
在 install_cp2k_toolchain.sh 里注释掉了

我用 yum 安装的 oneapi 最新版,会不会是 2018 跟 gcc 11 有啥兼容问题呢?

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

GMT+8, 2024-11-23 17:20 , Processed in 0.209734 second(s), 30 queries , Gzip On.

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