OpenMPI安装

Posted liu-shaobo

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了OpenMPI安装相关的知识,希望对你有一定的参考价值。

OpenMPI(open Message Passing Interface),OpenMPI是MPI的一种实现,是信息传递接口库项目。

1、安装OpenMPI

# wget https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-4.0.4.tar.bz2
# tar jxvf openmpi-4.0.4.tar.bz2 
# cd openmpi-4.0.4/
# ./configure --prefix=/usr/local/openmpi
# make
# make install

 

2、添加环境变量

# export PATH="/usr/local/openmpi/bin:$PATH"
# export LD_LIBRARY_PATH="/usr/local/openmpi/lib/:$LD_LIBRARY_PATH"
或者写 /etc/profile 环境变量文件

或者使用Moudle管理环境变量

# cat /etc/modulefiles/mpi/openmpi-4.04 
#%Module 1.0
##
## OpenMPI module for use with environment-modules package:
module-whatis "sets up access to openmpi-4.04"
#prereq openmpi-4.04
conflict mpi
setenv SOMEVERION 4.04
append-path PATH /usr/local/openmpi/bin
append-path LD_LIBRARY_PATH /usr/local/openmpi/lib

 

3、测试mpirun

# cd openmpi-4.0.4/examples
# mpicc hello_c.c -o hello
# mpirun --allow-run-as-root hello
Hello, world, I am 0 of 2, (Open MPI v4.0.4, package: Open MPI root@m1 Distribution, ident: 4.0.4, repo rev: v4.0.4, Jun 10, 2020, 102)
Hello, world, I am 1 of 2, (Open MPI v4.0.4, package: Open MPI root@m1 Distribution, ident: 4.0.4, repo rev: v4.0.4, Jun 10, 2020, 102)

多节点运行
多节点尽量使用NFS共享存储,不然所有节点都需要安装OpenMPI;

# for i in `seq 1 3` ; do echo "node$i" >> hostlist ; done
# /usr/local/openmpi/bin/mpirun --allow-run-as-root -np 6 --hostfile hostlist /openmpi-4.0.4/examples/hello
Hello, world, I am 0 of 6, (Open MPI v4.0.4, package: Open MPI root@m1 Distribution, ident: 4.0.4, repo rev: v4.0.4, Jun 10, 2020, 102)
Hello, world, I am 1 of 6, (Open MPI v4.0.4, package: Open MPI root@m1 Distribution, ident: 4.0.4, repo rev: v4.0.4, Jun 10, 2020, 102)
Hello, world, I am 4 of 6, (Open MPI v4.0.4, package: Open MPI root@m1 Distribution, ident: 4.0.4, repo rev: v4.0.4, Jun 10, 2020, 102)
Hello, world, I am 5 of 6, (Open MPI v4.0.4, package: Open MPI root@m1 Distribution, ident: 4.0.4, repo rev: v4.0.4, Jun 10, 2020, 102)
Hello, world, I am 2 of 6, (Open MPI v4.0.4, package: Open MPI root@m1 Distribution, ident: 4.0.4, repo rev: v4.0.4, Jun 10, 2020, 102)
Hello, world, I am 3 of 6, (Open MPI v4.0.4, package: Open MPI root@m1 Distribution, ident: 4.0.4, repo rev: v4.0.4, Jun 10, 2020, 102)

 

 

以上是关于OpenMPI安装的主要内容,如果未能解决你的问题,请参考以下文章

OpenMPI的下载和安装

安装 openmpi 4.0 用与 horovod 编译

运行基于 OpenMPI 的库时出错

安装HPL+GotoBLAS2+Openmpi

安装openmpi,编译失败,链接mpi_cxx

安装openmpi-3.1.0