Open MPI 安装及使用
Open MPI 是一个开源的消息传递接口标准的实现,主要广泛运用于高性能计算、并行计算领域应用。
下面将介绍如何在 SonmiHPC 集群上编译安装 Open MPI,并提供给集群内用户使用。
源码下载
使用 wget 从官网下载最新 5.0.3 版本的源码压缩包,并解压:
shell
wget https://download.open-mpi.org/release/open-mpi/v5.0/openmpi-5.0.3.tar.gz
tar xzvf openmpi-5.0.3.tar.gz && cd openmpi-5.0.3/
wget https://download.open-mpi.org/release/open-mpi/v5.0/openmpi-5.0.3.tar.gz
tar xzvf openmpi-5.0.3.tar.gz && cd openmpi-5.0.3/
编译安装
执行下面的命令进行编译:
shell
./configure --prefix=/share/apps/openmpi/5.0.3
make -j all
make install
./configure --prefix=/share/apps/openmpi/5.0.3
make -j all
make install
为方便集群内其他用户使用,修改安装路径权限:
shell
chmod -R 755 /share/apps/openmpi
chmod -R 755 /share/apps/openmpi
Modulefile 编写
编译好的 Open MPI 可以通过 Module 模块的方式提供给集群上其他用户使用,可以编写如下的 Modulefile 文件。先创建一个文件夹:
shell
mkdir -p /share/apps/modulefiles/openmpi
mkdir -p /share/apps/modulefiles/openmpi
在该路径下创建一个文件:
shell
cd /share/apps/modulefiles/openmpi && vim 5.0.3
cd /share/apps/modulefiles/openmpi && vim 5.0.3
新建文件内容如下:
shell
#%Module###########################################
set modulefilename "Open MPI"
set modulefilever "5.0.3"
set min_tcl_ver 8.4
if { $tcl_version < $min_tcl_ver } {
puts stderr " "
puts stderr "ERROR: This modulefile requires tcl $min_tcl_ver or greater."
puts stderr "Your system reports that tclsh version $tcl_version is installed."
exit 1
}
if { [ module-info mode load ] } {
puts stderr "Loading $modulefilename version $modulefilever"
}
if { [ module-info mode ] == "unload" || [ module-info mode ] == "remove" } {
puts stderr "Removing $modulefilename version $modulefilever"
puts stderr "Use to view any remaining dependent modules."
}
prepend-path PATH /share/apps/openmpi/5.0.3/bin
setenv MPI_HOME /share/apps/openmpi/5.0.3
prepend-path LD_LIBRARY_PATH /share/apps/openmpi/5.0.3/lib
prepend-path MANPATH /share/apps/openmpi/5.0.3/share/man
#%Module###########################################
set modulefilename "Open MPI"
set modulefilever "5.0.3"
set min_tcl_ver 8.4
if { $tcl_version < $min_tcl_ver } {
puts stderr " "
puts stderr "ERROR: This modulefile requires tcl $min_tcl_ver or greater."
puts stderr "Your system reports that tclsh version $tcl_version is installed."
exit 1
}
if { [ module-info mode load ] } {
puts stderr "Loading $modulefilename version $modulefilever"
}
if { [ module-info mode ] == "unload" || [ module-info mode ] == "remove" } {
puts stderr "Removing $modulefilename version $modulefilever"
puts stderr "Use to view any remaining dependent modules."
}
prepend-path PATH /share/apps/openmpi/5.0.3/bin
setenv MPI_HOME /share/apps/openmpi/5.0.3
prepend-path LD_LIBRARY_PATH /share/apps/openmpi/5.0.3/lib
prepend-path MANPATH /share/apps/openmpi/5.0.3/share/man
保存文件后,设置一下权限:
shell
chmod -R 755 /share/apps/modulefiles
chmod -R 755 /share/apps/modulefiles
用户使用
集群上面用户可以通过下面的命令来查看该模块:
[sonmi@sonmi ~]$ module avail
------------------ /share/apps/modulefiles ------------------
openmpi/5.0.3
[sonmi@sonmi ~]$ module avail
------------------ /share/apps/modulefiles ------------------
openmpi/5.0.3
用户可以通过下面的命令来加载该模块:
shell
module load openmpi/5.0.3
module load openmpi/5.0.3