Skip to content

Removed the deprecated Trainer.data_parallel_device_ids function in favour of Trainer.device_ids #14422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 28, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/pytorch_lightning/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Removed deprecated support for old torchtext versions ([#14375](https://github.com/Lightning-AI/lightning/pull/14375))


- Removed the depricated `Trainer.data_parallel_device_ids` hook in favour of `Trainer.device_ids` ((#14422)[https://github.com/Lightning-AI/lightning/pull/14422])


### Fixed

- Fixed `LightningDataModule` hparams parsing ([#12806](https://github.com/PyTorchLightning/pytorch-lightning/pull/12806))
Expand Down
8 changes: 0 additions & 8 deletions src/pytorch_lightning/trainer/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2108,14 +2108,6 @@ def devices(self) -> int:
)
return self.num_devices

@property
def data_parallel_device_ids(self) -> Optional[List[int]]:
rank_zero_deprecation(
"`Trainer.data_parallel_device_ids` was deprecated in v1.6 and will be removed in v1.8."
" Please use `Trainer.device_ids` instead."
)
return self.device_ids if isinstance(self.accelerator, CUDAAccelerator) else None

@property
def lightning_module(self) -> "pl.LightningModule":
# TODO: this is actually an optional return
Expand Down
26 changes: 0 additions & 26 deletions tests/tests_pytorch/deprecated_api/test_remove_1-8.py
Original file line number Diff line number Diff line change
Expand Up @@ -883,32 +883,6 @@ def test_trainer_num_processes(monkeypatch, trainer_kwargs, expected_num_process
trainer.num_processes == expected_num_processes


@pytest.mark.parametrize(
["trainer_kwargs", "expected_data_parallel_device_ids"],
[
({}, None),
({"devices": 1}, None),
({"devices": "1"}, None),
({"accelerator": "gpu", "devices": 1}, [0]),
({"accelerator": "gpu", "devices": 2}, [0, 1]),
({"accelerator": "gpu", "devices": [1]}, [1]),
({"accelerator": "gpu", "devices": "0,"}, [0]),
],
)
def test_trainer_data_parallel_device_ids(monkeypatch, trainer_kwargs, expected_data_parallel_device_ids):
"""Test multi type argument with bool."""
if trainer_kwargs.get("accelerator") == "gpu":
monkeypatch.setattr(device_parser, "is_cuda_available", lambda: True)
monkeypatch.setattr(device_parser, "num_cuda_devices", lambda: 2)

trainer = Trainer(**trainer_kwargs)
with pytest.deprecated_call(
match="`Trainer.data_parallel_device_ids` was deprecated in v1.6 and will be removed in v1.8."
" Please use `Trainer.device_ids` instead."
):
assert trainer.data_parallel_device_ids == expected_data_parallel_device_ids


def test_deprecated_mc_save_checkpoint():
mc = ModelCheckpoint()
trainer = Trainer()
Expand Down