计算化学公社

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

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

[复制链接 Copy URL]

1060

帖子

0

威望

3254

eV
积分
4314

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

2301

帖子

1

威望

5473

eV
积分
7794

Level 6 (一方通行)

2#
发表于 Post on 2022-3-8 11:14:34 | 只看该作者 Only view this author
采用默认指令编译的,
和官方提供的预编译的二进制, 没啥本质区别.

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

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

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

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

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

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

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

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

以上仅仅代表我的个人言论.
我从未研修过计算机专业, 以上说辞可能存在不当之处.
High-Performance Computing for You
为您专属定制的高性能计算解决方案

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

1060

帖子

0

威望

3254

eV
积分
4314

Level 6 (一方通行)

3#
 楼主 Author| 发表于 Post on 2022-3-8 15:26:48 | 只看该作者 Only view this author
abin 发表于 2022-3-8 05:14
采用默认指令编译的,
和官方提供的预编译的二进制, 没啥本质区别.

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


您也在我说的 Singularity 方法的帖子里回复了我的提问,但是依旧没法运行时事实啊……

2301

帖子

1

威望

5473

eV
积分
7794

Level 6 (一方通行)

4#
发表于 Post on 2022-3-8 15:43:19 | 只看该作者 Only view this author
乐平 发表于 2022-3-8 15:26
谢谢讨论。
但是,我在帖子里也说了

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

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

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

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

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

1060

帖子

0

威望

3254

eV
积分
4314

Level 6 (一方通行)

5#
 楼主 Author| 发表于 Post on 2022-3-8 19:48:04 | 只看该作者 Only view this author
abin 发表于 2022-3-8 09:43
无所谓了,
能解决自己的问题, 就是好方法.

其实并没有完全解决,我只是在自己的小工作站上编译成功了。但是,课题组的集群上由于是老旧的 CentOS 7 还是没编译成功……

185

帖子

1

威望

4133

eV
积分
4338

Level 6 (一方通行)

6#
发表于 Post on 2022-3-22 16:56:57 | 只看该作者 Only view this author
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

评分 Rate

参与人数
Participants 1
eV +5 收起 理由
Reason
乐平 + 5 谢谢分享

查看全部评分 View all ratings

1060

帖子

0

威望

3254

eV
积分
4314

Level 6 (一方通行)

7#
 楼主 Author| 发表于 Post on 2022-3-22 21:31:39 | 只看该作者 Only view this author
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) \
复制代码

78

帖子

0

威望

3306

eV
积分
3384

Level 5 (御坂)

8#
发表于 Post on 2022-3-23 20:55:50 | 只看该作者 Only view this author
乐平 发表于 2022-3-22 21:31
非常感谢!
在 scripts/stage4/install_libxsmm.sh 第 70 行以及第 76 添加 INTRINSICS=1 ,可行!

整个过程中似乎没有用到intel数学库

1060

帖子

0

威望

3254

eV
积分
4314

Level 6 (一方通行)

9#
 楼主 Author| 发表于 Post on 2022-3-23 22:22:57 | 只看该作者 Only view this author
waitingseven 发表于 2022-3-23 14:55
整个过程中似乎没有用到intel数学库

是的,我这个帖子是基于纯 GNU 的,没有用到任何 Intel 相关的东西。

17

帖子

0

威望

225

eV
积分
242

Level 3 能力者

10#
发表于 Post on 2022-4-1 08:11:36 | 只看该作者 Only view this author
我在centos编译的时候,编译顺利通过,ssmp的test全过,但是psmp的就很多time out,要怎么解决呢

17

帖子

0

威望

225

eV
积分
242

Level 3 能力者

11#
发表于 Post on 2022-4-1 08:12:34 | 只看该作者 Only view this author
zhukangg 发表于 2022-4-1 08:11
我在centos编译的时候,编译顺利通过,ssmp的test全过,但是psmp的就很多time out,要怎么解决呢

error文件里有一行“warning: jobserver unavailable: using -j1.  Add `+' to parent make rule”

1060

帖子

0

威望

3254

eV
积分
4314

Level 6 (一方通行)

12#
 楼主 Author| 发表于 Post on 2022-4-1 10:23:02 | 只看该作者 Only view this author
本帖最后由 乐平 于 2022-4-1 04:24 编辑
zhukangg 发表于 2022-4-1 02:11
我在centos编译的时候,编译顺利通过,ssmp的test全过,但是psmp的就很多time out,要怎么解决呢

CentOS 里各种奇怪的问题,不知道怎么解决……

328

帖子

0

威望

1916

eV
积分
2244

Level 5 (御坂)

13#
发表于 Post on 2022-4-10 11:58:30 | 只看该作者 Only view this author
网络惊现自带数千test例子100%通过测试的编译方法。

1236

帖子

1

威望

3495

eV
积分
4751

Level 6 (一方通行)

14#
发表于 Post on 2022-4-10 14:57:31 | 只看该作者 Only view this author
gog 发表于 2022-4-10 11:58
网络惊现自带数千test例子100%通过测试的编译方法。

不发个链接吗

2301

帖子

1

威望

5473

eV
积分
7794

Level 6 (一方通行)

15#
发表于 Post on 2022-4-10 15:29:40 | 只看该作者 Only view this author

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

前后用到的机器不同, 所以测试算例耗时不同.

如有需要, 请自行下载. https://pan.baidu.com/s/1r7PduYXqjn3kpS-ie0H8NQ?pwd=aknc

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

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

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

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

本版积分规则 Credits rule

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

GMT+8, 2024-11-23 15:04 , Processed in 0.185829 second(s), 25 queries , Gzip On.

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