!mpiexec
Microsoft MPI Startup Program [Version 10.1.12498.52]
Launches an application on multiple hosts.
Usage:
mpiexec [options] executable [args] [ : [options] exe [args] : ... ]
mpiexec -configfile <file name>
Common options:
-n <num_processes>
-env <env_var_name> <env_var_value>
-wdir <working_directory>
-hosts n host1 [m1] host2 [m2] ... hostn [mn]
-cores <num_cores_per_host>
-lines
-debug [0-3]
-logfile <log file>
Examples:
mpiexec -n 4 pi.exe
mpiexec -hosts 1 server1 master : -n 8 worker
For a complete list of options, run mpiexec -help2
For a list of environment variables, run mpiexec -help3
You can reach the Microsoft MPI team via email at askmpi@microsoft.com
from mpi4py import MPI
size = MPI.COMM_WORLD.Get_size()
rank = MPI.COMM_WORLD.Get_rank()
pname = MPI.Get_processor_name()
print(f"Hello from {pname} - {rank}/{size}")
--------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_10484\3061372955.py in <cell line: 0>() ----> 1 from mpi4py import MPI 2 size = MPI.COMM_WORLD.Get_size() 3 rank = MPI.COMM_WORLD.Get_rank() 4 pname = MPI.Get_processor_name() 5 print(f"Hello from {pname} - {rank}/{size}") ModuleNotFoundError: No module named 'mpi4py'
!pip install mpi4py
Defaulting to user installation because normal site-packages is not writeable Collecting mpi4py Downloading mpi4py-4.0.3-cp311-cp311-win_amd64.whl.metadata (10 kB) Downloading mpi4py-4.0.3-cp311-cp311-win_amd64.whl (1.6 MB) ---------------------------------------- 1.6/1.6 MB 11.3 MB/s eta 0:00:00 Installing collected packages: mpi4py Successfully installed mpi4py-4.0.3
from mpi4py import MPI
size = MPI.COMM_WORLD.Get_size()
rank = MPI.COMM_WORLD.Get_rank()
pname = MPI.Get_processor_name()
print(f"Hello from {pname} - {rank}/{size}")
Hello from pf-cai-p03-pc0 - 0/1
%%writefile mpi01.py
from mpi4py import MPI
size = MPI.COMM_WORLD.Get_size()
rank = MPI.COMM_WORLD.Get_rank()
pname = MPI.Get_processor_name()
print(f"Hello from {pname} - {rank}/{size}")
Writing mpi01.py
!mpiexec python mpi01.py
Hello from pf-cai-p03-pc0 - 4/6 Hello from pf-cai-p03-pc0 - 1/6 Hello from pf-cai-p03-pc0 - 5/6 Hello from pf-cai-p03-pc0 - 2/6 Hello from pf-cai-p03-pc0 - 0/6 Hello from pf-cai-p03-pc0 - 3/6
!mpiexec -n 4 python mpi01.py
Hello from pf-cai-p03-pc0 - 0/4 Hello from pf-cai-p03-pc0 - 2/4 Hello from pf-cai-p03-pc0 - 1/4 Hello from pf-cai-p03-pc0 - 3/4