|
本帖最后由 乐平 于 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 系统不自带编译器,需要自己安装
- huan@grape:~$ sudo apt-get install make build-essential g++ gfortran
复制代码
我们可以在任意位置编译 CP2K,比如我在 ~/Public 路径下用 tar jxvf 命令解压 cp2k-9.1.tar.bz2 压缩文件。我之前把该压缩文件放在 ~/SoftwareBACKUP/ 路径下。
- huan@grape:~/Public$ tar jxvf ~/SoftwareBACKUP/cp2k-9.1.tar.bz2
复制代码
然后把刚刚解压的 cp2k-9.1 改名为 cp2k91_GNU,以提示自己这个是纯 GNU 编译的,没有用到任何 Intel 的编译器。改名后进入此路径。
- huan@grape:~/Public$ mv cp2k-9.1/ cp2k91_GNU/ && cd cp2k91_GNU/tools/toolchain
复制代码
进入到~/Public/cp2k91_GUN/tools/toolchain 路径后,ls 查看当前路径下有什么文件。
- huan@grape:~/Public/cp2k91_GUN/tools/toolchain$ ls
- Dockerfile Dockerfile.hip_cuda install_cp2k_toolchain.sh install_requirements_ubuntu.sh scripts
- Dockerfile.cuda Dockerfile.hip_rocm install_requirements_fedora.sh install_tensorflow.sh
- Dockerfile.cuda_mkl Dockerfile.ubuntu_nompi install_requirements.sh README.md
复制代码
我们可以先运行 cp2k-9.1 自带的 install_requirements_ubuntu.sh 脚本,用来确认一下系统是否有预先需要的包。感叹一下程序设计者多贴心。
- huan@grape:~/Public/cp2k91_GNU/tools/toolchain$ sudo ./install_requirements_ubuntu.sh
- [sudo] password for huan:
- Installing Ubuntu packages...
- Selecting previously unselected package libopts25:amd64.
- (Reading database ... 182483 files and directories currently installed.)
- Preparing to unpack .../0-libopts25_1%3a5.18.16-3_amd64.deb ...
- Unpacking libopts25:amd64 (1:5.18.16-3) ...
- Selecting previously unselected package libopts25-dev:amd64.
- Preparing to unpack .../1-libopts25-dev_1%3a5.18.16-3_amd64.deb ...
- Unpacking libopts25-dev:amd64 (1:5.18.16-3) ...
- Selecting previously unselected package autogen.
- Preparing to unpack .../2-autogen_1%3a5.18.16-3_amd64.deb ...
- Unpacking autogen (1:5.18.16-3) ...
- Replaced by files in installed package libopts25-dev:amd64 (1:5.18.16-3) ...
- Selecting previously unselected package liberror-perl.
- Preparing to unpack .../3-liberror-perl_0.17029-1_all.deb ...
- Unpacking liberror-perl (0.17029-1) ...
- Selecting previously unselected package git-man.
- Preparing to unpack .../4-git-man_1%3a2.25.1-1ubuntu3.2_all.deb ...
- Unpacking git-man (1:2.25.1-1ubuntu3.2) ...
- Selecting previously unselected package git.
- Preparing to unpack .../5-git_1%3a2.25.1-1ubuntu3.2_amd64.deb ...
- Unpacking git (1:2.25.1-1ubuntu3.2) ...
- Selecting previously unselected package libtool-bin.
- Preparing to unpack .../6-libtool-bin_2.4.6-14_amd64.deb ...
- Unpacking libtool-bin (2.4.6-14) ...
- Setting up libtool-bin (2.4.6-14) ...
- Setting up libopts25:amd64 (1:5.18.16-3) ...
- Setting up liberror-perl (0.17029-1) ...
- Setting up git-man (1:2.25.1-1ubuntu3.2) ...
- Setting up libopts25-dev:amd64 (1:5.18.16-3) ...
- Setting up autogen (1:5.18.16-3) ...
- Setting up git (1:2.25.1-1ubuntu3.2) ...
- Processing triggers for libc-bin (2.31-0ubuntu9.7) ...
- Processing triggers for man-db (2.9.1-1) ...
- Processing triggers for install-info (6.7.0.dfsg.2-5) ...
- 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 桌面版能正常且顺利地安装,所以就尽可能都安装了。
- 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
接下来,就是自动编译的过程,我把所有的结果都呈现出来。
可以看到,过程很顺利,没有任何之前出现的 Error: (./scripts/stageXXinstall_YYY.sh line ZZ) Non-zero exit code detected 之类的幺蛾子。
然后就是按照上面的提示将 toolchain/install/arch/ 路径下的所有文件复制、粘贴到 cp2k91_GNU/arch/ 目录下,并 source 刚刚编译的库环境,再回到 cp2k91_GNU/ 路径下编译可执行程序的过程。
- huan@grape:~/Public/cp2k91_GNU/tools/toolchain$ cp install/arch/* /home/huan/Public/cp2k91_GNU/arch/
- huan@grape:~/Public/cp2k91_GNU/tools/toolchain$
- huan@grape:~/Public/cp2k91_GNU/tools/toolchain$
- huan@grape:~/Public/cp2k91_GNU/tools/toolchain$ source /home/huan/Public/cp2k91_GNU/tools/toolchain/install/setup
- huan@grape:~/Public/cp2k91_GNU/tools/toolchain$
- huan@grape:~/Public/cp2k91_GNU/tools/toolchain$ which mpirun
- /home/huan/Public/cp2k91_GNU/tools/toolchain/install/openmpi-4.1.1/bin/mpirun
- huan@grape:~/Public/cp2k91_GNU/tools/toolchain$
- huan@grape:~/Public/cp2k91_GNU/tools/toolchain$ cd ../..
- huan@grape:~/Public/cp2k91_GNU$ ls
- arch benchmarks data exts INSTALL.md LICENSE Makefile README.md REVISION src tests tools
- huan@grape:~/Public/cp2k91_GNU$
- huan@grape:~/Public/cp2k91_GNU$ make -j 56 ARCH=local VERSION=psmp
复制代码
接下来的编译过程需要等待较长的时间,且有大量的输出。这里只能展示最后 N 行的结果。
- Updating archive /home/huan/Public/cp2k91_GNU/lib/local/psmp/libcp2kstart.a
- ar: creating /home/huan/Public/cp2k91_GNU/lib/local/psmp/libcp2kstart.a
- 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++
- 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++
- /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&)':
- (.text+0xeca5e): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
- /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&)':
- (.text+0xeca5e): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
- cd /home/huan/Public/cp2k91_GNU/exe/local; ln -sf cp2k.psmp cp2k_shell.psmp
- cd /home/huan/Public/cp2k91_GNU/exe/local; ln -sf cp2k.psmp cp2k.popt
- huan@grape:~/Public/cp2k91_GNU$
- huan@grape:~/Public/cp2k91_GNU$
复制代码
可以看到,最后产生了两个软链接 ln -sf cp2k.psmp cp2k_shell.psmp , ln -sf cp2k.psmp cp2k.popt
cd 进入到 exe/local 路径下
- huan@grape:~/Public/cp2k91_GNU$
- huan@grape:~/Public/cp2k91_GNU$ cd exe/local/ && ll
- total 1.1G
- lrwxrwxrwx 1 huan huan 9 Mar 7 00:55 cp2k.popt -> cp2k.psmp*
- lrwxrwxrwx 1 huan huan 9 Mar 7 00:55 cp2k_shell.psmp -> cp2k.psmp*
- -rwxrwxr-x 1 huan huan 551M Mar 7 00:55 cp2k.psmp*
- -rwxrwxr-x 1 huan huan 551M Mar 7 00:55 libcp2k_unittest.psmp*
- -rwxrwxr-x 1 huan huan 910K Mar 7 00:55 xyz2dcd.psmp*
- -rwxrwxr-x 1 huan huan 960K Mar 7 00:55 dumpdcd.psmp*
- -rwxrwxr-x 1 huan huan 2.5M Mar 7 00:52 grid_unittest.psmp*
- -rwxrwxr-x 1 huan huan 2.5M Mar 7 00:52 grid_miniapp.psmp*
- -rwxrwxr-x 1 huan huan 2.0M Mar 7 00:51 graph.psmp*
- -rwxrwxr-x 1 huan huan 3.5M Mar 7 00:51 parallel_rng_types_unittest.psmp*
- -rwxrwxr-x 1 huan huan 120K Mar 7 00:51 memory_utilities_unittest.psmp*
- huan@grape:~/Public/cp2k91_GNU/exe/local$
复制代码
可以看到已经编译好的可执行程序。一切非常顺利!
接下来可以跑测试,看看编译是否有问题。命令如下:
- huan@grape:~/Public/cp2k91_GNU$ make -j 16 ARCH=local VERSION=psmp test
复制代码
这里请 root 用户注意,可能是 openmpi 限制了 root 用户运行造成的问题,在 /opt 路径下编译 CP2K 的朋友会遇到如下的警告
- *************************** Testing started ****************************
- --------------------------------------------------------------------------
- mpiexec has detected an attempt to run as root.
- Running as root is *strongly* discouraged as any mistake (e.g., in
- defining TMPDIR) or bug can result in catastrophic damage to the OS
- file system, leaving your system in an unusable state.
- We strongly suggest that you run mpiexec as a non-root user.
- You can override this protection by adding the --allow-run-as-root option
- to the cmd line or by setting two environment variables in the following way:
- the variable OMPI_ALLOW_RUN_AS_ROOT=1 to indicate the desire to override this
- protection, and OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 to confirm the choice and
- add one more layer of certainty that you want to do so.
- We reiterate our advice against doing so - please proceed at your own risk.
- --------------------------------------------------------------------------
复制代码 我为什么会知道呢,因为我最开始就是在 /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 再次报错了。
- (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
- WARNING: (./install_cp2k_toolchain.sh, line 329) No MPI installation detected (ignore this message in Cray Linux Environment or when MPI installation was requested).
- You have chosen to install GCC, therefore MPI libraries will have to be installed too
- Compiling with 40 processes.
- ==================== Installing GCC ====================
- gcc-11.2.0.tar.gz is found
- Installing GCC from scratch into /public/home/zhaoyan/cp2k91_GNU/tools/toolchain/install/gcc-11.2.0
- Step gcc took 725.00 seconds.
- ==================== Getting proc arch info using OpenBLAS tools ====================
- OpenBLAS-0.3.19.tar.gz is found
- make: Warning: File `Makefile.conf' has modification time 12 s in the future
- make: warning: Clock skew detected. Your build may be incomplete.
- OpenBLAS detected LIBCORE = haswell
- OpenBLAS detected ARCH = x86_64
- ==================== Installing CMake ====================
- cmake-3.22.1-Linux-x86_64.sh is found
- Installing from scratch into /public/home/zhaoyan/cp2k91_GNU/tools/toolchain/install/cmake-3.22.1
- Step cmake took 8.00 seconds
- ==================== Installing OpenMPI ====================
- openmpi-4.1.1.tar.gz is found
- Installing from scratch into /public/home/zhaoyan/cp2k91_GNU/tools/toolchain/install/openmpi-4.1.1
- Step openmpi took 985.00 seconds.
- ==================== Installing OpenBLAS ====================
- OpenBLAS-0.3.19.tar.gz is found
- Installing from scratch into /public/home/zhaoyan/cp2k91_GNU/tools/toolchain/install/openblas-0.3.19
- Step openblas took 161.00 seconds.
- ==================== Installing FFTW ====================
- fftw-3.3.10.tar.gz is found
- Installing from scratch into /public/home/zhaoyan/cp2k91_GNU/tools/toolchain/install/fftw-3.3.10
- Step fftw took 164.00 seconds.
- ==================== Installing LIBINT ====================
- libint-v2.6.0-cp2k-lmax-5.tgz is found
- Installing from scratch into /public/home/zhaoyan/cp2k91_GNU/tools/toolchain/install/libint-v2.6.0-cp2k-lmax-5
- Step libint took 678.00 seconds.
- ==================== Installing LIBXC ====================
- libxc-5.1.7.tar.gz is found
- Installing from scratch into /public/home/zhaoyan/cp2k91_GNU/tools/toolchain/install/libxc-5.1.7
- Step libxc took 128.00 seconds.
- ==================== Installing libsmm ====================
- Searching for an optimised libsmm binary from CP2K website
- An optimized libsmm libsmm_dnn_haswell-2015-11-10.a is available
- libsmm_dnn_haswell-2015-11-10.a has already been downloaded.
- Step libsmm took 0.00 seconds.
- ==================== Installing Libxsmm ====================
- libxsmm-1.17.tar.gz is found
- Installing from scratch into /public/home/zhaoyan/cp2k91_GNU/tools/toolchain/install/libxsmm-1.17
- ERROR: (./scripts/stage4/install_libxsmm.sh, line 70) Non-zero exit code detected.
- (base) [huan@login01 toolchain]$
复制代码
查看 scripts/stage4/install_libxsmm.sh 的 70 行,是 make 报错
- 67 cd libxsmm-${libxsmm_ver}
- 68 # Avoid an unintended (incompatible) setting of FORTRAN
- 69 unset FORTRAN
- 70 make -j $(get_nprocs) \
- 71 CXX=$CXX \
- 72 CC=$CC \
- 73 FC=$FC \
- 74 PREFIX=${pkg_install_dir} \
- 75 > make.log 2>&1
- 76 make -j $(get_nprocs) \
- 77 CXX=$CXX \
- 78 CC=$CC \
- 79 FC=$FC \
- 80 PREFIX=${pkg_install_dir} \
- 81 install > install.log 2>&1
- 82 cd ..
复制代码
查找报错记录
- (base) [huan@login01 toolchain]$ find -name *.log
复制代码 会出来很多 .log 文件,我们需要看关于安装 libxsmm 有关的 .log,会发现有一个 ./build/libxsmm-1.17/make.log 文件
- ./build/libxc-5.1.7/make.log
- ./build/libxc-5.1.7/install.log
- ./build/libxc-5.1.7/configure.log
- ./build/libxc-5.1.7/config.log
- ./build/libxsmm-1.17/make.log
- ./build/libint-v2.6.0-cp2k-lmax-5/make.log
- ./build/libint-v2.6.0-cp2k-lmax-5/install.log
- ./build/libint-v2.6.0-cp2k-lmax-5/configure.log
- ./build/libint-v2.6.0-cp2k-lmax-5/config.log
复制代码
然后进入 build/libxsmm-1.17/ 路径下查看。最终我发现 make.log 文件最后记录错误为
- 2527 /tmp/ccE3IUdy.s:131284: Error: no such instruction: `vcvtne2ps2bf16 %zmm10,%zmm1,%zmm14'
- 2528 /tmp/ccE3IUdy.s:131305: Error: no such instruction: `vcvtne2ps2bf16 %zmm9,%zmm11,%zmm5'
- 2529 /tmp/ccE3IUdy.s:131310: Error: no such instruction: `vcvtne2ps2bf16 %zmm15,%zmm0,%zmm13'
- 2530 /tmp/ccE3IUdy.s:131316: Error: no such instruction: `vcvtne2ps2bf16 %zmm4,%zmm3,%zmm6'
- 2531 /tmp/ccE3IUdy.s:131322: Error: no such instruction: `vcvtne2ps2bf16 %zmm8,%zmm7,%zmm2'
- 2532 /tmp/ccE3IUdy.s:131328: Error: no such instruction: `vcvtne2ps2bf16 %zmm1,%zmm12,%zmm10'
- 2533 /tmp/ccE3IUdy.s:131334: Error: no such instruction: `vcvtne2ps2bf16 %zmm11,%zmm14,%zmm9'
- 2534 /tmp/ccE3IUdy.s:131340: Error: no such instruction: `vcvtne2ps2bf16 %zmm0,%zmm5,%zmm15'
- 2535 /tmp/ccE3IUdy.s:131351: Error: no such instruction: `vcvtne2ps2bf16 %zmm3,%zmm13,%zmm4'
- 2536 /tmp/ccE3IUdy.s:131355: Error: no such instruction: `vcvtne2ps2bf16 %zmm7,%zmm6,%zmm8'
- 2537 /tmp/ccE3IUdy.s:131360: Error: no such instruction: `vcvtne2ps2bf16 %zmm12,%zmm2,%zmm1'
- 2538 /tmp/ccE3IUdy.s:131365: Error: no such instruction: `vcvtne2ps2bf16 %zmm14,%zmm10,%zmm11'
- 2539 /tmp/ccE3IUdy.s:131370: Error: no such instruction: `vcvtne2ps2bf16 %zmm5,%zmm9,%zmm0'
- 2540 /tmp/ccE3IUdy.s:131376: Error: no such instruction: `vcvtne2ps2bf16 %zmm13,%zmm15,%zmm3'
- 2541 /tmp/ccE3IUdy.s:131380: Error: no such instruction: `vcvtne2ps2bf16 %zmm6,%zmm4,%zmm7'
- 2542 /tmp/ccE3IUdy.s:131384: Error: no such instruction: `vcvtne2ps2bf16 %zmm2,%zmm8,%zmm12'
- 2543 make: [obj/intel64/libxsmm_dnn_rnncell_forward.o] Error 1 (ignored)
- 2544 make: *** [obj/intel64/libxsmm_dnn_rnncell_forward.o] Error 1
复制代码
莫名奇妙啊!
libxsmm 是 CP2K toolchain 默认安装的库。同样的 toolchain 为什么 Ubuntu 20.04 可以正常编译通过,而 CentOS 7 却不行?
-------------------------------------------------------------------------------------------------------------------------------
现在回想一下,之前大家一直纠结和困扰的问题,很可能是因为系统太老旧的缘故造成的。CP2K 又是一个特别挑剔编译器的程序,编译器的小版本号不一样,都很可能造成编译不成功的现象。对于我们这样的普通用户,没有太深入的编程背景,很多情况下是束手无策的。
再次感叹,系统不能太旧,不然麻烦太多。装机器的时候能用较为新的系统就不要用老旧的系统。对于已有的集群,最好能在假期前联系工程师更新系统。
|
评分 Rate
-
查看全部评分 View all ratings
|