Distributed package doesn't have MPI built in

kluegit: <p>Environment : docker container &amp; anaconda3<br>
docker images : <a href="http://nvcr.io/nvidia/pytorch:22.09-py3" rel="noopener nofollow ugc">nvcr.io/nvidia/pytorch:22.09-py3</a><br>
conda installed : pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia</p>
<p>line 82 : dist.init_process_group(backend=‘mpi’)</p>
<p>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 <a href="https://github.com/NVIDIA/FasterTransformer/blob/main/docs/gpt_guide.md#run-meta-opt" class="inline-onebox" rel="noopener nofollow ugc">FasterTransformer/docs/gpt_guide.md at main · NVIDIA/FasterTransformer · GitHub</a><br>
error message occurs:<br>
Traceback (most recent call last):<br>
File “/workspace/FasterTransformer/build/…/examples/pytorch/gpt/opt_summarization.py”, line 379<br>
File “/workspace/FasterTransformer/build/…/examples/pytorch/gpt/opt_summarization.py”, line 82<br>
dist.init_process_group(backend=‘mpi’)<br>
File “/root/anaconda3/envs/ft/lib/python3.10/site-packages/torch/distributed/c10d_logger.py”, line 74, in wrapper<br>
func_return = func(*args, **kwargs)<br>
File “/root/anaconda3/envs/ft/lib/python3.10/site-packages/torch/distributed/distributed_c10d.py”, line 1131, in init_process_group<br>
default_pg, _ = _new_process_group_helper(<br>
File “/root/anaconda3/envs/ft/lib/python3.10/site-packages/torch/distributed/distributed_c10d.py”, line 1248, in _new_process_group_helper<br>
raise RuntimeError(<br>
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.</p>
<p>$ python -m torch.utils.collect_env<br>
result :<br>
PyTorch version: 2.1.2<br>
Is debug build: False<br>
CUDA used to build PyTorch: 11.8<br>
ROCM used to build PyTorch: N/A</p>
<p>OS: Ubuntu 20.04.5 LTS (x86_64)<br>
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0<br>
Clang version: Could not collect<br>
CMake version: version 3.22.2<br>
Libc version: glibc-2.31</p>
<p>Python version: 3.10.9<br>
Python platform: Linux-5.4.0-167-generic-x86_64-with-glibc2.31<br>
Is CUDA available: True<br>
CUDA runtime version: 11.8.89<br>
CUDA_MODULE_LOADING set to: LAZY<br>
GPU models and configuration: GPU 0: NVIDIA TITAN V<br>
Nvidia driver version: 545.23.08<br>
cuDNN version: Probably one of the following:<br>
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.6.0<br>
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.6.0<br>
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.6.0<br>
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.6.0<br>
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.6.0<br>
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.6.0<br>
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.6.0<br>
HIP runtime version: N/A<br>
MIOpen runtime version: N/A<br>
Is XNNPACK available: True</p>
<p>CPU:<br>
Architecture:                       x86_64<br>
CPU op-mode(s):                     32-bit, 64-bit<br>
Byte Order:                         Little Endian<br>
Address sizes:                      46 bits physical, 48 bits virtual<br>
CPU(s):                             16<br>
On-line CPU(s) list:                0-15<br>
Thread(s) per core:                 2<br>
Core(s) per socket:                 8<br>
Socket(s):                          1<br>
NUMA node(s):                       1<br>
Vendor ID:                          GenuineIntel<br>
CPU family:                         6<br>
Model:                              85<br>
Model name:                         Intel(R) Core™ i7-7820X CPU @ 3.60GHz<br>
Stepping:                           4<br>
CPU MHz:                            3999.999<br>
CPU max MHz:                        4500.0000<br>
CPU min MHz:                        1200.0000<br>
BogoMIPS:                           7200.00<br>
Virtualization:                     VT-x<br>
L1d cache:                          256 KiB<br>
L1i cache:                          256 KiB<br>
L2 cache:                           8 MiB<br>
L3 cache:                           11 MiB<br>
NUMA node0 CPU(s):                  0-15<br>
Vulnerability Gather data sampling: Mitigation; Microcode<br>
Vulnerability Itlb multihit:        KVM: Mitigation: Split huge pages<br>
Vulnerability L1tf:                 Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable<br>
Vulnerability Mds:                  Mitigation; Clear CPU buffers; SMT vulnerable<br>
Vulnerability Meltdown:             Mitigation; PTI<br>
Vulnerability Mmio stale data:      Mitigation; Clear CPU buffers; SMT vulnerable<br>
Vulnerability Retbleed:             Mitigation; IBRS<br>
Vulnerability Spec store bypass:    Mitigation; Speculative Store Bypass disabled via prctl and seccomp<br>
Vulnerability Spectre v1:           Mitigation; usercopy/swapgs barriers and __user pointer sanitization<br>
Vulnerability Spectre v2:           Mitigation; IBRS, IBPB conditional, STIBP conditional, RSB filling, PBRSB-eIBRS Not affected<br>
Vulnerability Srbds:                Not affected<br>
Vulnerability Tsx async abort:      Mitigation; Clear CPU buffers; SMT vulnerable<br>
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</p>
<p>Versions of relevant libraries:<br>
[pip3] numpy==1.26.3<br>
[pip3] torch==2.1.2<br>
[pip3] torchaudio==2.1.2<br>
[pip3] torchvision==0.16.2<br>
[pip3] triton==2.1.0<br>
[conda] blas                      1.0                         mkl<br>
[conda] ffmpeg                    4.3                  hf484d3e_0    pytorch<br>
[conda] libjpeg-turbo             2.0.0                h9bf148f_0    pytorch<br>
[conda] mkl                       2023.1.0         h213fc3f_46344<br>
[conda] mkl-service               2.4.0           py310h5eee18b_1<br>
[conda] mkl_fft                   1.3.8           py310h5eee18b_0<br>
[conda] mkl_random                1.2.4           py310hdb19cb5_0<br>
[conda] numpy                     1.26.3          py310h5f9d8c6_0<br>
[conda] numpy-base                1.26.3          py310hb5e798b_0<br>
[conda] pytorch                   2.1.2           py3.10_cuda11.8_cudnn8.7.0_0    pytorch<br>
[conda] pytorch-cuda              11.8                 h7e8668a_5    pytorch<br>
[conda] pytorch-mutex             1.0                        cuda    pytorch<br>
[conda] torchaudio                2.1.2               py310_cu118    pytorch<br>
[conda] torchtriton               2.1.0                     py310    pytorch<br>
[conda] torchvision               0.16.2              py310_cu118    pytorch</p>
<p>I’ve been thinking about it for 2 days, but I couldn’t solve it. Please help me</p>

rohitdat: <p>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.</p>
<p>PyTorch supports several frameworks when it comes to the backend to use for distribution and communication: <strong>MPI, Gloo, NCCL</strong>. For more information, please refer to this <a href="https://pytorch.org/docs/stable/distributed.html" rel="noopener nofollow ugc">link</a>.</p>
<p>While Gloo and NCCL comes by default in PyTorch, in order to benefit from MPI backend, <strong>you need to build PyTorch from source</strong> (instead of installing it via pip or conda).</p>
<pre><code class="lang-auto">To enable backend == Backend.MPI, PyTorch needs to be built from source on a system that supports MPI.
</code></pre>
<p>For more information on how to do that, please refer to this github <a href="https://github.com/pytorch/pytorch#from-source" rel="noopener nofollow ugc">page</a>.</p>
<p>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 <a href="https://pytorch.org/docs/stable/distributed.html#which-backend-to-use" rel="noopener nofollow ugc">here</a>.</p>
<p>Good Luck!</p>

kluegit: <p>Thanks, I will try it.</p>

kluegit: <p>I solved it by exception handling code</p>