Complete MPICH2 Clustering Manual in Ubuntu

10
M Clustering b DATE: 13-Jun-15 MPICH2 g Manual in Ub by BSSE0509 buntu

Transcript of Complete MPICH2 Clustering Manual in Ubuntu

Page 1: Complete MPICH2 Clustering Manual in Ubuntu

MPICH2 Clustering Manual in Ubuntu

b

DATE: 13-Jun-15

MPICH2 Clustering Manual in Ubuntu

by BSSE0509

Clustering Manual in Ubuntu

Page 2: Complete MPICH2 Clustering Manual in Ubuntu

MPICH2 Clustering Manual in Ubuntu

by BSSE0509

Submitted to

Amit Seal Ami

Lecturer

Institute of Information Technology

University of Dhaka

Submitted by Minhas Kamal

Roll No: BSSE-0509

Institute of Information Technology

University of Dhaka

Submission Date 13th June, 2015

Page 3: Complete MPICH2 Clustering Manual in Ubuntu

Table of Contents

Introduction 1 Intended Audience and Purpose 1 Before Start 1 Preparing the Environment 2 Create a New User 2 Editing Hosts File 2 Installing OpenSSH 3 Generating SSH Key 3 Authorizing Keys 4 Installing MPICH2 4 Running Program through MPICH2 5 Setting up a Machine File 5 Running the First Program through MPICH2 6 Problems We Faced 7 Conclusion 7 References 7

Page 4: Complete MPICH2 Clustering Manual in Ubuntu

1

Introduction

MPI, the Message Passing Interface, is a library, and a software standard

developed by the MPI Forum to make use of the most attractive features of

existing message passing systems for parallel programming. An MPI process

consists of a C or Fortran 77 program which communicates with other MPI

processes by calling MPI routines. The MPI routines provide the programmer with

a consistent interface across a wide variety of different platforms. The MPICH

implementation is a library of several hundred C and Fortran routines which let

write programs that run in parallel and communicate with each other. In this

document we are going to describe how to install MPICH2 in Linux Ubuntu and

setup the environment to run a program.

Intended Audience and Purpose

Ubuntu users who want to work with parallel computers are the primary target of

this document.

The purpose of this document is to provide a complete guideline along with

explanations, and necessary backgrounds to set up clusters using computers

connected in a LAN.

Before Start

Before getting started, some prerequisites are necessary-

1. gcc is installed. 2. User has access to at least 2 computers as administrator with LAN. 3. The IP addresses are static. 4. PC is connected to internet.

Page 5: Complete MPICH2 Clustering Manual in Ubuntu

Preparing the Environment

Create a New User

MPICH uses remote logins to execute processes through MPI job.need a new user. Create all of the PCs by going to User Accounts. We named it

Give administrative privilegenew account.

Editing Hosts File

Use text editor such as gedit

need super user permission to change it.

Now we have to edit the hosts file according to the PCs’ username and IP

addresses which can be found by typing

Environment

MPICH uses remote logins to execute processes through MPI job.Create user on

going to Settings> We named it mpiuser.

privilege to the

gedit to edit the file at /etc/hosts in all th

super user permission to change it. Write this command.

Now we have to edit the hosts file according to the PCs’ username and IP

addresses which can be found by typing ifconfig in the terminal.

2

MPICH uses remote logins to execute processes through MPI job. For this we

in all the PCs. We will

Now we have to edit the hosts file according to the PCs’ username and IP

Page 6: Complete MPICH2 Clustering Manual in Ubuntu

Installing OpenSSH

We install openSSH in Ubuntu using this command:

sudo apt

Generating SSH Key

After logging in to mpiuser

ssh-keygen

It will ask where to save the file; without typing

whether any password will be used;

confirmation.

install openSSH in Ubuntu using this command:

sudo apt-get install openssh-server

mpiuser account, open terminal. Now type:

keygen -t dsa

ill ask where to save the file; without typing press ‘enter’. Then it will ask

ether any password will be used; again press ‘enter’. Press ‘enter

3

. Then it will ask

enter’ again for

Page 7: Complete MPICH2 Clustering Manual in Ubuntu

4

Authorizing Keys

Now we save the generated key in authorized keys using the following command-

cat id_dsa.pub >> authorized_keys

Now to see the authorized keys, use the following command-

cat authorized_keys

Something like this will be displayed in the terminal-

Now, we collect all authorized keys and append every of them in all PCs’ authorized keys’ file. We use this command to open it in ‘nano’ text editor-

nano authorized_keys

Installing MPICH2

Run the following command in each PC to install MPICH2 -

sudo apt-get install mpich2

After installation we can verify the version of MPICH by the next command-

mpich version

ssh-dss

AAAAB3NzaC1kc3MAAACBAK7gF+yy3cix5N+YWNBYktA9d28fuprAOm+aMBCMmNPJni63c59PgY

FPbb3bDDT/zDkmhl8cQiGe9W70b018vTXIpZFNoWKzBRNtSafP9vyyH+bZOfHDdWzhXM+c3PZK

PEe2h1D872LFNhi6MJzAGDAXEluMKJaUCyX79REqZ+bTAAAAFQDZmSmavlMunmPcLCMq7T9Plg

jIGwAAAIA1RmddGEyyhxxtxWhpBsj0sHI+tCANLrjHaHHAP220ZaLKPlm3y4nBqND24z2CaOsc

1mEQElXq39nCrjxbr8bijc/Y/WEJciXC0vR0ge5w/UbUGaPI8b1cwppzClZ3XWJMn7ffR6exH7

5t5Nb3REtPFITk3PkedTb5NObXk/rzEQAAAIAMVFOWQR4d8mde5xZlG8SB1Iz6RA8W3NcqN8x8

fJ+9h34jyWp4sAMRuTEkB3Lymh85NLZNY0AI4Y1hTTYOsZtPmdgGNzEVnHdZIdaYdLPYGgRQ2K

sltX0JBXnNrJIgrcCN1TElcTH+F801hvylLmKp7Sm4oGMJiUwI7o74v9pZ7Q==

mpiuser@iit123

Page 8: Complete MPICH2 Clustering Manual in Ubuntu

5

Running Program through MPICH2

Setting up a Machine File

We create a file named ‘machinefile’, write node names followed by a colon

and number of processes to spawn and store it to the root of mpiuser.

Change its mod using the command-

chmod +x machinefile

Lets store this file in every PC’s root folder.

iit123:4 misubeimp:2 bsse0532-H61MLV:3 orbachinujbuk:1

Page 9: Complete MPICH2 Clustering Manual in Ubuntu

Running the First Program through MPICH2

Lets write this code in a file

Now run this command to compile the program

mpicc mpi_hello.c

Run the program using this-

mpi

Output put will be like the following image

#include <stdio.h> #include <mpi.h> int main(int argc, char** argv) { int myrank, nprocs; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &nprocs); MPI_Comm_rank(MPI_COMM_WORLD, &myrank); printf("Hello from processor %d of %d MPI_Finalize(); return 0; }

Running the First Program through MPICH2

& name it ‘mpi_hello.c’.

Now run this command to compile the program-

mpicc mpi_hello.c -o mpi_hello

-

mpirun -n 10 -f machinefile ./mpi_hello

will be like the following image-

int main(int argc, char** argv) { int myrank, nprocs;

MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &nprocs); MPI_Comm_rank(MPI_COMM_WORLD, &myrank);

printf("Hello from processor %d of %d\n", myrank, nprocs);

6

f machinefile ./mpi_hello

n", myrank, nprocs);

Page 10: Complete MPICH2 Clustering Manual in Ubuntu

7

Problems We Faced:

Problem 1: Was not getting connection with other PCs.

Solution: Before running the program ping each PC to set up the connection.

Problem 2: Showing error in running the program.

Solution: As our PCs have temporary IP addresses, so rewrite the host fille’s IP

addresses after every reboot.

Problem 3: Getting error in finding ‘machinefile’.

Solution: We forgot to change the accessibility of the ‘machinefile’. Run this

command- chmod +x machinefile

Conclusion

So here, we have gone through a short definition of parallel computing and

MPICH. We installed the environment, MPICH2 and finally a program, which runs

on parallel computers. By following all the instructions here any technical person

should be able to setup MPICH cluster without any difficulty.

References

http://www.eecis.udel.edu/~pollock/372/manual/manual.html

https://help.ubuntu.com/community/MpichCluster