参考各位大佬整理的安装过程,随后整理了一份完整的cp2k-9.1安装过程,如下所示:
先开始配置各种环境,编译环境:mkl2020+gcc11.3+openmpi
- 数学库采用intel mkl
source /xxx/intel2020/mkl/bin/mklvars.sh intel64
source /xxx/intel2020/parallel_studio_xe_2020/psxevars.sh
export PATH=/xxx/intel2020/compilers_and_libraries_2020.4.304/linux/mkl:$PATH
- 查看gcc g++ gfortran 这三个的版本
gcc -v
g++ -v
gfortran -v
- 确认cuda正常,nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Tue_May__3_18:49:52_PDT_2022
Cuda compilation tools, release 11.7, V11.7.64
Build cuda_11.7.r11.7/compiler.31294372_0
- 做完上述检查,先解压cp2k-9.1.tar.bz2
tar jxf cp2k-9.1.tar.bz2
cd /xxx /cp2k-9.1/tools/toolchain
- 编译所需插件,cp2k相关依赖包放在cp2k-9.1/tools/toolchain/build/中,有些包比较大,可以提前下载好(https://www.cp2k.org/static/downloads/),放在该文件夹中
./install_cp2k_toolchain.sh --with-mkl=system --with-openmpi=install --with-cmake=system --with-libsmm=install --with-ptscotch=install --with-superlu=install --with-pexsi=install --with-plumed=install --enable-cuda=yes --gpu-ver=V100 -j 40
ps:openmpi我本身系统也装的有,还是选择install,不影响;其中gpu-ver根据./install_cp2k_toolchain.sh --help只有K20X, K40, K80, P100, V100可选,查询https://en.wikipedia.org/wiki/CUDA,选择一个和你显卡算力最接近的选项,我这里选V100,-j X,X指并行编译用的核数
MPI is detected and it appears to be OpenMPI
==================== Finding GCC from system paths ====================
path to gcc is /usr/bin/gcc
path to g++ is /usr/bin/g++
path to gfortran is /usr/bin/gfortran
Found include directory /usr/include
Step gcc took 0.00 seconds.
====================Getting proc arch info using OpenBLAS tools ====================
OpenBLAS-0.3.19.tar.gz is found
OpenBLAS detected LIBCORE = haswell
OpenBLAS detected ARCH = x86_64
==================== Installing CMake from system paths====================
cmake is found to be /xxx/cmake-3.24.1
Step cmake took 0.00 seconds.
==================== Installing OpenMPI ====================
openmpi-4.1.1.tar.gz is found
Installing from scratch into /xxx/cp2k-9.1/tools/toolchain/install/openmpi-4.1.1
Step openmpi took 440.00 seconds.
==================== Finding MKL from system paths ====================
MKLROOT is found to be /xxx/intel2020/compilers_and_libraries_2020.4.304/linux/mkl
libm is found in ld search path
libdl is found in ld search path
Step mkl took 0.00 seconds.
Step fftw took 0.00 seconds.
==================== Installing LIBINT ====================
libint-v2.6.0-cp2k-lmax-5.tgz is found
Installing from scratch into /xxx/cp2k-9.1/tools/toolchain/install/libint-v2.6.0-cp2k-lmax-5
Step libint took 277.00 seconds.
==================== Installing LIBXC ====================
libxc-5.1.7.tar.gz is found
Installing from scratch into /xxx/cp2k-9.1/tools/toolchain/install/libxc-5.1.7
Step libxc took 53.00 seconds.
Step libsmm took 0.00 seconds.
==================== Installing Libxsmm ====================
libxsmm-1.17.tar.gz is found
Installing from scratch into /xxx/cp2k-9.1/tools/toolchain/install/libxsmm-1.17
Step libxsmm took 28.00 seconds.
Step scalapack took 0.00 seconds.
==================== Installing COSMA ====================
COSMA-v2.5.1.tar.gz is found
Installing from scratch into /xxx/cp2k-9.1/tools/toolchain/install/COSMA-2.5.1
Step cosma took 23.00 seconds.
==================== Installing ELPA ====================
elpa-2021.11.001.tar.gz is found
patching file nvcc_wrap
Installing from scratch into /xxx/cp2k-9.1/tools/toolchain/install/elpa-2021.11.001/cpu
Step elpa took 241.00 seconds.
==================== Installing PT-Scotch ====================
scotch_6.0.0.tar.gz is found
Installing from scratch into /xxx/cp2k-9.1/tools/toolchain/install/scotch-6.0.0
Step ptscotch took 4.00 seconds.
==================== Installing SuperLU_DIST ====================
superlu_dist_6.1.0.tar.gz is found
Installing from scratch into /xxx/cp2k-9.1/tools/toolchain/install/superlu_dist-6.1.0
Step superlu took 9.00 seconds.
==================== Installing PEXSI ====================
pexsi_v1.2.0.tar.gz is found
Installing from scratch into /xxx/cp2k-9.1/tools/toolchain/install/pexsi-1.2.0
Step pexsi took 80.00 seconds.
==================== Installing QUIP ====================
QUIP-b4336484fb65b0e73211a8f920ae4361c7c353fd.tar.gz is found
Installing from scratch into /xxx/cp2k-9.1/tools/toolchain/install/quip-b4336484fb65b0e73211a8f920ae4361c7c353fd
Step quip took 241.00 seconds.
==================== Installing gsl ====================
gsl-2.7.tar.gz is found
Installing from scratch into /xxx/cp2k-9.1/tools/toolchain/install/gsl-2.7
Step gsl took 62.00 seconds.
==================== Installing PLUMED ====================
plumed-2.7.3.tgz is found
Installing from scratch into /xxx/cp2k-9.1/tools/toolchain/install/plumed-2.7.3
Step plumed took 50.00 seconds.
==================== Installing hdf5 ====================
hdf5-1.12.0.tar.bz2 is found
Installing from scratch into /xxx/cp2k-9.1/tools/toolchain/install/hdf5-1.12.0
Step hdf5 took 114.00 seconds.
Step libvdwxc took 0.00 seconds.
==================== Installing spglib ====================
spglib-1.16.2.tar.gz is found
Installing from scratch into /xxx/cp2k-9.1/tools/toolchain/install/spglib-1.16.2
Step spglib took 6.00 seconds.
==================== Installing libvori ====================
libvori-210412.tar.gz is found
Installing from scratch into /xxx/cp2k-9.1/tools/toolchain/install/libvori-210412
Step libvori took 19.00 seconds.
==================== Installing spfft ====================
SpFFT-1.0.5.tar.gz is found
Installing from scratch into /xxx/cp2k-9.1/tools/toolchain/install/SpFFT-1.0.5
Step spfft took 5.00 seconds.
==================== Installing spla ====================
SpLA-1.5.2.tar.gz is found
Installing from scratch into /xxx/cp2k-9.1/tools/toolchain/install/SpLA-1.5.2
Step spla took 8.00 seconds.
==================== Installing SIRIUS ====================
sirius_7.3.0.tar.gz is found
Installing from scratch into /xxx/cp2k-9.1/tools/toolchain/install/sirius-7.3.0
patching file cmake/cudalibs_target.cmake
Step sirius took 67.00 seconds.
==================== generating arch files ====================
arch files can be found in the /xxx/cp2k-9.1/tools/toolchain/install/arch subdirectory
Wrote /xxx/cp2k-9.1/tools/toolchain/install/arch/local.ssmp
Wrote /xxx/cp2k-9.1/tools/toolchain/install/arch/local_static.ssmp
Wrote /xxx/cp2k-9.1/tools/toolchain/install/arch/local.sdbg
Wrote /xxx/cp2k-9.1/tools/toolchain/install/arch/local.psmp
Wrote /xxx/cp2k-9.1/tools/toolchain/install/arch/local.pdbg
Wrote /xxx/cp2k-9.1/tools/toolchain/install/arch/local_static.psmp
Wrote /xxx/cp2k-9.1/tools/toolchain/install/arch/local_warn.psmp
Wrote /xxx/cp2k-9.1/tools/toolchain/install/arch/local_coverage.pdbg
========================== usage =========================
Done!
Now copy:
cp /xxx/cp2k-9.1/tools/toolchain/install/arch/* to the cp2k/arch/ directory
To use the installed tools and libraries and cp2k version
compiled with it you will first need to execute at the prompt:
source /xxx/cp2k-9.1/tools/toolchain/install/setup
To build CP2K you should change directory:
cd cp2k/
make -j 96 ARCH=local VERSION="ssmp sdbg psmp pdbg"
arch files for GPU enabled CUDA versions are named "local_cuda.*"
arch files for GPU enabled HIP versions are named "local_hip.*"
arch files for coverage versions are named "local_coverage.*"
Note that these pre-built arch files are for the GNU compiler, users have to adapt them for other compilers.
It is possible to use the provided CP2K arch files as guidance.
[xxx@elogin toolchain]$
- 接着把 /xxx/cp2k-9.1/tools/toolchain/install/arch/下所有文件拷到 /xxx/cp2k-9.1/arch目录下
cp /xxx/cp2k-9.1/tools/toolchain/install/arch/* /xxx/cp2k-9.1/arch/
然后运行
source /xxx/cp2k-9.1/tools/toolchain/install/setup
cd /xxx/cp2k-9.1
make -j X ARCH=local VERSION="ssmp sdbg psmp pdbg" X指并行编译用的核数,我设的30,大概20分钟左右,编译完最后会输出
cd /xxx/cp2k-9.1/exe/local; ln -sf cp2k.psmp cp2k_shell.psmp
cd /xxx/cp2k-9.1/exe/local; ln -sf cp2k.psmp cp2k.popt
- 测试 make -j 40 ARCH=local VERSION="ssmp sdbg psmp pdbg" test
--------------------------------- Summary --------------------------------
Number of FAILED tests 0
Number of WRONG tests 0
Number of CORRECT tests 3392
Total number of tests 3392
GREPME 0 0 3392 0 3392 X
Summary: correct: 3392 / 3392; 9min
Status: OK
--------------------------------------------------------------------------
Regtest took 526.00 seconds.
--------------------------------------------------------------------------
*************************** testing ended ********************************
- 配置环境
source /xxx/cp2k-8.1/tools/toolchain/install/setup
export PATH=/xxx/cp2k-8.1/exe/local: $PATH
执行安装依赖包过程中可能遇到的错误
(1)binutls 版本过旧,会导致 libxsmm 编译出现类似如下报错:
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
在这里,根据(cp2k9.1编译_mpi is detected and it appears to be intel mpi-CSDN博客)推文,通过给 make 加参数 INTRINSICS=1,即在/xxx/cp2k-9.1/tools/toolchain/scripts/stage4/install_libxsmm.sh 第 70 行以及第 76 添加 INTRINSICS=1 ,亲测可以解决该错误。
make INTRINSICS=1 -j $(get_nprocs) \
(2)ld cannot find -lcuda
我在===== generating arch files ===== 这一步
arch files can be found in the /xxx/cp2k-9.1/tools/toolchain/install/arch subdirectory时,提示我ERROR: (./scripts/generate_arch_files.sh) ld cannot find -lcuda, please check if cuda is installed or in system search path,原因是由于找不到libcuda.so这个库,然后我在我安装的/xxx/cuda11.7.0/targets/x86_64-linux/lib/stubs目录下找到了libcuda.so,因此在 .bashrc文件中加入
export LD_LIBRARY_PATH=/xxx/cuda11.7.0/targets/x86_64-linux/lib/stubs:$LD_LIBRARY_PATH
本身系统写了export LD_LIBRARY_PATH=/xxx/cuda11.7.0/lib64:$LD_LIBRARY_PATH,定义了cuda库的位置,不知道为啥没找到。