计算化学公社

标题: 在 Ubuntu 20.04 LTS 桌面系统 GNU 成功编译 CP2K-9.1 [打印本页]

作者
Author:
乐平    时间: 2022-3-8 01:00
标题: 在 Ubuntu 20.04 LTS 桌面系统 GNU 成功编译 CP2K-9.1
本帖最后由 乐平 于 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 又是一个特别挑剔编译器的程序,编译器的小版本号不一样,都很可能造成编译不成功的现象。对于我们这样的普通用户,没有太深入的编程背景,很多情况下是束手无策的。

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

作者
Author:
abin    时间: 2022-3-8 11:14
采用默认指令编译的,
和官方提供的预编译的二进制, 没啥本质区别.

“对于已有的集群,最好能在假期前联系工程师更新系统。”
这个, 升级系统是不可能的.
通用的CentOS系列, 不可能跨版本升级的.
Ubuntu虽然支持跨版本升级, 但是没有哪一个IT技术, 愿意在生产环境做系统升级.

最高效的方案, 你的源码中已经提及了, Docker等容器技术呀.
你的源码工作目录, 存在多个Dockerfile呢.
打开看看, 就知道在做什么了.

喜欢折腾的话, 看看Dockerfile就搞定了.

“同样的 toolchain 为什么 Ubuntu 20.04 可以正常编译通过,而 CentOS 7 却不行?”
难道没有发现, 官方默认基于Ubuntu 20.04做的开发测试吗? Dockerfile有写的.

CentOS7, 可以顺利编译呀, 我做的容器版本, 没有任何问题.

至于最新的开发版, 已经全面转向容器方案了.
看源码就晓得. 也有支持spack, 这是一种部署方案.

容器化, 才是最佳解决方案, 而非更换系统.

主机系统, 只要提供内核驱动, 让硬件工作, 让网络工作, 确保文件系统运作,
剩下交给容器就行了.

以上仅仅代表我的个人言论.
我从未研修过计算机专业, 以上说辞可能存在不当之处.

作者
Author:
乐平    时间: 2022-3-8 15:26
abin 发表于 2022-3-8 05:14
采用默认指令编译的,
和官方提供的预编译的二进制, 没啥本质区别.

谢谢讨论。
但是,我在帖子里也说了
尝试了论坛上的 Docker,Singularity 方法 (http://bbs.keinsci.com/thread-25773-1-1.html),过程中似乎是顺利的,但是测试的时候死活运行不起来。


您也在我说的 Singularity 方法的帖子里回复了我的提问,但是依旧没法运行时事实啊……
作者
Author:
abin    时间: 2022-3-8 15:43
乐平 发表于 2022-3-8 15:26
谢谢讨论。
但是,我在帖子里也说了

无所谓了,
能解决自己的问题, 就是好方法.

容器方案你无法使用,
可能是部分细节, 理解/执行有偏差, 当然无法使用了.
导致不可用的细节因素可能有几十条,
哪有功夫逐一debug呀.

能跑起来, 解决自己的实际需求, 就是好方案.


作者
Author:
乐平    时间: 2022-3-8 19:48
abin 发表于 2022-3-8 09:43
无所谓了,
能解决自己的问题, 就是好方法.

其实并没有完全解决,我只是在自己的小工作站上编译成功了。但是,课题组的集群上由于是老旧的 CentOS 7 还是没编译成功……
作者
Author:
highlight    时间: 2022-3-22 16:56
binutls 版本过旧,会导致 libxsmm 编译出现类似如下报错:
  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-1.16.1 时,给出了两种解决办法
1. 升级 binutils,可以选择用 scl-devtoolset 同时解决 GCC 和 binutils 的版本问题
2. 给 make 加参数 INTRINSICS=1
作者
Author:
乐平    时间: 2022-3-22 21:31
highlight 发表于 2022-3-22 10:56
binutls 版本过旧,会导致 libxsmm 编译出现类似如下报错:

在之前的 libxsmm-1.16.1 时,给出了两种解 ...

非常感谢!
在 scripts/stage4/install_libxsmm.sh 第 70 行以及第 76 添加 INTRINSICS=1 ,可行!

  1. make INTRINSICS=1 -j $(get_nprocs) \
复制代码

作者
Author:
waitingseven    时间: 2022-3-23 20:55
乐平 发表于 2022-3-22 21:31
非常感谢!
在 scripts/stage4/install_libxsmm.sh 第 70 行以及第 76 添加 INTRINSICS=1 ,可行!

整个过程中似乎没有用到intel数学库
作者
Author:
乐平    时间: 2022-3-23 22:22
waitingseven 发表于 2022-3-23 14:55
整个过程中似乎没有用到intel数学库

是的,我这个帖子是基于纯 GNU 的,没有用到任何 Intel 相关的东西。
作者
Author:
zhukangg    时间: 2022-4-1 08:11
我在centos编译的时候,编译顺利通过,ssmp的test全过,但是psmp的就很多time out,要怎么解决呢
作者
Author:
zhukangg    时间: 2022-4-1 08:12
zhukangg 发表于 2022-4-1 08:11
我在centos编译的时候,编译顺利通过,ssmp的test全过,但是psmp的就很多time out,要怎么解决呢

error文件里有一行“warning: jobserver unavailable: using -j1.  Add `+' to parent make rule”
作者
Author:
乐平    时间: 2022-4-1 10:23
本帖最后由 乐平 于 2022-4-1 04:24 编辑
zhukangg 发表于 2022-4-1 02:11
我在centos编译的时候,编译顺利通过,ssmp的test全过,但是psmp的就很多time out,要怎么解决呢

CentOS 里各种奇怪的问题,不知道怎么解决……
作者
Author:
gog    时间: 2022-4-10 11:58
网络惊现自带数千test例子100%通过测试的编译方法。
作者
Author:
biogon    时间: 2022-4-10 14:57
gog 发表于 2022-4-10 11:58
网络惊现自带数千test例子100%通过测试的编译方法。

不发个链接吗
作者
Author:
abin    时间: 2022-4-10 15:29
biogon 发表于 2022-4-10 14:57
不发个链接吗

鄙人编译的,
算例都是100%通过的.

前后用到的机器不同, 所以测试算例耗时不同.
(, 下载次数 Times of downloads: 36) (, 下载次数 Times of downloads: 47) (, 下载次数 Times of downloads: 30) (, 下载次数 Times of downloads: 38)
如有需要, 请自行下载. https://pan.baidu.com/s/1r7PduYXqjn3kpS-ie0H8NQ?pwd=aknc

其中, cp2k v7.1 & v8.1, 使用intel编译器处理了 第三方组件 以及 cp2k本体; 而非仅仅使用intel编译器处理cp2k本体.

注意, 不支持AMD处理器平台.


作者
Author:
乐平    时间: 2022-4-10 15:43
测试最好用如下代码
  1. make ARCH=local VERSION=psmp test TESTOPTS+="--mpiranks 4 --ompthreads 4"
复制代码


不要直接
  1. make -j XX ARCH=local VERSION=psmp test
复制代码


官方测试说明的链接如下,
https://www.cp2k.org/dev:regtesting

请注意,TESTOPTS+="--mpiranks 4 --ompthreads 4" 里的是两个连字符 -- ,而不是官方链接里的单个连字符 - 。亲测。

作者
Author:
gog    时间: 2022-4-10 15:48
本帖最后由 gog 于 2022-4-10 15:51 编辑
abin 发表于 2022-4-10 15:29
鄙人编译的,
算例都是100%通过的.

牛人啊!赞赞赞!
作者
Author:
gog    时间: 2022-4-10 16:58
biogon 发表于 2022-4-10 14:57
不发个链接吗

站外链接要审核。你百度搜噶,3700多个测试例子,支持 MKL 和 openmp
“史上功能最全面的CP2K完整编译”

作者
Author:
乐平    时间: 2022-4-10 17:23
gog 发表于 2022-4-10 10:58
站外链接要审核。你百度搜噶,3700多个测试例子,支持 MKL 和 openmp
“史上功能最全面的CP2K完整编译” ...

百度……
作者
Author:
gog    时间: 2022-4-10 17:46
乐平 发表于 2022-4-10 17:23
百度……

关键词 多个 bilibili
作者
Author:
gog    时间: 2022-4-10 17:48
乐平 发表于 2022-4-10 17:23
百度……

B站上的,八度搜不了?
作者
Author:
乐平    时间: 2022-4-10 20:47
gog 发表于 2022-4-10 11:48
B站上的,八度搜不了?

看了看,只不过是个公众号推广而已
作者
Author:
gog    时间: 2022-4-10 21:15
本帖最后由 gog 于 2022-4-10 21:16 编辑
乐平 发表于 2022-4-10 20:47
看了看,只不过是个公众号推广而已
最容易的是用openblas数学库和gcc。这计算速度要低一些。而DFT都比较吃算力。
我想白瞟,只是人家不给。。。

作者
Author:
leeru    时间: 2022-4-10 22:10
说说我的编译,所有测试过全。系统centos7.9,GCC9.3.0,intel2020U2,编译的时候先要升级binutil到2.372,然后gcc=system,intelmpi里面的mpiicc和mpifort改成mpicc和mpif90,然后编译就没报错。ssmp和psmp测试全部通过。,
作者
Author:
gog    时间: 2022-4-11 09:41
本帖最后由 gog 于 2022-4-11 09:53 编辑
leeru 发表于 2022-4-10 22:10
说说我的编译,所有测试过全。系统centos7.9,GCC9.3.0,intel2020U2,编译的时候先要升级binutil到2.372,然 ...

9.1版本?还是7.1?这么修改,太复杂了。我搞不懂。
如何用yum 升级 binutil?自定义路径编辑编译?
调用gcc到还好设置,并行器如何命令调转?

作者
Author:
leeru    时间: 2022-4-11 13:04
9.1版本
作者
Author:
leeru    时间: 2022-4-11 13:05
binutil下载源码,编译后不要自定义安装路径,它会自动安装到常用路径
作者
Author:
乐平    时间: 2022-4-18 19:38
leeru 发表于 2022-4-10 16:10
说说我的编译,所有测试过全。系统centos7.9,GCC9.3.0,intel2020U2,编译的时候先要升级binutil到2.372,然 ...

请问你是用 toolchain 安装的吗? 还是在 arch 里找对应的编译文件?

intelmpi里面的mpiicc和mpifort改成mpicc和mpif90,然后编译就没报错。


这句话里修改 intelmpi 是指 toolchain/scripts/stage1/install_intelmpi.sh 里修改?

还是  arch/Linux-x86-64-intel.psmp 里修改?

作者
Author:
leeru    时间: 2022-4-18 21:06
修改install_intelmpi.sh
作者
Author:
leeru    时间: 2022-4-18 21:21
直接toolchain安装
作者
Author:
leeru    时间: 2022-4-18 21:21
直接toolchain安装
作者
Author:
乐平    时间: 2022-4-19 10:17
本帖最后由 乐平 于 2022-4-19 04:39 编辑
leeru 发表于 2022-4-18 15:21
直接toolchain安装

那就是说,把
  1. cp2k-9.1/tools/toolchain/scripts/stage1/install_intelmpi.sh
复制代码

里面
  1. echo "==================== Finding Intel MPI from system paths ===================="
  2. check_command mpirun "intelmpi" && MPIRUN="$(command -v mpirun)" || exit
  3. check_command mpiicc "intelmpi" && MPICC="$(command -v mpiicc)" || exit
  4. check_command mpiifort "intelmpi" && MPIFC="$(command -v mpiifort)" || exit
  5. if [ $(command -v mpiicpc >&- 2>&-) ]; then
  6.     check_command mpiicpc "intelmpi" && MPICXX="$(command -v mpiicpc)"
  7. elif [ $(command -v mpic++ >&- 2>&-) ]; then
  8.     check_command mpic++ "intelmpi" && MPICXX="$(command -v mpic++)"
  9. else
  10.     check_command mpicxx "intelmpi" && MPICXX="$(command -v mpicxx)" || exit
  11. fi
  12. add_include_from_paths INTELMPI_CFLAGS "mpi.h" $INCLUDE_PATHS
  13. add_lib_from_paths INTELMPI_LDFLAGS "libmpi.*" $LIB_PATHS
  14. check_lib -lmpi "intelmpi"
  15. check_lib -lmpicxx "intelmpi"
  16. ;;
  17. __DONTUSE__) ;;
复制代码


所有的 mpiicc, mpiifort, 都替换成 mpicc, mpif90 ?


那 mpiicpc 需要修改吗?  如果需要修改,应该修改成什么呢?





作者
Author:
highlight    时间: 2022-4-19 11:57
本帖最后由 highlight 于 2022-4-19 11:58 编辑
乐平 发表于 2022-4-19 10:17
那就是说,把
里面
  1.      check_command mpicc "intelmpi" && MPICC="$(command -v mpicc)" || exit
  2.      check_command mpif90 "intelmpi" && MPIFC="$(command -v mpif90)" || exit
  3.      # if [ $(command -v mpiicpc >&- 2>&-) ]; then
  4.      #  check_command mpiicpc "intelmpi" && MPICXX="$(command -v mpiicpc)"
  5.      # elif [ $(command -v mpic++ >&- 2>&-) ]; then
  6.      #  check_command mpic++ "intelmpi" && MPICXX="$(command -v mpic++)"
  7.      #else
  8.         check_command mpicxx "intelmpi" && MPICXX="$(command -v mpicxx)" || exit
  9.      # fi
复制代码

另外 scripts/common_vars.sh 里 50 行 mpic++ 换成 mpicxx

作者
Author:
乐平    时间: 2022-4-19 14:48
本帖最后由 乐平 于 2022-4-19 08:55 编辑
highlight 发表于 2022-4-19 05:57
另外 scripts/common_vars.sh 里 50 行 mpic++ 换成 mpicxx

谢谢!
按照您的提示将 scripts/stage1/install_interlmpi 中的 mpiicc 修改为 mpicc ,将 mpiifort 改为 mpif90
并将 scripts/common_vars.sh 中 export MPICXX=${MPICXX:-mpic++} 改为 export MPICXX=${MPICXX:-mpicxx}

编译的命令是
  1. ./install_cp2k_toolchain.sh --math-mode=mkl --with-gcc=install --mpi-mode=intelmpi --with-pexsi=install --with-elpa=install --with-ptscotch=install --with-superlu=install --with-quip=install --with-plumed=install
复制代码


但是在 install elpa 这一步报错了……
  1. ==================== Installing ELPA ====================
  2. elpa-2021.11.001.tar.gz is found
  3. patching file nvcc_wrap
  4. Installing from scratch into /public/home/lxb/software/cp2k9_intelmpi/tools/toolchain/install/elpa-2021.11.001/cpu
  5. ERROR: (./scripts/stage5/install_elpa.sh, line 111) Non-zero exit code detected.
复制代码


查看 build/elpa-2021.11.001/build_cpu/configure.log 文件,报错信息是

  1. checking for library containing bi_f77_init... no
  2. checking for library containing blacs_gridinit... none required
  3. checking for library containing blacs_gridinit... (cached) none required
  4. checking for library containing pdtran... none required
  5. checking whether we can link a Fortran program with all blacs/scalapack... yes
  6. checking whether we can use the intrinsic Fortran function "get_environment_variable"... yes
  7. checking whether BAND_TO_FLULL_BLOCKING is requested... yes
  8. checking whether a Nvidia GPU compute capability is specified... yes
  9. checking whether Fortran mpi module can be used... no
  10. configure: error: Could not compile a Fortran program with an 'use mpi' statement. You can try again with --disable-mpi-module
复制代码


从提示的信息来看,不能用 mpi 模式……


之前没有用 intelmpi,而是 --with-openmpi=install 不会在 elpa 这一步报错。


作者
Author:
abin    时间: 2022-4-19 14:55
elpa 使用intel无法直接编译,需做部分修正。
作者
Author:
乐平    时间: 2022-4-19 15:03
abin 发表于 2022-4-19 08:55
elpa 使用intel无法直接编译,需做部分修正。

有趣

在 scripts/stage5/install_elpa.sh 中 35 至 42 代码段中看到 elpa only works with MPI switched on

  1. 35 # elpa only works with MPI switched on
  2. 36 if [ $MPI_MODE = no ]; then
  3. 37   report_warning $LINENO "MPI is disabled, skipping elpa installation"
  4. 38   cat << EOF > "${BUILDDIR}/setup_elpa"
  5. 39 with_elpa="__FALSE__"
  6. 40 EOF
  7. 41   exit 0
  8. 42 fi
复制代码


但是在 build/elpa-2021.11.001/build_cpu/configure.log 文件的报错信息中却看到

  1. configure: error: Could not compile a Fortran program with an 'use mpi' statement. You can try again with --disable-mpi-module
复制代码


一边说 elpa 必须要 MPI 才能运行,一边又说 --disable-mpi-module 。

真是呵呵呵……
作者
Author:
乐平    时间: 2022-4-19 15:15
abin 发表于 2022-4-19 08:55
elpa 使用intel无法直接编译,需做部分修正。

请问,需要部分修正是指在下面的代码中

  1. ../configure --prefix="${pkg_install_dir}/${TARGET}/" \
  2.           --libdir="${pkg_install_dir}/${TARGET}/lib" \
  3.           --enable-openmp=yes \
  4.           --enable-shared=no \
  5.           --enable-static=yes \
复制代码

加上 --disable-mpi-module \ 吗?

作者
Author:
乐平    时间: 2022-4-19 15:25
乐平 发表于 2022-4-19 09:15
请问,需要部分修正是指在下面的代码中

不行……

  1. ../configure --prefix="${pkg_install_dir}/${TARGET}/" \
  2.           --libdir="${pkg_install_dir}/${TARGET}/lib" \
  3.           --enable-openmp=yes \
  4.           --enable-shared=no \
  5.           --enable-static=yes \
  6.           --disable-mpi-module \
复制代码


不是正确方法,依旧报错……

作者
Author:
abin    时间: 2022-4-19 15:44
乐平 发表于 2022-4-19 15:15
请问,需要部分修正是指在下面的代码中

不记得了……
你先试试用intel编译elpa 呗,如有必要……

没有elpa ,也能用的……
作者
Author:
乐平    时间: 2022-4-19 16:33
本帖最后由 乐平 于 2022-4-19 10:39 编辑
gog 发表于 2022-4-11 03:41
9.1版本?还是7.1?这么修改,太复杂了。我搞不懂。
如何用yum 升级 binutil?自定义路径编辑编译?
调 ...

其实直接用
  1. yum install centos-release-scl
  2. yum install devtoolset-9-gcc*
复制代码

gcc 升级到 9.3.1, binutil 就跟着升级到 2.32 了

或者
  1. yum install devtoolset-11-gcc*
复制代码
gcc 升级到 11.2.1, binutil 就跟着升级到 2.32 了

你可以用
  1. ld -v
复制代码

查看版本号,升级之前查看一次,升级之后调用 gcc
  1. scl enable devtoolset-9 bash
复制代码
或者
  1. scl enable devtoolset-11 bash
复制代码

再 ld -v 查看,就知道 binutil 升级好了。




作者
Author:
highlight    时间: 2022-4-19 16:51
乐平 发表于 2022-4-19 14:48
谢谢!
按照您的提示将 scripts/stage1/install_interlmpi 中的 mpiicc 修改为 mpicc ,将 mpiifort 改 ...

注意  --with-gcc=install --mpi-mode=intelmpi 时的输出
install_cp2k_toolchain.sh 里有这么一段
  1.   if [ "$with_gcc" = "__INSTALL__" ]; then
  2.     echo "You have chosen to install GCC, therefore MPI libraries will have to be installed too"
  3.      with_openmpi="__INSTALL__"
  4.      with_mpich="__INSTALL__"
  5.      with_intelmpi="__DONTUSE__"
  6.   fi
  7. fi
复制代码

懂了吧
作者
Author:
乐平    时间: 2022-4-19 18:54
本帖最后由 乐平 于 2022-4-19 13:06 编辑
highlight 发表于 2022-4-19 10:51
注意  --with-gcc=install --mpi-mode=intelmpi 时的输出
install_cp2k_toolchain.sh 里有 ...

谢谢提示!

install_cp2k_toolchain.sh 里还有
  1.   elif (mpirun --version 2>&1 | grep -s -q "Intel"); then
  2.     echo "MPI is detected and it appears to be Intel MPI"
  3.     with_gcc=__DONTUSE__
  4.     export MPI_MODE=intelmpi
复制代码


似乎 gcc=install 和 intelmpi 是互斥的?

我也尝试过  --with-gcc=system  --mpi-mode=intelmpi 的组合(gcc 11.2.1 版),运行到 install libint 会报错……

作者
Author:
leeru    时间: 2022-4-19 23:15
我这边测试过很多组合,devtoolset编译过程没有任何报错,就是运行psmp时显示coredamp,不能运行
作者
Author:
gog    时间: 2022-4-20 08:14
乐平 发表于 2022-4-19 16:33
其实直接用

gcc 升级到 9.3.1, binutil 就跟着升级到 2.32 了

运行不能通过呢。coredamped
作者
Author:
highlight    时间: 2022-4-20 09:05
乐平 发表于 2022-4-19 18:54
谢谢提示!

install_cp2k_toolchain.sh 里还有

你把这里注释掉不就行
可能是编译器版本,也可能是安装的时候配置问题吧, -with-gcc=install 是 11.2.0
作者
Author:
leeru    时间: 2022-4-20 12:59
gog 发表于 2022-4-20 08:14
运行不能通过呢。coredamped

我尝试的结果是必须手动安装gcc到所有节点都可以访问的公共目录,才不会出现coredump
作者
Author:
gog    时间: 2022-4-20 17:04
leeru 发表于 2022-4-20 12:59
我尝试的结果是必须手动安装gcc到所有节点都可以访问的公共目录,才不会出现coredump

用的toolset-9.以前安装过GCC,
centos 7上  gcc不容易编译安装成功。
作者
Author:
乐平    时间: 2022-4-20 19:05
highlight 发表于 2022-4-20 03:05
你把这里注释掉不就行
可能是编译器版本,也可能是安装的时候配置问题吧, -with-gcc=install 是 11.2.0

在 install_cp2k_toolchain.sh 里注释掉了

  1.   elif (mpirun --version 2>&1 | grep -s -q "Intel"); then
  2.     echo "MPI is detected and it appears to be Intel MPI"
  3. #    with_gcc=__DONTUSE__
  4.     export MPI_MODE=intelmpi
复制代码


以及
  1. #else
  2. #  # if gcc is installed, then mpi needs to be installed too
  3. #  if [ "$with_gcc" = "__INSTALL__" ]; then
  4. #    echo "You have chosen to install GCC, therefore MPI libraries will have to be installed too"
  5. #    with_openmpi="__INSTALL__"
  6. #    with_mpich="__INSTALL__"
  7. #    with_intelmpi="__DONTUSE__"
  8. #  fi
复制代码




然后 elpa 报错……

  1. ./install_cp2k_toolchain.sh --math-mode=mkl --with-gcc=install --mpi-mode=intelmpi --with-pexsi=install --with-elpa=install --with-ptscotch=install --with-superlu=install --with-quip=install --with-plumed=install
  2. MPI is detected and it appears to be Intel MPI
  3. Compiling with 16 processes.
  4. ==================== Installing GCC ====================
  5. gcc-11.2.0 is already installed, skipping it.
  6. Step gcc took 0.00 seconds.
  7. ==================== Getting proc arch info using OpenBLAS tools ====================
  8. OpenBLAS detected LIBCORE = haswell
  9. OpenBLAS detected ARCH    = x86_64
  10. ==================== Installing CMake ====================
  11. cmake-3.22.1 is already installed, skipping it.
  12. Step cmake took 0.00 seconds.
  13. ==================== Finding Intel MPI from system paths ====================
  14. path to mpirun is  /public1/apps/intel/compilers_and_libraries_2018.1.163/linux/mpi/intel64/bin/mpirun
  15. path to mpicc is  /public1/apps/intel/compilers_and_libraries_2018.1.163/linux/mpi/intel64/bin/mpicc
  16. path to mpif90 is  /public1/apps/intel/compilers_and_libraries_2018.1.163/linux/mpi/intel64/bin/mpif90
  17. path to mpicxx is  /public1/apps/intel/compilers_and_libraries_2018.1.163/linux/mpi/intel64/bin/mpicxx
  18. Found lib directory /public1/apps/intel/compilers_and_libraries_2018.1.163/linux/mpi/intel64/lib
  19. libmpi is found in ld search path
  20. libmpicxx is found in ld search path
  21. Step intelmpi took 0.00 seconds.
  22. ==================== Finding MKL from system paths ====================
  23. MKLROOT is found to be /public1/apps/intel/compilers_and_libraries_2018.1.163/linux/mkl
  24. libm is found in ld search path
  25. libdl is found in ld search path
  26. Step mkl took 0.00 seconds.
  27. Step fftw took 0.00 seconds.
  28. ==================== Installing LIBINT ====================
  29. libint-2.6.0 is already installed, skipping it.
  30. Step libint took 1.00 seconds.
  31. ==================== Installing LIBXC ====================
  32. libxc-5.1.7 is already installed, skipping it.
  33. Step libxc took 0.00 seconds.
  34. Step libsmm took 0.00 seconds.
  35. ==================== Installing Libxsmm ====================
  36. libxsmm-1.17.tar.gz is found
  37. Installing from scratch into /public2/wanghuan/cp2k9i/tools/toolchain/install/libxsmm-1.17
  38. Step libxsmm took 19.00 seconds.
  39. Step scalapack took 0.00 seconds.
  40. ==================== Installing COSMA ====================
  41. COSMA-v2.5.1.tar.gz is found
  42. Installing from scratch into /public2/wanghuan/cp2k9i/tools/toolchain/install/COSMA-2.5.1
  43. Step cosma took 25.00 seconds.
  44. ==================== Installing ELPA ====================
  45. elpa-2021.11.001.tar.gz is found
  46. patching file nvcc_wrap
  47. Installing from scratch into /public2/wanghuan/cp2k9i/tools/toolchain/install/elpa-2021.11.001/cpu
  48. ERROR: (./scripts/stage5/install_elpa.sh, line 111) Non-zero exit code detected.

复制代码



作者
Author:
leeru    时间: 2022-4-20 19:32
乐平 发表于 2022-4-20 19:05
在 install_cp2k_toolchain.sh 里注释掉了



elpa报错可能是因为binutil的问题,我升级到2.37就没有问题了
作者
Author:
乐平    时间: 2022-4-21 10:26
leeru 发表于 2022-4-20 06:59
我尝试的结果是必须手动安装gcc到所有节点都可以访问的公共目录,才不会出现coredump

我是在所有节点上(包括管理节点和计算节点)都
  1. yum install centos-release-scl
  2. yum install devtoolset-9-gcc*f
复制代码


作者
Author:
leeru    时间: 2022-4-21 11:14
乐平 发表于 2022-4-21 10:26
我是在所有节点上(包括管理节点和计算节点)都

我之前也这么做,也不行,还是要手动编译gcc到其他的公共目录
作者
Author:
southcrux    时间: 2022-4-21 11:15
老师们有遇到过psmp安装后速度很慢的问题吗?我这里编译过程和楼主差不多,只是没有安装elpa,以及使用的是ubuntu不是centos。编译以后ssmp版本测试非常顺利,速度也很快。但是使用了集群上的四台机器共160个核进行psmp测试却发现运算速度极为缓慢。elpa有这么重要吗?
作者
Author:
乐平    时间: 2022-4-21 11:20
leeru 发表于 2022-4-21 05:14
我之前也这么做,也不行,还是要手动编译gcc到其他的公共目录

我之前编译 CP2K-7.1 的时候是所以所有节点 yum install devtoolset-9-gcc* ,可以正常运行,测试也全部通过。

CP2K-9.1 类似地  yum install devtoolset-11-gcc*  处理,编译就各种问题……
作者
Author:
highlight    时间: 2022-4-21 12:13
乐平 发表于 2022-4-20 19:05
在 install_cp2k_toolchain.sh 里注释掉了

我用 yum 安装的 oneapi 最新版,会不会是 2018 跟 gcc 11 有啥兼容问题呢?
作者
Author:
乐平    时间: 2022-4-21 12:24
highlight 发表于 2022-4-21 06:13
我用 yum 安装的 oneapi 最新版,会不会是 2018 跟 gcc 11 有啥兼容问题呢?

oneAPI BaseKit 2022.1.2.146  和  HPCKit 2022.1.2.117 吗?


作者
Author:
leeru    时间: 2022-4-21 12:48
southcrux 发表于 2022-4-21 11:15
老师们有遇到过psmp安装后速度很慢的问题吗?我这里编译过程和楼主差不多,只是没有安装elpa,以及使用的是 ...

psmp慢可能是并行环境的问题,如果使用的是IB卡互联,mpich似乎不支持IB卡,换openmpi就可以了。
作者
Author:
highlight    时间: 2022-4-21 15:58
乐平 发表于 2022-4-21 12:24
oneAPI BaseKit 2022.1.2.146  和  HPCKit 2022.1.2.117 吗?


紫薯布丁
作者
Author:
southcrux    时间: 2022-4-26 04:44
本帖最后由 southcrux 于 2022-4-26 05:37 编辑
leeru 发表于 2022-4-21 12:48
psmp慢可能是并行环境的问题,如果使用的是IB卡互联,mpich似乎不支持IB卡,换openmpi就可以了。

谢谢!后来试了一下把运算节点增加到四个就能通过make test了,但是运行起来和学校编译的在另一个cluster上的版本相比还是慢了很多
作者
Author:
乐平    时间: 2022-4-27 15:25
本帖最后由 乐平 于 2022-4-27 09:31 编辑
highlight 发表于 2022-4-21 09:58

在 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
复制代码


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





作者
Author:
abin    时间: 2022-4-27 18:35
本帖最后由 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





作者
Author:
highlight    时间: 2022-4-27 20:46
乐平 发表于 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:是否有大神可以解析下这个坑的成因?
作者
Author:
abin    时间: 2022-4-27 20:57
highlight 发表于 2022-4-27 20:46
首先,提前恭喜一下,我印象里这是成功编译前的最后一个坑了

然后,丰富下描述:

试试租用一台境外网络正常的裸金属服务器试试……我们遇到的很多奇葩问题,
开发者几乎不会遇到。
作者
Author:
乐平    时间: 2022-4-28 12:50
abin 发表于 2022-4-27 14:57
试试租用一台境外网络正常的裸金属服务器试试……我们遇到的很多奇葩问题,
开发者几乎不会遇到。

跟网络无关吧
我都是把所有依赖包下载好了,放到 build 目录下然后再安装的。
作者
Author:
乐平    时间: 2022-4-28 12:53
highlight 发表于 2022-4-27 14:46
首先,提前恭喜一下,我印象里这是成功编译前的最后一个坑了

然后,丰富下描述:

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




作者
Author:
highlight    时间: 2022-4-28 16:33
乐平 发表于 2022-4-28 12:53
emmmmm 我是这个帖子的楼主,此帖到目前为止已经从 Ubuntu 正常安装到 CentOS 7 不正常安装各种填坑,哈 ...

由于 glibc 版本的缘故,使用 wsl ubuntu-20.04 编译出来的没法移植至 centos7,后者应该是现在大多数超算和服务器使用的发行版吧
或许我可以发个帖子说说咋在 wsl 里搞 centos7......
作者
Author:
乐平    时间: 2022-4-28 22:27
本帖最后由 乐平 于 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 开发的。

作者
Author:
abin    时间: 2022-4-28 22:53
可以去华为社区,找他们优化的cp2k7.1
源码优化,
他们自己讲,至少30%以上。

作者
Author:
highlight    时间: 2022-4-29 07:04
乐平 发表于 2022-4-28 22:27
我用的不是 wsl Ubuntu,我是在自己的小工作站上安装的 Ubuntu 20.04 LST

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

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




欢迎光临 计算化学公社 (http://bbs.keinsci.com/) Powered by Discuz! X3.3