cndaqiang Web Linux DFT

GPAW安装

2020-09-02
cndaqiang
DFT
RSS

参考

GPAW

Ubuntu18.04/Mint19

sudo apt install libopenblas-dev libxc-dev libscalapack-mpi-dev libfftw3-dev

python

#创建环境
conda create --name python37 python=3.7
#激活环境
source activate python37 # for Linux & Mac
#包
echo y  | conda install -n python37 numpy
echo y  | conda install -n  python37 matplotlib
echo y  | conda install -n  python37 pandas
echo y  | conda install -n  python37 scipy
#只能pip安装
echo y  | python -m pip install --upgrade pip --user  -i https://pypi.tuna.tsinghua.edu.cn/simple
echo y  | python -m pip install --user PyHamcrest -i https://pypi.tuna.tsinghua.edu.cn/simple
echo y  | python -m ensurepip --user
echo y  | python -m pip install ase --user -i https://pypi.tuna.tsinghua.edu.cn/simple

gpaw

git clone git@gitlab.com:gpaw/gpaw.git
cd gpaw
vi siteconfig.py

填入

fftw = True
scalapack = True
libraries = ['xc', 'blas', 'fftw3', 'scalapack-openmpi']

安装

python setup.py install

安装paw数据

gpaw install-data pawdir

测试

(python37) cndaqiang@mint19:~$ gpaw test
-----------------+----------------------------------------------------------------------------------------------------------
python-3.7.9     | /home/cndaqiang/anaconda3/envs/python37/bin/python
gpaw-20.1.1b1    | /home/cndaqiang/anaconda3/envs/python37/lib/python3.7/site-packages/gpaw/
ase-3.20.1       | /home/cndaqiang/.local/lib/python3.7/site-packages/ase/
numpy-1.19.1     | /home/cndaqiang/anaconda3/envs/python37/lib/python3.7/site-packages/numpy/
scipy-1.5.2      | /home/cndaqiang/anaconda3/envs/python37/lib/python3.7/site-packages/scipy/
libxc-3.0.0      | yes
_gpaw-96a66e3883 | /home/cndaqiang/anaconda3/envs/python37/lib/python3.7/site-packages/_gpaw.cpython-37m-x86_64-linux-gnu.so
MPI enabled      | yes
scalapack        | yes
Elpa             | no
FFTW             | yes
libvdwxc         | no
PAW-datasets (1) | /home/cndaqiang/soft/gpaw/pawdir/gpaw-setups-0.9.20000
-----------------+----------------------------------------------------------------------------------------------------------
Doing a test calculation (cores: 1): ... Done

Test parallel calculation with "gpaw -P 4 test".
(python37) cndaqiang@mint19:~$ gpaw -P 4 test
-----------------+----------------------------------------------------------------------------------------------------------
python-3.7.9     | /home/cndaqiang/anaconda3/envs/python37/bin/python
gpaw-20.1.1b1    | /home/cndaqiang/anaconda3/envs/python37/lib/python3.7/site-packages/gpaw/
ase-3.20.1       | /home/cndaqiang/.local/lib/python3.7/site-packages/ase/
numpy-1.19.1     | /home/cndaqiang/anaconda3/envs/python37/lib/python3.7/site-packages/numpy/
scipy-1.5.2      | /home/cndaqiang/anaconda3/envs/python37/lib/python3.7/site-packages/scipy/
libxc-3.0.0      | yes
_gpaw-96a66e3883 | /home/cndaqiang/anaconda3/envs/python37/lib/python3.7/site-packages/_gpaw.cpython-37m-x86_64-linux-gnu.so
MPI enabled      | yes
scalapack        | yes
Elpa             | no
FFTW             | yes
libvdwxc         | no
PAW-datasets (1) | /home/cndaqiang/soft/gpaw/pawdir/gpaw-setups-0.9.20000
-----------------+----------------------------------------------------------------------------------------------------------
Doing a test calculation (cores: 4): ... Done

结果输出到当前目录的test.txt文件

Centos7

python部分差不多,依赖要修改一下,其他部分同Ubuntu18.04

yum install epel-release #有些程序包在这里面
yum install libxc-devel openblas-devel openmpi-devel fftw-devel
yum install blacs-openmpi-devel scalapack-openmpi-devel
OPENMPI=/usr/lib64/openmpi
export PATH=$OPENMPI/bin/:$PATH
export LD_LIBRARY_PATH=$OPENMPI/lib:$LD_LIBRARY_PATH
vi siteconfig.py
fftw = True
scalapack = True
libraries = ['xc', 'fftw3', 'scalapack', 'mpiblacs']
library_dirs = ['/usr/lib64/openmpi/lib/']

自己编译库

python同上

超算上编译

#----------------加载编译环境---------------------------------------------
#### 加载编译环境1:怀柔gnu8&openmpi
module swap gnu4 gnu8/8.3.0
module load gnu8/8.3.0
module load openmpi3/3.1.4
#创建编译目录
mkdir -p ~/soft/gnu8-openmpi/
cd ~/soft/gnu8-openmpi/

#### 加载编译环境2:SSLAB gnu4&mvapich
module load  mpi/mvapich2/gnu/2.3b
mkdir -p ~/soft/gcc-MVAPICH/
cd ~/soft/gcc-MVAPICH/

#### 加载编译环境3:怀柔
module unload gnu8/8.3.0
module swap gnu8 gnu4/4.8.5
module load gnu4/4.8.5
module load mvapich2/2.3.1
mkdir -p ~/soft/gnu4-mvapich
cd ~/soft/gnu4-mvapich


#----------------开始编译环境---------------------------------------------

ROOT=$PWD
mkdir $ROOT/source

#创建编译脚本
cd $ROOT/source
cat << EOF > ./make.sh
#!/bin/bash
#SBATCH -J make
#SBATCH -p debug
#SBATCH -N 1
#SBATCH --ntasks-per-node=10
#SBATCH -o make.out

#这里同编译环境
module load gnu8/8.3.0
module load module load openmpi3/3.1.4
if [ -e ./netlib.py ]
then
    ./setup.py --prefix=$ROOT/math --downall
else
    make -j10
    make
    make install
fi
EOF

#把下面的执行结果复制到环境变量
echo -e"
#把下面的执行结果复制到环境变量
ROOT=$ROOT
MATHDIR=\$ROOT/math/lib
export LD_LIBRARY_PATH=\$ROOT/libxc-4.3.4/lib:\$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=\$ROOT/fftw-3.3.3/lib:\$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=\$ROOT/math/lib:\$LD_LIBRARY_PATH
export LIBRARY_PATH=\$ROOT/libxc-4.3.4/lib:\$LIBRARY_PATH
export LIBRARY_PATH=\$ROOT/fftw-3.3.3/lib:\$LIBRARY_PATH
export LIBRARY_PATH=\$ROOT/math/lib:\$LIBRARY_PATH
export C_INCLUDE_PATH=\$ROOT/libxc-4.3.4/include:\$C_INCLUDE_PATH
export C_INCLUDE_PATH=\$ROOT/fftw-3.3.3/include:\$C_INCLUDE_PATH
export C_INCLUDE_PATH=\$ROOT/math/include:\$C_INCLUDE_PATH
export PATH=\$ROOT/fftw-3.3.3/bin:\$PATH
"


#libxc-4.3.4 for octopus-10.1
cd $ROOT/source
wget https://cndaqiang.gitee.io/packages//mirrors/libxc/libxc-4.3.4.tar.gz
tar xzvf libxc-4.3.4.tar.gz 
cd libxc-4.3.4
#--enable-shared 动态库
./configure --prefix=$ROOT/libxc-4.3.4  CC=gcc CXX=g++ FC=gfortran --enable-shared 
qsub ../make.sh

#fft
cd $ROOT/source
wget https://cndaqiang.gitee.io/packages//mirrors/fftw/fftw-3.3.3.tar.gz
tar xzvf fftw-3.3.3.tar.gz
cd fftw-3.3.3/
./configure --prefix=$ROOT/fftw-3.3.3 --enable-mpi --enable-shared
qsub ../make.sh



#从0编译动态库scalapack
if [ ! -d $ROOT/math ]
then
    mkdir $ROOT/math
    mkdir $ROOT/math/lib
    mkdir $ROOT/math/include
fi

cd $ROOT/source
wget https://cndaqiang.gitee.io/packages//mirrors/math/lapack-3.8.0.tar.gz
rm -rf lapack-3.8.0
tar xzvf lapack-3.8.0.tar.gz
cd lapack-3.8.0/
#修改编译参数,并默认输出动态库

#BLAS&LAPACK
echo -e "
all:libblas.so
libblas.so: \$(ALLOBJ)
\t \$(FORTRAN) -shared -Wl,-soname,\$@ -o \$@ \$(ALLOBJ)
" >> BLAS/SRC/Makefile
#TMG
echo -e "
all:libtmg.so
libtmg.so: \$(ALLOBJ)
\t \$(FORTRAN) -shared -Wl,-soname,\$@ -o \$@ \$(ALLOBJ)
" >> TESTING/MATGEN/Makefile
#LAPACK
echo -e "
all: liblapack.so
liblapack.so: \$(ALLOBJ)
\t \$(FORTRAN) -shared -Wl,-soname,\$@ -o \$@ \$(ALLOBJ)
" >> SRC/Makefile

cp make.inc.example make.inc
echo "OPTS += -fPIC" >> make.inc
echo "NOOPT += -fPIC" >> make.inc
echo -e "
MATHDIR=$ROOT/math/lib
install:all
\t cp $PWD/BLAS/SRC/libblas.so \$(MATHDIR)
\t cp $PWD/SRC/liblapack.so \$(MATHDIR)
\t cp $PWD/TESTING/MATGEN/libtmg.so \$(MATHDIR)
\t cp $PWD/*.a \$(MATHDIR)
" >> make.inc
#安装
make -j36 #必须用make,用其他参数/完成后再输make会编译测试程序,没必要
#不可以注释Makefile中
#   all: lapack_install lib blas_testing lapack_testing
#为
#   all: lapack_install lib
#   #blas_testing lapack_testing
#可以跳过测试的过程,编译更快
# 因为blas_testing依赖blas的编译
#如果非要注释,要添加依赖blas

#Scalapack
cd $ROOT/source
wget https://cndaqiang.gitee.io/packages//mirrors/math/scalapack-2.0.2.tgz
rm -rf scalapack-2.0.2
tar xzvf scalapack-2.0.2.tgz
cd scalapack-2.0.2

#echo -e "
#ALLOBJ += \$(SLASRC) \$(DLASRC)  \$(CLASRC) \$(ZLASRC)  \
#\t   \$(SCLAUX) \$(DZLAUX) \$(ALLAUX)
#all:libscalapack.so
#libscalapack.so: \$(ALLOBJ)
#\t \$(FC) -shared -Wl,-soname,\$@ -o \$@ \$(ALLOBJ)
#" >> SRC/Makefile

#使用fPIC参数,这样静态库可以转为动态库
cp SLmake.inc.example SLmake.inc
echo "FC += -fPIC" >> SLmake.inc
echo "CC += -fPIC" >> SLmake.inc
echo -e "
MATHDIR=$ROOT/math/lib
install: all
\t \$(FC) -shared -o $PWD/libscalapack.so -Wl,--whole-archive $PWD/libscalapack.a -Wl,--no-whole-archive
\t cp $PWD/libscalapack.so \$(MATHDIR)
" >> SLmake.inc
#不支持-j20,就得逐个编译,把每个库依次打包添加到libscalapack.a,没编译成功也有libscalapack.a
make  install


#gapw git模式
cd $ROOT/source
git clone -b 20.10.0 https://gitlab.com/gpaw/gpaw.git
cd gpaw
#gapw下载模式
cd $ROOT/source
wget https://wiki.fysik.dtu.dk/gpaw/gpaw-20.10.1b1.tar.gz
rm -rf gpaw-20.10.1b1#  清空编译历史,不然有很多未知事件
tar xzvf gpaw-20.10.1b1.tar.gz
cd gpaw-20.10.1b1
#卸载之前的安装残留
python -m pip uninstall gpaw

cat << EOF > ./siteconfig.py
fftw = True
scalapack = True
libraries += ['xc', 'blas', 'lapack', 'tmg', 'scalapack', 'fftw3']
EOF

python setup.py install
gpaw install-data pawdir
#测试
gpaw  test

测试结果

(python37) [SSLAB cndaqiang@login2 gpaw-20.10.1b1]$gpaw test
 -----------------------------------------------------------------------------------------------------------------------------------------------
| python-3.7.3      /public/home/chendq/anaconda3/envs/python37/bin/python                                                                      |
| gpaw-20.10.1b1    /public/home/chendq/soft/gcc-MVAPICH/source/gpaw-20.10.1b1/gpaw/                                                            |
| ase-3.20.1        /public/home/chendq/anaconda3/envs/python37/lib/python3.7/site-packages/ase/                                                |
| numpy-1.19.1      /public/home/chendq/anaconda3/envs/python37/lib/python3.7/site-packages/numpy/                                              |
| scipy-1.5.2       /public/home/chendq/anaconda3/envs/python37/lib/python3.7/site-packages/scipy/                                              |
| libxc-4.3.4       yes                                                                                                                         |
| _gpaw             /public/home/chendq/soft/gcc-MVAPICH/source/gpaw-20.10.1b1/build/lib.linux-x86_64-3.7/_gpaw.cpython-37m-x86_64-linux-gnu.so |
| MPI enabled       yes                                                                                                                         |
| scalapack         yes                                                                                                                         |
| Elpa              no                                                                                                                          |
| FFTW              yes                                                                                                                         |
| libvdwxc          no                                                                                                                          |
| PAW-datasets (1)  /public/home/chendq/soft/intel17/gpaw/pawdir/gpaw-setups-0.9.20000                                                          |
 -----------------------------------------------------------------------------------------------------------------------------------------------
Doing a test calculation (cores: 1): ... Done

Test parallel calculation with "gpaw -P 4 test".
(python37) [SSLAB cndaqiang@login2 gpaw-20.10.1b1]$gpaw -P 4 test
 -----------------------------------------------------------------------------------------------------------------------------------------------
| python-3.7.3      /public/home/chendq/anaconda3/envs/python37/bin/python                                                                      |
| gpaw-20.10.1b1    /public/home/chendq/soft/gcc-MVAPICH/source/gpaw-20.10.1b1/gpaw/                                                            |
| ase-3.20.1        /public/home/chendq/anaconda3/envs/python37/lib/python3.7/site-packages/ase/                                                |
| numpy-1.19.1      /public/home/chendq/anaconda3/envs/python37/lib/python3.7/site-packages/numpy/                                              |
| scipy-1.5.2       /public/home/chendq/anaconda3/envs/python37/lib/python3.7/site-packages/scipy/                                              |
| libxc-4.3.4       yes                                                                                                                         |
| _gpaw             /public/home/chendq/soft/gcc-MVAPICH/source/gpaw-20.10.1b1/build/lib.linux-x86_64-3.7/_gpaw.cpython-37m-x86_64-linux-gnu.so |
| MPI enabled       yes                                                                                                                         |
| scalapack         yes                                                                                                                         |
| Elpa              no                                                                                                                          |
| FFTW              yes                                                                                                                         |
| libvdwxc          no                                                                                                                          |
| PAW-datasets (1)  /public/home/chendq/soft/intel17/gpaw/pawdir/gpaw-setups-0.9.20000                                                          |
 -----------------------------------------------------------------------------------------------------------------------------------------------
Doing a test calculation (cores: 4): ... Done

macosx

brew install libxc
brew install open-mpi
brew install fftw
brew install lapack
brew install openblas
brew install scalapack
  export LDFLAGS="$LDFLAGS-L/usr/local/opt/openblas/lib"
  export CPPFLAGS="$CPPFLAGS-I/usr/local/opt/openblas/include"
  export LDFLAGS="$LDFLAGS-L/usr/local/Cellar/fftw/3.3.8_2/lib"
  export CPPFLAGS="$CPPFLAGS-I/usr/local/Cellar/fftw/3.3.8_2/include"
  export LDFLAGS="$LDFLAGS-L/usr/local/opt/lapack/lib"
  export CPPFLAGS="$CPPFLAGS-I/usr/local/opt/lapack/include"
  export LDFLAGS="$LDFLAGS-L/usr/local/Cellar/scalapack/2.1.0_2/lib/"
(python37) cndaqiang@mac gpaw$ cat siteconfig.py
fftw = True
scalapack = True
libraries = ['xc','blas' , 'fftw3', 'lapack','scalapack']
gpaw install-data pawdir
(python37) cndaqiang@mac gpaw$ gpaw -P 4 test
-------------------------+----------------------------------------------------------------------------------------
python-3.7.9             | /Users/cndaqiang/anaconda3/envs/python37/bin/python
gpaw-20.1.1b1-96a66e3883 | /Users/cndaqiang/soft/gpaw/gpaw/
ase-3.20.1               | /Users/cndaqiang/.local/lib/python3.7/site-packages/ase/
numpy-1.19.1             | /Users/cndaqiang/anaconda3/envs/python37/lib/python3.7/site-packages/numpy/
scipy-1.5.2              | /Users/cndaqiang/anaconda3/envs/python37/lib/python3.7/site-packages/scipy/
libxc-4.3.4              | yes
_gpaw-96a66e3883         | /Users/cndaqiang/soft/gpaw/build/lib.macosx-10.9-x86_64-3.7/_gpaw.cpython-37m-darwin.so
MPI enabled              | yes
scalapack                | yes
Elpa                     | no
FFTW                     | yes
libvdwxc                 | no
PAW-datasets (1)         | /Users/cndaqiang/soft/gpaw/pawdir/gpaw-setups-0.9.20000
-------------------------+----------------------------------------------------------------------------------------
Doing a test calculation (cores: 4): ... Done

本文首发于我的博客@cndaqiang.
本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!


上一篇 Linux使用clash

下一篇 GPAW快速上手


评论


广告

目录

广告
访客数据