Distributed pytorch support in mpi

hello i had installed pytorch using the command
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 pytorch -c nvidia

and mpi using the command
sudo apt-get -y install mpich & conda install -c conda-forge mpi4py

but while executing distributed pytorch program , mpi support error occured
RuntimeError: Distributed package doesn’t have MPI built in. MPI is only included if you build PyTorch from source on a host that has MPI installed.
RuntimeError: Distributed package doesn’t have MPI built in. MPI is only included if you build PyTorch from source on a host that has MPI installed.
please give a solution for it

Did you follow this suggestion and build PyTorch from source with MPI support?

yes . pytorch distributed package not installed successfuly. anaconda ,cuda and mpi working properly. i can run pytorch in local system. using mpi python and c program working perfectly.
but my actual demand is use distributed pytorch in hpc( 5 client nodes and 1 server node)
any one can help me to install distributed pytorch with mpi support

my os is ubuntu 22.04 server
installed anaconda
cuda
pytorch ( ```
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia)

for mpi support

conda install -c conda-forge mpi4py

after that i checked mpi with following program.

from mpi4py import MPI

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

print(f"Hello from rank {rank} out of {size} processes!")

MPI.Finalize()
mpiexec -n 4 python mpi_hello.py

it work succefully

but while executing the distributed pytorch program it will not recognize mpi.

please help me