zoukankan      html  css  js  c++  java
  • MPI linux Ubuntu cluster 集群

    在局域网内安装mpi,并进行并行计算。MPICH3。

    下载源码:

    wget http://www.mpich.org/static/downloads/3.3.1/mpich-3.3.1.tar.gz
    
    tar -xzf mpich-3.3.1.tar.gz
    
    cd mpich-3.3.1
    
    mkdir build
    
    cd build
    
    ../configure --disable-fortran
    
    make 
    
    sudo make install

    修改主机名后需要重启。

    sudo vim /etc/hostname

    修改为 master 或 client0,client1等

    sudo vim /etc/hosts

    增加 192.*.*.* master

    也就是增加master的IP地址。

    或者增加client的IP地址, 注意master机器的hosts也要更新这些ip

    sudo adduser mpiuser

     #设置密码 其余回车

    sudo apt­-get install openssh-server

    ################给mpiuser 增加sudo权限

    sudo chmod u+w /etc/sudoers
    
    sudo -i
    
    vim /etc/sudoers
    
    增加一行 mpiuser ALL=(ALL:ALL) ALL
    
    sudo chmod u-w /etc/sudoers

    ################给mpiuser 增加sudo权限

    su - mpiuser 

    #我们都在每个机器的mpiuser 用户中做实验,安装源码可以在主用户下,

    mpi用ssh进行通信,为了ssh通信免密我们需要用以下步骤生成秘钥文件,并发送到对方服务器,当然其他的机器也要互相做同样的动作。

    ssh-keygen -t rsa

     # 生成rsa秘钥

    ssh-copy-id -i ~/.ssh/id_rsa.pub master 

    # 发送秘钥给master 输入yes 和 master机器的密码

    sudo apt-get install nfs-kernel-server -y 

    # 安装网络文件服务器,因为mpi运行的程序必须是一致,而且需要快速更新。

    mkdir cloud
    
    sudo mount -t nfs master:/home/mpiuser/cloud ~/cloud

    test1#####################################

    mpirun -np 4 -hosts client,client1 ./cpi
    
    Process 3 of 4 is on client1
    Process 0 of 4 is on client
    Process 1 of 4 is on client1
    Process 2 of 4 is on client
    pi is approximately 3.1415926544231243, Error is 0.0000000008333312
    wall clock time = 0.001272

    另外一个test

    master 与 client 建立TCP链接 ,首先在master上run server程序。源码在

    https://github.com/qiaosiyi/ssserver/blob/master/tcptestserver.c

    编译之,

    mpicc tcptestserver.c -o tcptestserver

    tcptestclient ,同理。

     在master上运行:

    ################master###############################

    $ mpirun -np 1 ./tcptestserver
    
    $ portname: tag#0$description#master$port#36221$ifname#192.168.187.160$

    ################master###############################

    再在client上运行:

    ################client###############################

    $ mpirun -np 1 ./tcptestclient 'tag#0$description#master$port#36221$ifname#192.168.187.160$'
    
    $ Trying connect to tag#0$description#master$port#36221$ifname#192.168.187.160$

    ################client###############################

     在master上运行:

    ################master###############################

    $ client connected
    
    $ msg: 42

    ################master###############################

     =====

    qsy

    31 Jul 2019

  • 相关阅读:
    2018.4.5课堂笔记
    黑白染色——封锁阳光大学
    末日游戏——杨辉三角+搜索
    dilworth定理+属性排序(木棍加工)
    伯努利错装信封问题
    zhx'code1
    字符串-----KMP竟然是18禁
    Presto Event Listener开发
    Presto安装完成之后需要做的
    Apache Calcite 论文学习笔记
  • 原文地址:https://www.cnblogs.com/pandaroll/p/11274440.html
Copyright © 2011-2022 走看看