Distributed package doesn't have MPI built in

Environment : docker container & anaconda3
docker images : nvcr.io/nvidia/pytorch:22.09-py3
conda installed : pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia

line 82 : dist.init_process_group(backend=‘mpi’)

When I execute python3 …/examples/pytorch/gpt/opt_summarization.py --summarize --test_hf --max_ite 20 --ft_model_location opt-125m/c-model --hf_model_name opt-125m # from FasterTransformer/docs/gpt_guide.md at main · NVIDIA/FasterTransformer · GitHub
error message occurs:
Traceback (most recent call last):
File “/workspace/FasterTransformer/build/…/examples/pytorch/gpt/opt_summarization.py”, line 379
File “/workspace/FasterTransformer/build/…/examples/pytorch/gpt/opt_summarization.py”, line 82
File “/root/anaconda3/envs/ft/lib/python3.10/site-packages/torch/distributed/c10d_logger.py”, line 74, in wrapper
func_return = func(*args, **kwargs)
File “/root/anaconda3/envs/ft/lib/python3.10/site-packages/torch/distributed/distributed_c10d.py”, line 1131, in init_process_group
default_pg, _ = _new_process_group_helper(
File “/root/anaconda3/envs/ft/lib/python3.10/site-packages/torch/distributed/distributed_c10d.py”, line 1248, in _new_process_group_helper
raise RuntimeError(
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.

$ python -m torch.utils.collect_env
result :
PyTorch version: 2.1.2
Is debug build: False
CUDA used to build PyTorch: 11.8
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.5 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Clang version: Could not collect
CMake version: version 3.22.2
Libc version: glibc-2.31

Python version: 3.10.9
Python platform: Linux-5.4.0-167-generic-x86_64-with-glibc2.31
Is CUDA available: True
CUDA runtime version: 11.8.89
GPU models and configuration: GPU 0: NVIDIA TITAN V
Nvidia driver version: 545.23.08
cuDNN version: Probably one of the following:
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
Address sizes: 46 bits physical, 48 bits virtual
CPU(s): 16
On-line CPU(s) list: 0-15
Thread(s) per core: 2
Core(s) per socket: 8
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 85
Model name: Intel(R) Core™ i7-7820X CPU @ 3.60GHz
Stepping: 4
CPU MHz: 3999.999
CPU max MHz: 4500.0000
CPU min MHz: 1200.0000
BogoMIPS: 7200.00
Virtualization: VT-x
L1d cache: 256 KiB
L1i cache: 256 KiB
L2 cache: 8 MiB
L3 cache: 11 MiB
NUMA node0 CPU(s): 0-15
Vulnerability Gather data sampling: Mitigation; Microcode
Vulnerability Itlb multihit: KVM: Mitigation: Split huge pages
Vulnerability L1tf: Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable
Vulnerability Mds: Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Meltdown: Mitigation; PTI
Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Retbleed: Mitigation; IBRS
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; IBRS, IBPB conditional, STIBP conditional, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Mitigation; Clear CPU buffers; SMT vulnerable
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single pti ssbd mba ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req md_clear flush_l1d arch_capabilities

Versions of relevant libraries:
[pip3] numpy==1.26.3
[pip3] torch==2.1.2
[pip3] torchaudio==2.1.2
[pip3] torchvision==0.16.2
[pip3] triton==2.1.0
[conda] blas 1.0 mkl
[conda] ffmpeg 4.3 hf484d3e_0 pytorch
[conda] libjpeg-turbo 2.0.0 h9bf148f_0 pytorch
[conda] mkl 2023.1.0 h213fc3f_46344
[conda] mkl-service 2.4.0 py310h5eee18b_1
[conda] mkl_fft 1.3.8 py310h5eee18b_0
[conda] mkl_random 1.2.4 py310hdb19cb5_0
[conda] numpy 1.26.3 py310h5f9d8c6_0
[conda] numpy-base 1.26.3 py310hb5e798b_0
[conda] pytorch 2.1.2 py3.10_cuda11.8_cudnn8.7.0_0 pytorch
[conda] pytorch-cuda 11.8 h7e8668a_5 pytorch
[conda] pytorch-mutex 1.0 cuda pytorch
[conda] torchaudio 2.1.2 py310_cu118 pytorch
[conda] torchtriton 2.1.0 py310 pytorch
[conda] torchvision 0.16.2 py310_cu118 pytorch

I’ve been thinking about it for 2 days, but I couldn’t solve it. Please help me

I believe you are trying to use the distributed package from PyTorch. Although I am not an expert, I will try to explain what I know about it.

PyTorch supports several frameworks when it comes to the backend to use for distribution and communication: MPI, Gloo, NCCL. For more information, please refer to this link.

While Gloo and NCCL comes by default in PyTorch, in order to benefit from MPI backend, you need to build PyTorch from source (instead of installing it via pip or conda).

To enable backend == Backend.MPI, PyTorch needs to be built from source on a system that supports MPI.

For more information on how to do that, please refer to this github page.

However, this task is not really trivial so you might first want to look more closely at what you want to achieve and evaluate if Gloo or NCCL may suit your goals. The rule of thumb to choose the right backend can be found here.

Good Luck!

Thanks, I will try it.

I solved it by exception handling code