Skip to content

Commit 8ac4843

Browse files
roccomorettideependujhajustusschock
authored
Catch issue with partial mpi4py installation. (#21353)
* Catch issue with partial mpi4py installation. Depending on precise install, mpi4py may be installed without `MPI` being present. Catch that case in the detect() function, and treat it as if mpi4py is not installed. * update * update * update --------- Co-authored-by: deependujha <[email protected]> Co-authored-by: Justus Schock <[email protected]>
1 parent c76cec6 commit 8ac4843

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/lightning/fabric/CHANGELOG.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
2525

2626
### Fixed
2727

28-
- Fixed `EADDRINUSE` errors in distributed tests with port manager and retry logic ([#21309](https://github.com/Lightning-AI/pytorch-lightning/pull/21309))
29-
28+
- Fixed issue in detecting MPIEnvironment with partial mpi4py installation ([#21353](https://github.com/Lightning-AI/pytorch-lightning/pull/21353))
3029

3130
- Learning rate scheduler is stepped at the end of epoch when `on_train_batch_start` returns -1 ([#21296](https://github.com/Lightning-AI/pytorch-lightning/issues/21296)).
3231

3332

34-
3533
---
3634

3735
## [2.5.5] - 2025-09-05

src/lightning/fabric/plugins/environments/mpi.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ def detect() -> bool:
7373
if not _MPI4PY_AVAILABLE:
7474
return False
7575

76-
from mpi4py import MPI
76+
try:
77+
# mpi4py may be installed without MPI being present
78+
from mpi4py import MPI
79+
except ImportError:
80+
return False
7781

7882
return MPI.COMM_WORLD.Get_size() > 1
7983

0 commit comments

Comments
 (0)