计算化学公社

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

[VASP] VASP6.5.0+Intel CPU编译并添加module环境

[复制链接 Copy URL]

11

帖子

1

威望

68

eV
积分
99

Level 2 能力者

跳转到指定楼层 Go to specific reply
楼主
本帖最后由 Tosykie 于 2024-12-24 06:49 编辑

听闻VASP有重大更新,课题组恰好购买了版权。作为课题组服务器的(免费)维护员,特来尝试编译一下新版。
6.5.0 (December 17, 2024)主要新特性:电声耦合


服务器软硬件概要:
  • CPU:双路 Intel 第三代至强
  • 节点数:3

# 登录节点CPU的型号/主频等和计算节点不同,计算节点采用了核心更多,主频稍高的Gold 6336Y CPU @ 2.40GHz
$ lscpu
Architecture:            x86_64
   CPU op-mode(s):        32-bit, 64-bit
   Address sizes:         46 bits physical, 57 bits virtual
   Byte Order:            Little Endian
CPU(s):                  80
   On-line CPU(s) list:   0-79
Vendor ID:               GenuineIntel
   Model name:            Intel(R) Xeon(R) Silver 4316 CPU @ 2.30GHz
     CPU family:          6
     Model:               106
     Thread(s) per core:  2
     Core(s) per socket:  20
     Socket(s):           2
     ......
  • 操作系统:Ubuntu 22.04 LTS Server (Jammy)

$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.4 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.4 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
......

0. 编译环境准备
Intel OneAPI 套件
$ module avail -t intel
/mnt/data/apps/modules/programming/compilers:
intel-oneapi/2023.2
intel-oneapi/2024.0
intel-oneapi/2024.1
笔者的服务器上安装了三个OneAPI套件版本。这里选择intel-oneapi/2023.2。
关于OneAPI版本:
intel-oneapi/2023.2是这一系列套件中最后一个支持经典C/C++/Fortran编译器的版本, 也就是icc/icpc/ifort。
“Intel® C++ Compiler Classic (icc) is deprecated and was discontinued in the oneAPI 2024.0 release.”
对于只支持经典C/C++/Fortran的VASP版本,比如VASP5.4.4,需要使用OneAPI <=2023.2,在>=2024的OneAPI的套件里,已经弃用了icc/icpx/ifort这三个编译器,而是换成了icx/icpx/ifx这几个基于LLVM的编译器。
Intel官网不能再下载到老版本的编译套件了,但是笔者发现一个可用的仓库,存放了老版的安装包(包括了已经弃用的Intel Parallel Studio):[color=var(--main-6)]https://get.hpc.dev/vault/intel/
如果读者不喜欢Intel,VASP官网还提供了能用于编译VASP兼容工具链:[color=var(--main-6)]https://www.vasp.at/wiki/index.php/Toolchains
可选择使用GCC+OpenMPI替代,并加配FFTW3+SCALAPACK等数学库替代MKL。

VASP开发组强烈建议添加HDF5支持来增强I/O,笔者之前也编译了多个HDF5。
$ module avail -t hdf5
/mnt/data/apps/modules/libraries/io:
hdf5/1.12.3-gcc8
hdf5/1.12.3-gcc8-mpi
hdf5/1.12.3-gcc11
hdf5/1.12.3-intel-oneapi2023.2
hdf5/1.12.3-intel-oneapi2023.2-mpi
读者可根据上述兼容工具链的网址里挑选兼容的HDF5版本。这里选择hdf5/1.12.3-intel-oneapi2023.2-mpi。


1. 编译1.1 加载环境
带有[color=var(--main-6)]module的系统
$ module load intel-oneapi/2023.2
$ module load compiler mpi mkl
$ module load hdf5/1.12.3-intel-oneapi2023.2-mpi
不带module的系统
使用类似
$ source /opt/intel/oneapi/setvars.sh
$ source /opt/intel/oneapi/compiler/latest/env/vars.sh intel64
/opt/intel/具体换为读者所安装OneAPI的路径
注意事项:如果读者是自己手动安装OneAPI,例如是2023.2.4版本,intel mpi相关的编译器和LIB可能不能直接加载到PATH和LD_LIBRARY_PATH里,导致mpiifort not found读者需要自己手动定位mpi的路径进行修复。
1.2 解压VASP6.5.0源码 $ tar -xzf vasp.6.5.0.tgz
$ cd vasp.6.5.0
$ ls
arch/     src/    build/  makefile    README_ELPHON.md
......
1.3 C/C++/Fortran Classic
先尝试用C/C++ Classic
$ cp arch/makefile.include.intel ./makefile.include
$ vim makefile.include
修改 makefile.include,一个参考:
# Default precompiler options
CPP_OPTIONS = -DHOST=\"Khompute\" \
               -DMPI -DMPI_BLOCK=8000 -Duse_collective \
               -DscaLAPACK \
               -DCACHE_SIZE=4000 \
               -Davoidalloc \
               -Dvasp6 \
               -Dtbdyn \
               -Dfock_dblbuf

CPP         = fpp -f_com=no -free -w0  $*$(FUFFIX) $*$(SUFFIX) $(CPP_OPTIONS)

FC          = mpiifort
FCL         = mpiifort

FREE        = -free -names lowercase

FFLAGS      = -assume byterecl -w

OFLAG       = -O2
OFLAG_IN    = $(OFLAG)
DEBUG       = -O0

# For what used to be vasp.5.lib
CPP_LIB     = $(CPP)
FC_LIB      = $(FC)
CC_LIB      = icc -diag-disable=10441
CFLAGS_LIB  = -O
FFLAGS_LIB  = -O1
FREE_LIB    = $(FREE)

OBJECTS_LIB = linpack_double.o

# For the parser library
CXX_PARS    = icpc -diag-disable=10441
LLIBS       = -lstdc++

##
## Customize as of this point! Of course you may change the preceding
## part of this file as well if you like, but it should rarely be
## necessary ...
##

# When compiling on the target machine itself, change this to the
# relevant target when cross-compiling for another architecture
VASP_TARGET_CPU ?= -xHOST
FFLAGS     += $(VASP_TARGET_CPU)

# Intel MKL (FFTW, BLAS, LAPACK, and scaLAPACK)
# (Note: for Intel Parallel Studio's MKL use -mkl instead of -qmkl)
FCL        += -qmkl=sequential
MKLROOT    ?= /path/to/your/mkl/installation
LLIBS      += -L$(MKLROOT)/lib/intel64 -lmkl_scalapack_lp64 -lmkl_blacs_intelmpi_lp64
INCS        =-I$(MKLROOT)/include/fftw

# HDF5-support (optional but strongly recommended, and mandatory for some features)
CPP_OPTIONS+= -DVASP_HDF5
HDF5_ROOT  ?= /path/to/your/hdf5/installation
LLIBS      += -L$(HDF5_ROOT)/lib -lhdf5_fortran
INCS       += -I$(HDF5_ROOT)/include

# For the VASP-2-Wannier90 interface (optional)
#CPP_OPTIONS    += -DVASP2WANNIER90
#WANNIER90_ROOT ?= /path/to/your/wannier90/installation
#LLIBS          += -L$(WANNIER90_ROOT)/lib -lwannier

# For machine learning library vaspml (experimental)
#CPP_OPTIONS += -Dlibvaspml
#CPP_OPTIONS += -DVASPML_USE_CBLAS
#CPP_OPTIONS += -DVASPML_USE_MKL
#CPP_OPTIONS += -DVASPML_DEBUG_LEVEL=3
#CXX_ML      = mpiicpc -cxx=icpx
#CXXFLAGS_ML = -O3 -std=c++17 -Wall
#INCLUDE_ML  =
说明:
  • 第2行,HOST笔者改为课题组服务器的名字;(可选)
  • 第27和35行,笔者添加了-diag-disable=10441是为了不让icc和icpc编译器在编译代码时每调用一次就跳出很烦人的弃用警告。
  • 第52和58行,笔者在用module load mkl hdf5时会分别自动设置了MKLROOT和HDF5_ROOT这两个变量。对于后者,如果echo $HDF5_ROOT没有输出,则读者需要手动设置。

当然也可以不去掉第57-60行的注释,不打开HDF5支持。
总体来讲,不怎么需要修改makefile.include

编译
$ make DEPS=1 -j40 all
40改成读者服务器合适的CPU核心数量。注意-jN并行编译的特性只有VASP6才支持,VASP5不支持。
编译成功后在bin/目录下生成vasp_gam vasp_std和vasp_ncl三个可执行文件。
1.4 添加到module中 $ cp -rp bin/ oneapi2023.2-hdf5
$ cd oneapi2023.2-hdf5/
$ ls
vasp_gam  vasp_ncl  vasp_std
$ pwd
/mnt/data/apps/vasp/vasp.6.5.0/oneapi2023.2
编写如下module file,名为6.5.0-oneapi2023.2-hdf5
#%Module1.0#####################################################################

set rootdir  /mnt/data/apps/vasp/vasp.6.5.0/oneapi2023.2

module-whatis "Name: VASP"
module-whatis "Version: 6.5.0"
module-whatis "Category: Computational Materials Science"
module-whatis "Description: The Vienna Ab initio Simulation Package (VASP) is a computer program for atomic scale materials modelling, e.g. electronic structure calculations and quantum-mechanical molecular dynamics, from first principles. "
module-whatis "URL: http://vasp.at"

proc ModulesHelp { } {

global rootdir

puts stderr "Name: VASP"
puts stderr "Version: 6.5.0"
puts stderr "Category: Computational Materials Science"
puts stderr "URL: http://vasp.at"
puts stderr ""
puts stderr "Package specification:"
puts stderr "Manually compiled"
puts stderr ""
puts stderr "Directory Location:"
puts stderr "$rootdir"
puts stderr ""
puts stderr "Description:"
puts stderr "The Vienna Ab initio Simulation Package (VASP) is a computer program"
puts stderr "for atomic scale materials modelling, e.g. electronic structure"
puts stderr "calculations and quantum-mechanical molecular dynamics, from first"
puts stderr "principles."
puts stderr ""
puts stderr "Additional Notes:"
puts stderr ""
puts stderr "1. VASP is a licensed software"

}

conflict vasp

if { [ module-info mode load ] } {
     module load intel-oneapi/2023.2
     module load compiler mpi mkl
     module load hdf5/1.12.3-intel-oneapi2023.2-mpi
}

prepend-path    PATH                 $rootdir
setenv          OMP_NUM_THREADS      1
放到MODULEPATH变量包含的目录下,即可。
注意:
setenv          OMP_NUM_THREADS      1会把OMP_NUM_THREADS强制设为1,读者要注意这是否是预期的,一般来说VASP其值为1,但是读者应该小心测试,否则应该要删除这一行。
测试:
$ module avail -t vasp
/mnt/data/apps/modules/compmatsci/dft:
vasp/5.4.4-oneapi2023.2
vasp/6.3.2-oneapi2023.2-hdf5
vasp/6.5.0-oneapi2023.2-hdf5

$ module help vasp/6.5.0-oneapi2023.2-hdf5
-------------------------------------------------------------------
Module Specific Help for /mnt/data/apps/modules/compmatsci/dft/vasp/6.5.0-oneapi2023.2-hdf5:

Name: VASP
Version: 6.5.0
Category: Computational Materials Science
URL: http://vasp.at

Package specification:
Manually compiled

Directory Location:
/mnt/data/apps/vasp/vasp.6.5.0/oneapi2023.2

Description:
The Vienna Ab initio Simulation Package (VASP) is a computer program
for atomic scale materials modelling, e.g. electronic structure
calculations and quantum-mechanical molecular dynamics, from first
principles.

Additional Notes:

1. VASP is a licensed software
-------------------------------------------------------------------
最后一个即刚刚添加的VASP6.5.0。

1.5 C/C++/Fortran LLVM
如法炮制,仅仅某些行不同。
复制使用于OneAPI (LLVM)套件的makefile.include
$ cp arch/makefile.include.oneapi ./makefile.include
$ make veryclean
$ rm bin/vasp_*
$ make DEPS=1 -j40 all
编译结束发现vasp_gam没有生成,另外两个是正常的,如果直接make gam会报编译器错误。
即便先清除-j40编译生成的文件,然后用单核单线程编译,仍然报错。错误来源于使用mpiifort -fc=ifx编译greens_real_space.f90。
$ make veryclean
$ make gam
mpiifort -fc=ifx -free -names lowercase -assume byterecl -w -xHOST -O2 -I/mnt/data/apps/intel/oneapi/2023.2/mkl/2023.2.0/include/fftw -I/mnt/data/apps/hdf5/1.12.3/intel-oneapi2023.2-mpi/include  -c greens_real_space.f90
           #0 0x0000000002203192
           #1 0x0000000002266e47
           #2 0x0000000002266f70
           #3 0x00007f01ad517520
           #4 0x0000000001fa52da
           #5 0x0000000001fe414c
           #6 0x000000000200350e
           #7 0x0000000001fe45a2
           #8 0x000000000200f2fa
           #9 0x00000000020073e7
          #10 0x0000000001fe42fb
          #11 0x0000000001fe0db1
          #12 0x0000000001fe00aa
          #13 0x000000000206039d
          #14 0x000000000224c731
          #15 0x000000000214f026
          #16 0x000000000231f37e
          #17 0x00007f01ad4fed90
          #18 0x00007f01ad4fee40 __libc_start_main + 128
          #19 0x0000000001f8fa69

greens_real_space.f90: error #5633: **Internal compiler error: segmentation violation signal raised** Please report this error along with the circumstances in which it occurred in a Software Problem Report.  Note: File and line given may not be explicit cause of this error.
compilation aborted for greens_real_space.f90 (code 3)
make[2]: *** [makefile:195: greens_real_space.o] Error 3
make[2]: Leaving directory '/mnt/data/apps/vasp/vasp.6.5.0/build/gam'
cp: cannot stat 'vasp': No such file or directory
make[1]: *** [makefile:150: all] Error 1
make[1]: Leaving directory '/mnt/data/apps/vasp/vasp.6.5.0/build/gam'
make: *** [makefile:17: gam] Error 2
猜测可能是编译器的问题,随即加载了更新的OneAPI套件(这里是2024.1),并顺利编译通过。
$ module purge
$ module load intel-oneapi/2024.1
$ module load compiler mpi mkl
$ make veryclean
$ rm bin/vasp_*
$ make DEPS=1 -j40 all

2. 结束
本文到此,后面有空更新VASP6.5.0+GPU (nvhpc)和AMD CPU的编译经验。
转载请注明出处
欢迎交流。


评分 Rate

参与人数
Participants 3
eV +13 收起 理由
Reason
tanyazhi + 5 GJ!
guoguoping199 + 1 好物!
sobereva + 7

查看全部评分 View all ratings

3

帖子

0

威望

19

eV
积分
22

Level 1 能力者

2#
发表于 Post on 2024-12-26 10:23:04 | 只看该作者 Only view this author
可以分享一下vasp6.5.0的安装包吗,感谢&#128591;

6

帖子

0

威望

73

eV
积分
79

Level 2 能力者

3#
发表于 Post on 2024-12-26 20:59:22 | 只看该作者 Only view this author
分享一下vasp6.5.0的安装包嘛

101

帖子

1

威望

645

eV
积分
766

Level 4 (黑子)

4#
发表于 Post on 2024-12-27 20:48:45 | 只看该作者 Only view this author
本帖最后由 五十八 于 2024-12-28 15:11 编辑

还是加上VASPml的好,之后可以联lammps,或者写个lammps的plugin,(我目前在用的是intel的oneapi 2023,不过是ifort,看到intel官方的性能提醒:
Known Limitations
With ifx 2023.x, the only I/O allowed with ifx in an OpenMP TARGET region is print * and that is limited to numeric, logical, complex and character strings.
Support added in ifx 2022.3.0... On Windows* the ATTRIBUTES DLLEXPORT and DLLIMPORT are not yet supported.
Beginning with ifx 2023.2.0, Windows QuickWin applications are supported.
COMPLEX data type performance

A current ( version 2023.x and older ) shortcoming of the Intel Fortran Compiler is performance when data is COMPLEX.  The datatypes affected are:

COMPLEX(KIND=4) same as Intel's COMPLEX*8
COMPLEX(KIND=8) same as Intel's COMPLEX*16 or DOUBLE COMPLEX
COMPLEX(KIND=16) same as Intel's COMPLEX*32

For applications using these datatypes, the Intel Fortran Compiler will show a performance loss in comparison to the Intel Fortran Compiler Classic.  We are working on improving performance for these Fortran intrinsic data types in a future release.

=========
得改下vaspml的hpp文件,incar里开了vaspml也会报错

122

帖子

0

威望

3091

eV
积分
3213

Level 5 (御坂)

5#
发表于 Post on 2025-1-8 00:56:34 | 只看该作者 Only view this author
分享一下vasp6.5.0的安装包嘛

11

帖子

0

威望

153

eV
积分
164

Level 3 能力者

6#
发表于 Post on 2025-2-15 15:35:09 | 只看该作者 Only view this author
作者你好,我在编译hdf5的时候遇到了问题,因为默认编译用的mpif90,使用mpiifort会报错。但是用mpif90编译的hdf5又没法接入用mpiifot编译的vasp中,这个怎么解决呢,谢谢

11

帖子

1

威望

68

eV
积分
99

Level 2 能力者

7#
 楼主 Author| 发表于 Post on 2025-2-17 03:52:16 | 只看该作者 Only view this author
本帖最后由 Tosykie 于 2025-2-17 04:04 编辑
hsesese 发表于 2025-2-15 15:35
作者你好,我在编译hdf5的时候遇到了问题,因为默认编译用的mpif90,使用mpiifort会报错。但是用mpif90编译 ...
```bash
$ CFLAGS+=-diag-disable=10441

# serial version (串行版本)
$ CC=icc FC=ifort CXX=icpc ./configure --prefix=/path/to/install/target --enable-fortran --enable-cxx

# and/or MPI version (MPI版本,注意:MPI版本生成的shared object file/dynamically linked libraries 动态链接库 (.so???)文件可能不适用于所有的DFT后续依赖,比如QE并不能成功的使用MPI版本的HDF5 (v1.12.3),会报错为无法找到某个.so
$ CC=mpiicc FC=mpiifort CXX=mpiicpc ./configure --prefix=/path/to/install/target --enable-fortran --enable-parallel

#After configure
#---------------------------------------------------------
$ make
$ make install
$ make clean
``
请问你在configure的时候有没有手动指定编译器呢?
你可以尝试根据上面的代码编译HDF5,看是编译HDF5还否有报错。`--prefix=`改成你自己的安装目标目录。

评分 Rate

参与人数
Participants 1
eV +4 收起 理由
Reason
hsesese + 4 233333

查看全部评分 View all ratings

11

帖子

0

威望

153

eV
积分
164

Level 3 能力者

8#
发表于 Post on 2025-2-17 10:03:03 | 只看该作者 Only view this author
Tosykie 发表于 2025-2-17 03:52
```bash
$ CFLAGS+=-diag-disable=10441

谢谢你的回复,借助你的指引我成功编译了,vasp+hdf5,再次感谢,把你挂在我问答的帖子里了
http://bbs.keinsci.com/forum.php ... mp;page=1#pid325100

11

帖子

1

威望

68

eV
积分
99

Level 2 能力者

9#
 楼主 Author| 发表于 Post on 2025-2-22 22:37:04 | 只看该作者 Only view this author
本帖最后由 Tosykie 于 2025-2-22 23:25 编辑

勘误:最后一个支持经典Fortran编译器的版本, 也就是ifort编译器的是Intel OneAPI 2024系列;并在Intel OneAPI 2025的版本中移除了ifort。参见发行通告链接:https://www.intel.com/content/ww ... -release-notes.html
Support Removed
Intel® Fortran Compiler Classic (ifort) is now discontinued in oneAPI 2025 release.
注意:
VASP6.5的makefile.include与VASP6.3.x或者VASP6.4.x以及之前的有所不同,例如,不包含OBJECTS,OBJECTS_O1,OBJECTS_O2等。

11

帖子

1

威望

68

eV
积分
99

Level 2 能力者

10#
 楼主 Author| 发表于 Post on 2025-2-23 02:12:28 | 只看该作者 Only view this author
更新:
[VASP6.5.0+AMD CPU/NVIDIA A100 GPU编译](http://bbs.keinsci.com/thread-51729-1-1.html)

2

帖子

0

威望

55

eV
积分
57

Level 2 能力者

11#
发表于 Post on 2025-5-16 16:18:42 | 只看该作者 Only view this author
请问是否增加了溶剂化,我编译的时候使用pbz_patch_610 这个patch有报错,可能是已经不适用了。

9

帖子

0

威望

101

eV
积分
110

Level 2 能力者

12#
发表于 Post on 2025-5-19 15:13:18 | 只看该作者 Only view this author
可以分享一下6.5.0的包吗?想用LAK泛函

11

帖子

1

威望

68

eV
积分
99

Level 2 能力者

13#
 楼主 Author| 发表于 Post on 2025-7-11 04:48:11 | 只看该作者 Only view this author
ly934684881 发表于 2025-5-16 16:18
请问是否增加了溶剂化,我编译的时候使用pbz_patch_610 这个patch有报错,可能是已经不适用了。

暂时没有测试溶剂化的补丁包。pbz_patch_610 可能只适用于6.1.x系列的VASP版本。建议发邮件给开发者问一下。或者写个issue

210

帖子

0

威望

1577

eV
积分
1787

Level 5 (御坂)

14#
发表于 Post on yesterday 14:34 | 只看该作者 Only view this author
借楼,求个6.5.0的包,好人一生平安

本版积分规则 Credits rule

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

GMT+8, 2025-8-14 00:59 , Processed in 0.227610 second(s), 27 queries , Gzip On.

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