Last active
February 22, 2021 20:38
-
-
Save arm2arm/533b108f7a23cde71a6f93624ec7d6e8 to your computer and use it in GitHub Desktop.
python MPI on with conda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# HPC MPI enviroment for python jobs | |
``` | |
conda create -n mpi | |
conda activate mpi | |
conda install openmpi openmpi-mpicc mpi4py matplotlib astropy scikit-learn pandas pytables | |
``` | |
# testing | |
``` | |
from mpi4py import MPI | |
import numpy | |
comm = MPI.COMM_WORLD | |
rank = comm.Get_rank() | |
size = comm.Get_size() | |
if rank == 0: | |
data = [i*i for i in range(size)] | |
print('I am Rank 0 ') | |
else: | |
data = None | |
data=comm.scatter(data,root=0) | |
print(f'On process {rank}, data is {data}') | |
``` | |
mpirun -np 4 python test.mpi.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment