I get the above mentioned error when I try to run the followed code:
import torch.distributed
import ipdb
if name == ‘main’:
ipdb.set_trace()
torch.distributed.init_process_group(backend=‘mpi’)
rank = torch.distributed.collectives.get_rank()
print('My rank is ' + rank)

I am running this code on command line as follows:
mpiexec -n 2 python main.py 4