Lightning-AI / Lightning-AI/pytorch-lightning
test_ddp.py hangs at test_ddp_configure_ddp
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 31.4k
- Forks
- 3.8k
- Avg merge
- 6d 7h
- Merged PRs (30d)
- 6
Description
### Bug description
When I try to run single test on multi-gpu device, it hangs at specific test case `test_ddp_configure_ddp` https://github.com/Lightning-AI/pytorch-lightning/blob/6f6c07dddfd68717f0b765a63d05a937b8508e15/tests/tests_pytorch/strategies/test_ddp.py#L142.
I've found that this case is related to `torch.distributed.init_process_group` . https://github.com/Lightning-AI/pytorch-lightning/blob/6f6c07dddfd68717f0b765a63d05a937b8508e15/src/lightning/fabric/utilities/distributed.py#L258
I have 4 gpus on my device, so the `world_size` send to `init_process_group` is 4, but the way I ran the test seems not include multiprocessing, so `init_process_group` just hangs for device to be ready.
When I set `CUDA_VISIBLE_DEVICES` to single device, it works fine. I'm not sure is this a bug or I've used the wrong command to run test. If so. how should I run this test?
### What version are you seeing the problem on?
v2.1
### How to reproduce the bug
```python
On multi-gpu environment:
pytest -v tests/tests_pytorch/strategies/test_ddp.py -k test_ddp_configure_ddp
```
### Error messages and logs
```
# Error messages and logs here please
no Error message, just hang up for a long time(default args: 1800 seconds)
```
### Environment
Current environment
* CUDA:
- GPU:
- Tesla V100-SXM2-16GB
- Tesla V100-SXM2-16GB
- Tesla V100-SXM2-16GB
- Tesla V100-SXM2-16GB
- available: True
- version: 12.2
* Lightning:
- lightning: 2.1.0
- lightning-utilities: 0.10.1
- pytorch-lightning: 2.2.1
- torch: 2.3.0a0+gitbfa71b5
- torchmetrics: 1.3.1
- torchvision: 0.18.0a0+423a1b0
* Packages:
- aiohttp: 3.9.4rc0
- aiosignal: 1.3.1
- annotated-types: 0.6.0
- astunparse: 1.6.3
- async-timeout: 4.0.3
- attrs: 23.2.0
- audioread: 3.0.1
- certifi: 2023.11.17
- cffi: 1.16.0
- charset-normalizer: 3.3.2
- contourpy: 1.2.0
- cycler: 0.12.1
- decorator: 5.1.1
- dllogger: 1.0.0
- exceptiongroup: 1.2.0
- expecttest: 0.2.1
- filelock: 3.13.1
- fonttools: 4.49.0
- frozenlist: 1.4.1
- fsspec: 2023.12.2
- hypothesis: 6.97.3
- idna: 3.6
- inflect: 7.0.0
- iniconfig: 2.0.0
- jinja2: 3.1.3
- joblib: 1.3.2
- kiwisolver: 1.4.5
- librosa: 0.8.1
- lightning: 2.1.0
- lightning-utilities: 0.10.1
- llvmlite: 0.42.0
- markupsafe: 2.1.4
- matplotlib: 3.8.3
- mpmath: 1.3.0
- multidict: 6.0.5
- networkx: 3.2.1
- numba: 0.59.0
- numpy: 1.23.1
- optree: 0.10.0
- packaging: 23.2
- pillow: 10.2.0
- pip: 22.2.2
- platformdirs: 4.2.0
- pluggy: 1.4.0
- pooch: 1.8.1
- psutil: 5.9.8
- pycparser: 2.21
- pydantic: 2.6.3
- pydantic-core: 2.16.3
- pyparsing: 3.1.2
- pytest: 8.1.1
- python-dateutil: 2.9.0.post0
- pytorch-lightning: 2.2.1
- pyyaml: 6.0.1
- requests: 2.31.0
- resampy: 0.4.3
- scikit-learn: 1.4.1.post1
- scipy: 1.12.0
- setuptools: 63.2.0
- six: 1.16.0
- sortedcontainers: 2.4.0
- soundfile: 0.12.1
- sympy: 1.12
- tabulate: 0.9.0
- threadpoolctl: 3.3.0
- tomli: 2.0.1
- torch: 2.3.0a0+gitbfa71b5
- torchmetrics: 1.3.1
- torchvision: 0.18.0a0+423a1b0
- tqdm: 4.66.2
- types-dataclasses: 0.6.6
- typing-extensions: 4.9.0
- unidecode: 1.3.8
- urllib3: 2.2.0
- wheel: 0.42.0
- yarl: 1.9.4
* System:
- OS: Linux
- architecture:
- 64bit
- ELF
- processor: x86_64
- python: 3.10.8
- release: 5.11.0-27-generic
- version: #29~20.04.1-Ubuntu SMP Wed Aug 11 15:58:17 UTC 2021
### More info
_No response_
cc @lantiga @borda
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with tests/tests_pytorch/strategies/test_ddp.py at test_ddp_configure_ddp and the distributed initialization path in src/lightning/fabric/utilities/distributed.py. Run the reported pytest command on a multi-GPU environment and compare it with a single visible device. Done means the test no longer hangs when invoked as documented, or the correct multiprocessing command and test guidance are documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- distributed-systems, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100