1. 安装 MiniConda3
从 Miniconda3 官方网站
下载 Miniconda3_py39_23.5.2 。
1
| wget https://repo.anaconda.com/miniconda/Miniconda3-py39_23.5.2-0-Linux-x86_64.sh
|
执行 Miniconda3-py39_23.5.2-0-Linux-x86_64.sh ,按照提示安装 Miniconda3。(安装在 $HOME/software/miniconda3/23.5.2
目录下)
然后,设置 Miniconda3 环境变量。
1
| export PATH=$HOME/software/miniconda3/23.5.2/bin:$PATH
|
2. 安装 Boost
从 Boost 官方网站
下载 Boost。
1
2
3
| wget https://boostorg.jfrog.io/artifactory/main/release/1.77.0/source/boost_1_77_0.tar.gz
tar -zxvf boost_1_77_0.tar.gz
cd boost_1_77_0
|
在 Boost 根目录下执行以下命令安装 Boost:
1
2
3
4
| module load gcc/8.4.0
./bootstrap.sh --prefix=$HOME/software/boost/1.77.0-gcc-8.4.0 \
CC=gcc CXX=g++ FC=gfortran CFLAGS='-O3' CXXFLAGS='-O3' FCFLAGS='-O3'
|
配置环境变量:
1
2
3
4
5
6
| export BOOST_ROOT=$HOME/software/boost/1.77.0-gcc-8.4.0
export LD_LIBRARY_PATH=$BOOST_ROOT/lib:$LD_LIBRARY_PATH
export LIBRARY_PATH=$BOOST_ROOT/lib:$LIBRARY_PATH
export CMAKE_PREFIX_PATH=$BOOST_ROOT/lib/cmake:$CMAKE_PREFIX_PATH
export CPATH=$BOOST_ROOT/include:$CPATH
export LD_RUN_PATH=$BOOST_ROOT/lib:$LD_RUN_PATH
|
3. 安装 GNU Scientific Library
从 GNU Scientific Library 镜像站
下载 GSL。
1
2
| wget https://mirror.ibcp.fr/pub/gnu/gsl/gsl-latest.tar.gz
tar -zxvf gsl-latest.tar.gz
|
在 GSL 根目录执行以下命令安装 GSL:
1
2
3
4
5
6
| module load gcc/8.4.0
./configure --prefix=$HOME/software/gsl/2.7.1-gcc-8.4.0 \
CC=gcc CXX=g++ FC=gfortran CFLAGS='-O3' CXXFLAGS='-O3' FCFLAGS='-O3'
make install
|
配置环境变量:
1
2
3
4
5
6
| export GSL_ROOT=$HOME/software/gsl/2.7.1-gcc-8.4.0
export LD_LIBRARY_PATH=$GSL_ROOT/lib:$LD_LIBRARY_PATH
export PATH=$GSL_ROOT/bin:$PATH
export CPATH=$GSL_ROOT/include:$CPATH
export LIBRARY_PATH=$GSL_ROOT/lib:$LIBRARY_PATH
export LD_RUN_PATH=$GSL_ROOT/lib:$LD_RUN_PATH
|
4. 安装 NEST
使用 Miniconda3 创建一个虚拟环境。
1
2
3
| source activate
conda create -n nest python=3.9
conda activate nest
|
使用 pip 安装 numpy, scipy, cython==0.29.36
1
| pip install numpy scipy cython==0.29.36
|
从 NEST github 仓库
下载 NEST 3.4。
1
2
| wget https://github.com/nest/nest-simulator/archive/refs/tags/v3.4.tar.gz
tar -zxvf v3.4.tar.gz
|
在 nest-simulator-3.4 目录下执行:
1
2
3
4
5
6
7
8
9
10
11
12
13
| module load gcc/8.4.0
module load mvaapich2/2.3.7-gcc-8.4.0
cmake -DCMAKE_C_COMPILER=mpicc \
-DCMAKE_CXX_COMPILER=mpicxx \
-Dwith-mpi=`which mpiexec` \
-DCMAKE_C_FLAGS='-O3 -fPIC' \
-DCMAKE_CXX_FLAGS='-O3' \
-Dwith-boost=$HOME/software/boost/1.77.0-gcc-8.4.0 \
-DGSL_INCLUDE_DIR=$HOME/software/gsl/2.7.1-gcc-8.4.0/include \
-DGSL_LIBRARY=$HOME/software/gsl/2.7.1-gcc-8.4.0/lib/libgsl.a \
-DGSL_CBLAS_LIBRARY=$HOME/software/gsl/2.7.1-gcc-8.4.0/lib/libgslcblas.a \
-DCMAKE_INSTALL_PREFIX:PATH=$HOME/software/nest-simulator/3.4-gcc-8.4.0 .
|
配置环境变量:
1
2
3
| export NEST_ROOT=$HOME/software/nest-simulator/3.4-gcc-8.4.0
export LIBRARY_PATH=$NEST_ROOT/lib:$LIBRARY_PATH
export LD_LIBRARY_PATH=$NEST_ROOT/lib:$LD_LIBRARY_PATH
|
5. 运行 hpc_benchmark 测试
运行 NEST 前需要配置 nest 环境:
1
| source $HOME/software/nest-simulator/3.4-gcc-8.4.0/bin/nest_vars.sh
|
接着找到 hpc_benchmark.py
目录,该文件位于 $HOME/software/nest-simulator/3.4-gcc-8.4.0/share/doc/nest/examples/hpc_benchmark.py
。修改其中的 params 以并行运行更大的模型。
- 修改 nvp 为所需 MPI 进程数 × 每进程线程数,如 2 MPI 进程 × 14 线程 = 28
- 设置合适的 scale ,如 10 。更大的需要更多 nvp 。
1
2
3
4
5
| params = {
'nvp': 28, # total number of virtual processes
'scale': 10., # scaling factor of the network size
# others...
}
|
在 hpc_benchmark.py
目录下执行:
1
2
| export OMP_NUM_THREADS=14
mpiexec -N 1 -n 2 -p <partition_name> --export=all python3 hpc_benchmark.py
|
其中 -N 指定节点数,-n 指定 MPI 进程数,-p 指定分区名,如 compute
,–export=all 用于将环境变量导出到 MPI 进程中。
总结
本文介绍了在高性能计算机上安装 NEST-3.4 的方法。
参考资料
- NEST 官方文档