Linux【11】-软件安装8-在centos上安装MPI

一、安装MPI(centos7.2)

查看MPI可安装的版本,我是直接全部安装

yum list mpich*

安装:

yum install -y mpich*

可以查看到设置的路径

which mpicc

如果找不到,就需要添加环境变量

添加环境变量

vim ~/.bashrc

#在文件中添加,具体路径要根据系统和具体环境,以下是我的情况:

export PATH=$PATH:/usr/lib64/mpich/bin/

然后使其生效

source .bashrc

yum 默认mpich安装路径是在/usr/lib64。如果在不到,就需要find / -name “mpicc” 查找安装路径

二、测试

mpi代码示例(hello.c):

#include <mpi.h>
#include <stdio.h>
#include <math.h>
int main(int argc,char** argv)
{
    int myid,numproces;
    int namelen;
    char processor_name[MPI_MAX_PROCESSOR_NAME];
    MPI_Init(&argc,&argv);
    MPI_Comm_rank(MPI_COMM_WORLD,&myid);
    MPI_Comm_size(MPI_COMM_WORLD,&numproces);
    MPI_Get_processor_name(processor_name,&namelen);
    fprintf(stdout,"hello world! Process %d of %d on %s\n",
            myid,numproces,processor_name);
    MPI_Finalize();

    return 0;
}

编译:

mpicc -o hello hello.c

运行:

mpirun -np 4 ./hello

输出:

hello world! Process 0 of 4 on node25
hello world! Process 1 of 4 on node25
hello world! Process 3 of 4 on node25
hello world! Process 2 of 4 on node25

三、报错

mpi报错

/data/software/amber/amber18//bin/pmemd.MPI: error while loading shared libraries: libmpifort.so.12: cannot open shared object file: No such file or directory
/data/software/amber/amber18//bin/pmemd.MPI: error while loading shared libraries: libmpifort.so.12: cannot open shared object file: No such file or directory
/data/software/amber/amber18//bin/pmemd.MPI: error while loading shared libraries: libmpifort.so.12: cannot open shared objec

天呐,直接重新安装就好。。

参考资料

个人公众号,比较懒,很少更新,可以在上面提问题,如果回复不及时,可发邮件给我: tiehan@sina.cn

Sam avatar
About Sam
专注生物信息 专注转化医学