分布式学习 - MPICH编译与实践

下载release编译

参考官方README

源码编译

准备工作:

git clone https://github.com/pmodels/mpich.git
bash
cd mpich
git submodule update --init
sudo apt install libtool-bin autoconf automake gfortran  
sh ./autogen.sh

开始编译:

./configure --prefix=/home//mpich-install 2>&1 | tee c.txt
# ./configure --prefix=/data1/jilan.li/mpich-install 2>&1 | tee c.txt

sudo make
sudo make install

添加环境

sudo vim ~/.bashrc

export MPI_ROOT=/home//mpich-install
export PATH=$MPI_ROOT/bin:$PATH
export MANPATH=$MPI_ROOT/man:$MANPATH

sh ~/.bashrc

which mpicc 查看位置信息

mpichversion 查看版本信息,出现版本号说明安装成功

MPICH Version:          3.3.2
MPICH Release date:     Tue Nov 12 21:23:16 CST 2019
MPICH Device:           ch3:nemesis
MPICH configure:        --prefix=/home/jilan.li/anaconda3 --disable-dependency-tracking --enable-cxx --enable-fortran --disable-wrapper-rpath
MPICH CC:       x86_64-conda_cos6-linux-gnu-cc -I/home/jilan.li/anaconda3/include -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -I/home/jilan.li/anaconda3/include -fdebug-prefix-map=/tmp/build/80754af9/mpich-mpi_1575396103289/work=/usr/local/src/conda/mpich-3.3.2 -fdebug-prefix-map=/home/jilan.li/anaconda3=/usr/local/src/conda-prefix  -O2
MPICH CXX:      x86_64-conda_cos6-linux-gnu-c++ -I/home/jilan.li/anaconda3/include -fvisibility-inlines-hidden -std=c++17 -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -I/home/jilan.li/anaconda3/include -fdebug-prefix-map=/tmp/build/80754af9/mpich-mpi_1575396103289/work=/usr/local/src/conda/mpich-3.3.2 -fdebug-prefix-map=/home/jilan.li/anaconda3=/usr/local/src/conda-prefix -O2
MPICH F77:      x86_64-conda_cos6-linux-gnu-gfortran -I/home/jilan.li/anaconda3/include -fopenmp -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -I/home/jilan.li/anaconda3/include -fdebug-prefix-map=/tmp/build/80754af9/mpich-mpi_1575396103289/work=/usr/local/src/conda/mpich-3.3.2 -fdebug-prefix-map=/home/jilan.li/anaconda3=/usr/local/src/conda-prefix -O2
MPICH FC:       x86_64-conda_cos6-linux-gnu-gfortran -I/home/jilan.li/anaconda3/include -fopenmp -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -I/home/jilan.li/anaconda3/include -fdebug-prefix-map=/tmp/build/80754af9/mpich-mpi_1575396103289/work=/usr/local/src/conda/mpich-3.3.2 -fdebug-prefix-map=/home/jilan.li/anaconda3=/usr/local/src/conda-prefix -O2
MPICH Custom Information:

测试

hellow.c


/*
 * Copyright (C) by Argonne National Laboratory
 *     See COPYRIGHT in top-level directory
 */

#include 
#include "mpi.h"

int main(int argc, char *argv[])
{
    int rank;
    int size;

    MPI_Init(0, 0);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    MPI_Comm_size(MPI_COMM_WORLD, &size);
    printf("Hello world from process %d of %d\n", rank, size);
    MPI_Finalize();
    return 0;
}

编译

mpicc -o hellow hellow.c

运行

mpiexec -n 4 ./hellow

如果出现:/bin/mpicc: line 285: x86_64-conda_cos6-linux-gnu-cc: command not found
则:conda install gxx_linux-64 (保证在activate某个env的情况下)

mpiexec -n 2 cpi -i
Process 0 of 1 is on server-207
pi is approximately 3.1415926544231341, Error is 0.0000000008333410
wall clock time = 0.000044
Process 0 of 1 is on server-207
pi is approximately 3.1415926544231341, Error is 0.0000000008333410
wall clock time = 0.000023

你可能感兴趣的:(分布式,Deep,Learning,linux,linux,分布式)