计算化学公社

标题: ABACUS-3.2的安装方法 [打印本页]

作者
Author:
JamesBourbon    时间: 2023-5-22 21:22
标题: ABACUS-3.2的安装方法
本帖最后由 JamesBourbon 于 2024-2-19 19:20 编辑

2024-02-19更新
本帖上方法已经内嵌到ABACUS的toolchain中,可以直接在ABACUS仓库使用toolchain安装ABACUS。
欢迎大家试用国产DFT软件并积极提出建议遇见!


软件介绍:

[ABACUS Documentation — ABACUS documentation (deepmodeling.com)](https://abacus.deepmodeling.com/en/latest/index.html)
[Abacus (ustc.edu.cn)](http://abacus.ustc.edu.cn/main.htm)


声明:本人和深势科技无任何利益关系

目录:

1. ABACUS安装方法简介
2. 基于OpenMPI-OpenBLAS安装
3. 基于OneAPI安装
4. 安装DeePKS支持
5. 安装DeePMD支持

ABACUS安装方法简介

[Easy Installation — ABACUS documentation (deepmodeling.com)](https://abacus.deepmodeling.com/ ... t/easy_install.html)

官网推荐采用OneAPI安装,
MKL里面包含了LAPACK, ScaLAPACK和BLAS需求,
并自带MPI。
但这估计是因为目前主流服务器是intel-u。
AMD-u上oneAPI性能一般来说是略逊于OpenMPI+Openblas思路的()
上述测试结果来自对cp2k-2023.1的测试

一系列测试表明,GNU工具链对ABACUS是最好的,OneAPI工具链运行效率相对偏慢,
并且OneAPI工具链不能很好地实现OMP并行,而ABACUS恰恰又是一个特别地在MPI+OMP并行下运行效率最高的软件。

目前采用GNU方法
(即Openmpi + OpenBLAS + ScaLAPACK 方法)
编译安装得到的abacus最稳定且运行速度最快。
在系列测试中也表现明显
在Intel服务器上测试结果:OneAPI慢约10%(Intel 8358)
在AMD服务器上测试结果:OneAPI慢约50%(AMD 7b12)

注:如果要安装DeePKS特性的话在build的时候需要在build时加入mkl环境;
如果要装DeePMD特性的话要求已经有装好的DeePMD-python环境且GCC版本>=11.1(支持libstdc++.so.6.29)
有许多软件包都是采用cp2k-toolchain先装上去的,稍加修改即可直接用于abacus的编译安装,GNU工具链中主要难点ScaLAPACK和ELPA均可采用cp2k-toolchain直接装上。
文中提到的“toolchain方法”均指利用cp2k-toolchain系列脚本,对依赖进行安装。


GNU方法

0. cmake
采用cmake 3.25.1
可以并建议直接安装,用官网的.sh脚本和gcc编译安装都可以。也可以通过 cp2k 的 toolchain 方法安装得到。
在`$cp2k/tools/toolchain/scripts/stage1/install_cmake.sh`中修改:
  1. # omitted
  2.     echo "==================== Installing CMake ===================="
  3.     cmake_ver="3.25.1"
  4.     if [ "${OPENBLAS_ARCH}" = "arm64" ]; then
  5.       cmake_arch="linux-aarch64"
  6.       cmake_sha256="8491a40148653b99877a49bf5ad6b33b595acc58f7ad2f60b659b63b38bb2cbf"
  7.     elif [ "${OPENBLAS_ARCH}" = "x86_64" ]; then
  8.       cmake_arch="linux-x86_64"
  9.       cmake_sha256="6598da34f0e3a0f763809e25cfdd646aa1d5e4d133c4277821e63ae5cfe09457"
  10.     else
  11.       report_error ${LINENO} \
  12.         "cmake installation for ARCH=${ARCH} is not supported. You can try to use the system installation using the flag --with-cmake=system instead."
  13.       exit 1
  14.     fi
  15.     #pkg_install_dir="${INSTALLDIR}/cmake-${cmake_ver}"
  16.     pkg_install_dir="/data/softwares/cmake/${cmake_ver}"
  17.     install_lock_file="$pkg_install_dir/install_successful"
  18. # omitted
复制代码


1. Openmpi
采用openmpi/4.1.4,
在`$cp2k/tools/toolchain/scripts/stage1/install_openmpi.sh`中修改:
  1. # omitted
  2. case "${with_openmpi}" in
  3.   __INSTALL__)
  4.     echo "==================== Installing OpenMPI ===================="
  5.     #pkg_install_dir="${INSTALLDIR}/openmpi-${openmpi_ver}"
  6.     pkg_install_dir="/data/softwares/openmpi/${openmpi_ver}"
  7.     install_lock_file="$pkg_install_dir/install_successful"
  8.     if verify_checksums "${install_lock_file}"; then
  9. # omitted
复制代码
当然openmpi也可以自己直接装,在configure的时候没啥需要特别设置的


2. OpenBLAS
采用openblas-0.3.21

并类似上述的手动修改脚本内的安装位置
(同时建议手动调优编译选项)
  1. # - line 27
  2. case "${with_openblas}" in
  3.   __INSTALL__)
  4.     echo "==================== Installing OpenBLAS ===================="
  5.     #pkg_install_dir="${INSTALLDIR}/openblas-${openblas_ver}"
  6.     pkg_install_dir="/data/libraries/openblas/${openblas_ver}_cp2k"
  7.     install_lock_file="$pkg_install_dir/install_successful"
  8. # omitted
复制代码
openblas也可以自己根据toolchain脚本的选项自行cmake安装,要写进去的参数不多


3. FFTW3
FFTW3的安装则相对特殊,不能用 cp2k toolchain的默认设置,因为ABACUS同时需要float版本和double版本的fftw3

具体安装方法:
1. 下载安装fftw.3.3.10.tar.gz安装包,这个安装包可以用cp2k离线安装的安装包
2. 解压,进入主目录,用如下脚本,在PREFIX处同时安装float版本和double版本
  1. #!/bin/bash
  2. # for install fftw float/double version, for abacus
  3. # Author: JamesMisaka
  4. # server: AMD-41 date: 2023-04-02

  5. module load openblas openmpi cmake

  6. PREFIX=/data/libraries/fftw/3.3.10

  7. # optimaztion options
  8. # abacus 3.2 required float and double version

  9. # install float(single) version
  10. FFTW_FLAGS="--enable-openmp --enable-mpi --enable-shared --enable-static --enable-float --enable-avx2 --enable-avx --enable-threads --enable-fma --enable-sse --enable-sse2"

  11. # if --enable-sse and --enable-sse2, use float version & single version
  12. # float & double version seems to should be installed separately

  13. # if use intel
  14. # CC=icc F90=ifort F77=ifort

  15. # cleanup
  16. make distclean

  17. # install
  18. ./configure --prefix=$PREFIX $FFTW_FLAGS | tee configure_float.log
  19. make -j `nproc` | tee make_float.log
  20. make -j `nproc` install | tee install_float.log

  21. # install double version
  22. FFTW_FLAGS="--enable-openmp --enable-mpi --enable-shared --enable-static --enable-avx2 --enable-avx --enable-threads --enable-fma"
  23. make distclean
  24. # install
  25. ./configure --prefix=$PREFIX $FFTW_FLAGS | tee configure_double.log
  26. make -j `nproc` | tee make_double.log
  27. make -j `nproc` install | tee install_double.log
复制代码

要求已经装好openblas和openmpi


4. LibXC
2023-04-22更新

建议采用cmake方法自行安装:使用如下脚本:
```bash
#!/bin/bash
# install libxc by gnu
# JamesMisaka
# from https://gitlab.com/jxzou/qcinsta ... 5%99%A8%E7%89%88.md

rm -rf build

module load openmpi openblas cmake

mkdir build && cd build

LIBXC=/data/libraries/libxc/6.0.0

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$LIBXC \
-DBUILD_SHARED_LIBS=YES -DCMAKE_C_COMPILER=gcc \
-DCMAKE_Fortran_COMPILER=gfortran \
-DCMAKE_INSTALL_LIBDIR=lib -DENABLE_FORTRAN=ON \
-DENABLE_CXX=ON -DENABLE_PYTHON=ON \
-DBUILD_TESTING=NO ..

make -j24
make install
```


也可以用toolchain方法安装,但需要加入参数。
建议和openmpi, openblas一起用toolchain方法一次装上

在`$cp2k/tools/toolchain/scripts/stage3/install_openmpi.sh`中
修改安装位置和设置,去掉`--disable-lxc`(似乎是非必要项), 加入`--enable-shared`
  1. # omitted
  2.       # CP2K does not make use of fourth derivatives, so skip their compilation with --disable-lxc
  3.       ./configure --prefix="${pkg_install_dir}" --libdir="${pkg_install_dir}/lib" --enable-shared\
  4.         > configure.log 2>&1 || tail -n ${LOG_LINES} configure.log
  5.       make -j $(get_nprocs) > make.log 2>&1 || tail -n ${LOG_LINES} make.log
  6.       make install > install.log 2>&1 || tail -n ${LOG_LINES} install.log
  7. # omitted
复制代码

如果不加入enable-shared,此libxc将不被abacus识别。
但目前实测加入enable-shared也没法识别,原因不明,依然建议用cmake方法安装。


5. ScaLAPACK
采用toolchain方法安装即可,
建议和openmpi, openblas一起用toolchain方法一次装上。

在`$cp2k/tools/toolchain/scripts/stage1/install_openmpi.sh`中
修改安装位置和设置,
修改cmake选项`-DBUILD_SHARED_LIBS=YES` (默认NO)
  1. # omitted
  2. case "$with_scalapack" in
  3.   __INSTALL__)
  4.     echo "==================== Installing ScaLAPACK ===================="
  5.     #pkg_install_dir="${INSTALLDIR}/scalapack-${scalapack_ver}"
  6.     pkg_install_dir="/data/libraries/scalapack/${scalapack_ver}"
  7.     install_lock_file="$pkg_install_dir/install_successful"
  8.     if verify_checksums "${install_lock_file}"; then
  9. # omitted
  10.       if ("${FC}" --version | grep -q 'GNU'); then
  11.         flags=$(allowed_gfortran_flags "-fallow-argument-mismatch")
  12.       fi
  13.       FFLAGS=$flags cmake -DCMAKE_FIND_ROOT_PATH="$ROOTDIR" \
  14.         -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \
  15.         -DCMAKE_INSTALL_LIBDIR="lib" \
  16.         -DBUILD_SHARED_LIBS=YES \ # default no ,need change
  17.         -DCMAKE_BUILD_TYPE=Release .. \
  18.         -DBUILD_TESTING=NO \
  19.         -DSCALAPACK_BUILD_TESTS=NO \
  20.         > configure.log 2>&1 || tail -n ${LOG_LINES} configure.log
  21. # omitted
复制代码

6. ELPA
采用toolchain方法安装即可,但有多处要修改
1. ABACUS 暂时不兼容elpa-2022.11.001,需要用2021.11.002.:
elpa-2022中有函数名字发生了改变才导致不兼容,据说可以手动修改,
开发者似乎在issue上面提到它们打算利用elpa的新特性,
但总归暂时不太行。,=
需要到 [Index of /static/downloads (cp2k.org)](https://www.cp2k.org/static/downloads/)处下载elpa-2021.11.002.tar.gz
将它copy到toolchain/build文件夹下

2. 采用toolchain方法安装:
最好和 openmpi, openblas,scalapack 一起用 toolchain 方法一次装上,
不然后续用 system 的 openmpi, openblas 的时候容易编译报错,
原因不明,可能来自于环境变量设置。


在`$cp2k/tools/toolchain/scripts/stage1/install_openmpi.sh`中修改:
-  elpa版本,安装位置
-  configure选项,打开enable-shared
  1. # omitted
  2. # From <a href="https://elpa.mpcdf.mpg.de/software/tarball-archive/ELPA_TARBALL_ARCHIVE.html" target="_blank">https://elpa.mpcdf.mpg.de/softwa ... ARBALL_ARCHIVE.html</a>
  3. # elpa_ver="2022.11.001"
  4. elpa_ver="2021.11.002"
  5. #elpa_sha256="35e397d7c0af95bb43bc7bef7fff29425c1da400fa0cd86ae8d3bd2ff2f9d999"
  6. # omitted
  7. case "$with_elpa" in
  8.   __INSTALL__)
  9.     echo "==================== Installing ELPA ===================="
  10.     #pkg_install_dir="${INSTALLDIR}/elpa-${elpa_ver}"
  11.     pkg_install_dir="/data/libraries/elpa/${elpa_ver}"
  12.     install_lock_file="$pkg_install_dir/install_successful"
  13.     enable_openmp="yes"
  14. # omitted
  15.         cd "build_${TARGET}"
  16.         ../configure --prefix="${pkg_install_dir}/${TARGET}/" \
  17.           --libdir="${pkg_install_dir}/${TARGET}/lib" \
  18.           --enable-openmp=${enable_openmp} \
  19.           --enable-shared=yes \ # default no : need change
  20.           --enable-static=yes \
  21.           --disable-c-tests \
  22.           --disable-cpp-tests \
  23. # omitted
复制代码

安装完毕之后进入到`elpa/include/`目录下,进行如下操作:
  1. ln -s ./elpa_openmp-2021.11.002 ./elpa
复制代码
创建软链接使abacus能识别到elpa的include

7. toolchain检查
这些都做完之后就可以采用toolchain方法安装了。
由于FFTW的特别性,可能最好先用toolchain方法或自行编译方法安装cmake ,openmpi, openblas以方便编译。
为了确认,最终也可以再跑一次toolchain安装,具体方法

  1. #!/bin/bash
  2. # install cp2k as openmpi-openblas
  3. # can be used to install dependence of gpaw and abacus

  4. module load fftw plumed
  5. # 这里load plumed是因为我plumed也是自定义路径的
  6. # 也可以install,只要有token就不会覆盖安装
  7. # libint同理也是自定义路径的,但不会覆盖安装

  8. ./install_cp2k_toolchain.sh --with-openblas=install \
  9.         --with-intel=no \
  10.         --with-gcc=system \
  11.         --with-cmake=install \
  12.         --with-openmpi=install \
  13.         --with-scalapack=install \
  14.         --with-elpa=install \
  15.         --with-libint=install \
  16.         --with-libxc=install \
  17.         --with-sirius=no \
  18.         --with-fftw=system \
  19.         --with-plumed=system \
复制代码

8. CEREAL
直接官网下载即可,在ABACUS安装时指定对应INCLUDE文件夹路径就行

9. ABACUS
终于,我们来到了本体。在上述动作都做完之后,通过module方法或其他方法将上述库加入到环境变量中,通过如下脚本安装:

  1. #!/bin/bash
  2. # compile and install abacus-3.2.0
  3. # JamesMisaka in 2023.04.02
  4. # TMC AMD-41 Server

  5. # rm -rf ./build/

  6. module load cmake fftw openmpi/4.1.4 openblas elpa/2021.11.002 libxc scalapack
  7. # needed:cmake, openmpi, openblas , libxc(sometimes)

  8. PREFIX=/data/softwares/abacus/3.2.0_openmpi
  9. LAPACK=/data/libraries/openblas/0.3.21_cp2k/lib
  10. SCALAPACK=/data/libraries/scalapack/2.2.1/lib
  11. #ELPA=/data/libraries/elpa/2022.11.001/cpu
  12. ELPA=/data/libraries/elpa/2021.11.002/cpu
  13. FFTW3=/data/libraries/fftw/3.3.10
  14. CEREAL=/data/libraries/cereal/include/cereal
  15. LIBXC=/data/libraries/libxc/6.0.0

  16. CXX=mpicxx

  17. cmake -B build -DCMAKE_INSTALL_PREFIX=$PREFIX \
  18.         -DMPI_CXX_COMPILER=mpicxx \
  19.         -DLAPACK_DIR=$LAPACK \
  20.         -DSCALAPACK_DIR=$SCALAPACK \
  21.         -DELPA_DIR=$ELPA \
  22.         -DFFTW3_DIR=$FFTW3 \
  23.         -DCEREAL_INCLUDE_DIR=$CEREAL \
  24.         -DLibxc_DIR=$LIBXC \
  25.         -DENABLE_LCAO=ON \
  26.         -DENABLE_LIBXC=ON \
  27.         -DUSE_OPENMP=ON \
  28.         -DENABLE_ASAN=OFF \
  29.         -DUSE_ELPA=ON | tee configure.log

  30. cmake --build build -j `nproc` | tee build.log
  31. cmake --install build | tee install.log
复制代码

即可将abacus成功安装在PREFIX下。
目前服务器上的abacus运算测试均通过

注:目前abacus存在内存泄漏问题,如果在编译的时候,
加入ENABLE_ASAN=on选项就能看到,
不过这个选项是用于开发的,在生产中不推荐,会拖慢速度,
这方面的问题有待开发者进一步更新

OneAPI方法
基于Intel-OneAPI方法进行安装是ABACUS教程推荐的安装方法。

具体流程
1. 使用toolchain方法编译安装elpa,单独安装libxc
如果对cp2k安装有印象的话就知道oneapi装cp2k时,
libint是需要单独安装的,不过我们abacus也用不到libint,这里也可以默认安装
  1. #!/bin/bash
  2. # install cp2k as oneapi, also use for abacus and gpaw

  3. module load icc mkl mpi compiler plumed
  4. module load cmake libint
  5. ./install_cp2k_toolchain.sh --with-openblas=no \
  6.         --with-intel=system \
  7.         --with-gcc=no \
  8.         --with-cmake=system \
  9.         --with-openmpi=no \
  10.         --with-scalapack=system \
  11.         --with-libint=system \
  12.         --with-libxc=install \
  13.         --with-sirius=no \
  14.         --with-elpa=install \
  15.         --with-fftw=system \
  16.         --with-plumed=system \
  17.         --with-quip=no \
  18.         --with-pexsi=no \
  19.         --with-superlu=no \
  20.         --with-ptscotch=no
复制代码
在使用toolchain安装之前所需要做的脚本调整与之前一致,
需要注意intel-OneAPI编译的elpa和libxc要与gcc-openblas编译的elpa和libxc区分开来,工具链之间不能杂化()
libxc建议采用cmake方法单独安装:
  1. !/bin/bash
  2. # build by oneapi
  3. mkdir build && cd build

  4. module load mkl mpi icc compiler cmake

  5. cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME/lib/libxc/6.0.0_oneapi \
  6. -DBUILD_SHARED_LIBS=YES -DCMAKE_C_COMPILER=icc \
  7. -DCMAKE_Fortran_COMPILER=ifort -DCMAKE_CXX_COMPILER=icpc \
  8. -DCMAKE_INSTALL_LIBDIR=lib -DENABLE_FORTRAN=ON -DENABLE_PYTHON=ON -DENABLE_CXX=ON \
  9. -DBUILD_TESTING=NO ..

  10. make -j `nproc`
  11. make install
复制代码

2.编译安装
在abacus的目录下运行如下脚本,注意确认路径

  1. #!/bin/bash
  2. # install abacus by oneapi
  3. # JamesMisaka in 2023-04-02
  4. # TMC AMD-41 Server

  5. # using oneapi
  6. module load cmake mkl icc mpi compiler elpa/2021.11.002_oneapi libxc

  7. PREFIX="/data/softwares/abacus/3.2.0_oneapi"
  8. ELPA="/data/libraries/elpa/2021.11.002_oneapi/cpu"
  9. CEREAL="/data/libraries/cereal/include/cereal"
  10. LIBXC="/data/libraries/libxc/6.0.0_oneapi/"

  11. # if ELPA_INCLUDE_DIR not find: do
  12. # ln -s $ELPA/include/elpa-****/elpa $ELPA/include/elpa

  13. CC=icc
  14. CXX=icpc
  15. F90=ifort
  16. F77=ifort

  17. cmake -B build -DCMAKE_INSTALL_PREFIX=${PREFIX} \
  18.         -DMPI_CXX_COMPILER=mpiicpc \
  19.         -DMKLROOT=$MKLROOT \
  20.         -DELPA_DIR=${ELPA} \
  21.         -DCEREAL_INCLUDE_DIR=${CEREAL} \
  22.         -DLibxc_DIR=${LIBXC} \
  23.         -DENABLE_LCAO=ON \
  24.         -DENABLE_LIBXC=ON \
  25.         -DUSE_OPENMP=ON \
  26.         -DENABLE_ASAN=OFF \
  27.         -DUSE_ELPA=ON | tee configure.log

  28. cmake --build build -j 16 | tee build.log
  29. cmake --install build | tee install.log
复制代码

即可成功安装,目前实测运行正常,虽然在AMD41上的运行效率远低于OpenBlas版本.

关于安装过程和计算效率的一些讨论可见:
[Failed to Install ABACUS · Issue #2173 · deepmodeling/abacus-develop (github.com)](https://github.com/deepmodeling/abacus-develop/issues/2173)

安装有DeepKS支持的ABACUS

GNU方法

此前尝试openblas-openmpi安装,但一直不太行
直接编译安装时,在configure阶段不会报错,但在build阶段报错:

-
- Build files have been written to: /data/softwares/abacus/abacus-develop/build
[  0%] Built target psi
[  1%] Built target hamilt_general
[  1%] Built target symmetry
[  2%] Built target tddft
[  3%] Built target hamilt_ofdft
[  4%] Built target genelpa
[  6%] Built target neighbor
[  7%] Built target driver
[  9%] Built target vdw
[ 14%] Built target device
[ 17%] Built target planewave
[ 19%] Built target hsolver
[ 20%] Built target operator_ks_pw
[ 22%] Built target hamilt_stodft
[ 25%] Built target orb
[ 29%] Built target dftu
[ 31%] Built target xc_
[ 35%] Built target cell
[ 36%] Built target md
[ 39%] Built target surchem
[ 42%] Built target io_advanced
[ 46%] Built target relax
[ 57%] Built target base
[ 62%] Built target gint
[ 71%] Built target io_basic
[ 78%] Built target hamilt_pwdft
[ 80%] Built target operator_ks_lcao
[ 85%] Built target esolver
[ 90%] Built target elecstate
[ 90%] Building CXX object source/module_hamilt_lcao/module_deepks/CMakeFiles/deepks.dir/LCAO_deepks_io.cpp.o
[ 98%] Built target hamilt_lcao
[100%] Built target deepks
[100%] Building CXX object CMakeFiles/abacus.dir/source/main.cpp.o
[100%] Linking CXX executable abacus
/usr/bin/ld: cannot find -lmkl_intel_ilp64
/usr/bin/ld: cannot find -lmkl_intel_thread
/usr/bin/ld: cannot find -lmkl_core
collect2: error: ld returned 1 exit status
gmake[2]: *** [CMakeFiles/abacus.dir/build.make:813: abacus] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:696: CMakeFiles/abacus.dir/all] Error 2
gmake: *** [Makefile:136: all] Error 2

原因集中于libtorch在使用时,会自动寻找环境里的Intel mkl, 似乎libtorch的已编译版都是基于mkl编译的。
要整这个的话可能得自己用openblas编译libtorch,abacus开发者提供的dockerfile里面有纯gnu版本的,据说可以,暂未尝试。
于是想了一个曲线救国的方法,我在configure的时候不加入mkl环境,但在build的时候加载,让libtorch能找到mkl。

  1. #!/bin/bash
  2. # install ABACUS with libxc and deepks
  3. # JamesMisaka in 2023.04.02

  4. # conda activate deepks

  5. #rm -rf build

  6. module load cmake fftw openmpi/4.1.4 openblas elpa/2021.11.002 libxc/6.0.0 scalapack libnpy

  7. PREFIX=/data/softwares/abacus/3.2.0_deepks
  8. LAPACK=/data/libraries/openblas/0.3.21_cp2k/lib
  9. SCALAPACK=/data/libraries/scalapack/2.2.1/lib
  10. #ELPA=/data/libraries/elpa/2022.11.001/cpu
  11. ELPA=/data/libraries/elpa/2021.11.002/cpu
  12. FFTW3=/data/libraries/fftw/3.3.10
  13. CEREAL=/data/libraries/cereal/include/cereal
  14. LIBXC=/data/libraries/libxc/6.0.0
  15. LIBTORCH=/data/libraries/libtorch/2.0.0/share/cmake/Torch
  16. LIBNPY=/data/libraries/libnpy/0.1.0/include/

  17. # in docker.gnu file
  18. #export OMPI_MCA_btl_vader_single_copy_mechanism=none

  19. export CMAKE_PREFIX_PATH=/data/libraries/libtorch/2.0.0/share/cmake/

  20. CXX=mpicxx

  21. cmake -B build -DCMAKE_INSTALL_PREFIX=$PREFIX \
  22.         -DMPI_CXX_COMPILER=mpicxx \
  23.         -DLAPACK_DIR=$LAPACK \
  24.         -DSCALAPACK_DIR=$SCALAPACK \
  25.         -DELPA_DIR=$ELPA \
  26.         -DFFTW3_DIR=$FFTW3 \
  27.         -DCEREAL_INCLUDE_DIR=$CEREAL \
  28.         -DLibxc_DIR=$LIBXC \
  29.         -DENABLE_LCAO=ON \
  30.         -DENABLE_LIBXC=ON \
  31.         -DUSE_OPENMP=ON \
  32.         -DENABLE_ASAN=OFF \
  33.         -DUSE_ELPA=ON \
  34.         -DENABLE_DEEPKS=1 \
  35.         -DTorch_DIR=$LIBTORCH \
  36.         -Dlibnpy_INCLUDE_DIR=$LIBNPY \
  37.         | tee configure.log

  38. # add mkl env for libtorch to link
  39. module load mkl

  40. cmake --build build -j `nproc` | tee build.log
  41. cmake --install build | tee install.log
复制代码

编译通过。
经简单测试,计算速度基本在OpenBLAS-OpenMPI版ABACUS正常水平。对deepks的具体支持有待进一步测试

OneAPI方法
采用Intel-OneAPI则简单直接,只需要加入libtorch和libnpy的路径即可。注意一定要加载libnpy环境

  1. #!/bin/bash
  2. # install abacus by oneapi with deepks feature
  3. # JamesMisaka in 2023-04-02
  4. # Server: TMC-AMD41

  5. # using oneapi
  6. module load cmake mkl icc mpi compiler elpa/2021.11.002_oneapi libnpy libxc/6.0.0_oneapi

  7. PREFIX="/data/softwares/abacus/3.2.0_oneapi/"
  8. ELPA="/data/libraries/elpa/2021.11.002_oneapi/cpu"
  9. CEREAL="/data/libraries/cereal/include/cereal"
  10. LIBXC="/data/libraries/libxc/6.0.0_oneapi"
  11. LIBTORCH="/data/libraries/libtorch/2.0.0/share/cmake/Torch"
  12. LIBNPY="/data/libraries/libnpy/0.1.0/include"

  13. # if ELPA_INCLUDE_DIR not find: do
  14. # ln -s $ELPA/include/elpa-****/elpa $ELPA/include/elpa

  15. CC=icc
  16. CXX=icpc
  17. F90=ifort
  18. F77=ifort

  19. cmake -B build -DCMAKE_INSTALL_PREFIX=${PREFIX} \
  20.         -DMKLROOT=$MKLROOT \
  21.         -DELPA_DIR=${ELPA} \
  22.         -DCEREAL_INCLUDE_DIR=${CEREAL} \
  23.         -DLibxc_DIR=${LIBXC} \
  24.         -DENABLE_LCAO=ON \
  25.         -DENABLE_LIBXC=ON \
  26.         -DUSE_OPENMP=ON \
  27.         -DENABLE_ASAN=OFF \
  28.         -DENABLE_DEEPKS=1 \
  29.         -DTorch_DIR=$LIBTORCH \
  30.         -Dlibnpy_INCLUDE_DIR=$LIBNPY \
  31.         -DUSE_ELPA=ON | tee configure.log

  32. cmake --build build -j 16 | tee build.log
  33. cmake --install build | tee install.log
复制代码


安装有DeepMD支持的ABACUS

此处展示GNU方法:
注意:要求gcc版本为11.3及以上,或支持GLIBCXX-3.4.29

  1. #!/bin/bash
  2. # install ABACUS with libxc, deepks, deepmd
  3. # JamesMisaka in 2023.04.23
  4. # platform: AMD-3950X WSL2

  5. # conda activate deepmd

  6. # rm -rf build

  7. module load cmake openmpi/4.1.4 openblas fftw scalapack libxc/6.0.0 libnpy

  8. PREFIX=$HOME/apps/abacus/3.2.0
  9. LAPACK=$HOME/math_lib/openblas/0.3.21/lib
  10. SCALAPACK=$HOME/math_lib/scalapack/2.2.1/lib
  11. #ELPA=/data/libraries/elpa/2022.11.001/cpu
  12. ELPA=$HOME/math_lib/elpa/2021.11.002/cpu
  13. FFTW3=$HOME/math_lib/fftw/3.3.10
  14. CEREAL=$HOME/math_lib/cereal/include/cereal
  15. LIBTORCH=$HOME/math_lib/libtorch/2.0.0/share/cmake/Torch
  16. LIBNPY=$HOME/math_lib/libnpy/0.1.0/include
  17. LIBXC=$HOME/math_lib/libxc/6.0.0
  18. DEEPMD=$HOME/apps/anaconda3/envs/deepmd

  19. CXX=mpicxx

  20. cmake -B build -DCMAKE_INSTALL_PREFIX=$PREFIX \
  21.         -DMPI_CXX_COMPILER=mpicxx \
  22.         -DLAPACK_DIR=$LAPACK \
  23.         -DSCALAPACK_DIR=$SCALAPACK \
  24.         -DELPA_DIR=$ELPA \
  25.         -DFFTW3_DIR=$FFTW3 \
  26.         -DCEREAL_INCLUDE_DIR=$CEREAL \
  27.         -DLibxc_DIR=$LIBXC \
  28.         -DENABLE_LCAO=ON \
  29.         -DENABLE_LIBXC=ON \
  30.         -DUSE_OPENMP=ON \
  31.         -DENABLE_ASAN=OFF \
  32.         -DUSE_ELPA=ON \
  33.         -DENABLE_DEEPKS=1 \
  34.         -DTorch_DIR=$LIBTORCH \
  35.         -Dlibnpy_INCLUDE_DIR=$LIBNPY \
  36.         -DDeePMD_DIR=$DEEPMD \
  37.         -DTensorFlow_DIR=$DEEPMD \
  38.         | tee configure.log

  39. # add mkl env for libtorch to link
  40. module load mkl

  41. cmake --build build -j `nproc` | tee build.log
  42. cmake --install build | tee install.log
复制代码

OneAPI方法同理。
此方法安装deepmd支持的时候会有warning:

-
- Configuring done
CMake Warning at CMakeLists.txt:104 (add_executable):
  Cannot generate a safe runtime search path for target abacus because files
  in some directories may conflict with libraries in implicit directories:

    runtime library [libgomp.so.1] in /usr/lib/gcc/x86_64-linux-gnu/11 may be hidden by files in:
      /home/james/apps/anaconda3/envs/deepmd/lib

  Some of these libraries may not be found correctly.

-- Generating done
-- Build files have been written to: /home/james/source-code/abacus-develop/build

暂未具体测试此方法安装的DeePMD支持性能。








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