0% found this document useful (0 votes)
3 views1 page

MPI-Lab 1

This document provides a step-by-step installation procedure for setting up MPI for Python on Windows. It includes commands for checking CPU cores, installing Microsoft MPI, configuring the PATH environment variable, and installing the mpi4py library. Finally, it outlines how to create and execute a sample Python script using MPI functionalities.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

MPI-Lab 1

This document provides a step-by-step installation procedure for setting up MPI for Python on Windows. It includes commands for checking CPU cores, installing Microsoft MPI, configuring the PATH environment variable, and installing the mpi4py library. Finally, it outlines how to create and execute a sample Python script using MPI functionalities.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Amrita Vishwa Vidyapeetham, Bengaluru

Department of Computer Science and Engineering


19CSE312 – Distributed Systems

MPI for Python – Installation Procedure


1. To get the number of cores and logical processors type the following command in cmd
prompt, in windows.
wmic cpu get NumberOfCores,NumberOfLogicalProcessors
2. Install Python IDLE
3. Microsoft MPI
To use MPI with Windows, you will need to install the free download of Microsoft MPI.
Go to the installation page and download MSMpiSetup.exe. Once downloaded, run the
executable and follow the instructions.
You can find the version relevant for your machine. To download MPI for Windows 10,
use the link https://www.microsoft.com/en-us/download/details.aspx?id=57467 and
download the .exe file.
4. Next, add the path C:\Program Files\Microsoft MPI\bin to the PATH environment
variable. You can do this by typing the command:
PATH=%PATH%;C:\Program Files\Microsoft MPI\bin
5. Install mpi4py using pip install mpi4py
6. Open a new python file named script.py and type the following code:

from mpi4py import MPI

comm = MPI.COMM_WORLD
rank = comm.Get_rank()

if rank == 0:
print("Inside Parent Process")
else:
print("Inside Process ", rank)

7. Come to the prompt and execute the program using the following command
mpiexec -n 4 python script.py
or
mpiexec -n 4 py script.py (for windows 10)

You might also like