Skip to content

Commit 6feda08

Browse files
daniellepintzcarmoccaSkafteNickirohitgr7
authored
Deprecate GPUStatsMonitor and XLAStatsMonitor in favor of DeviceStatsMonitor (#9924)
Co-authored-by: Carlos Mocholí <[email protected]> Co-authored-by: Nicki Skafte Detlefsen <[email protected]> Co-authored-by: Rohit Gupta <[email protected]>
1 parent a002f87 commit 6feda08

File tree

4 files changed

+38
-3
lines changed

4 files changed

+38
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
362362
- Deprecated passing `weights_summary` to the `Trainer` constructor in favor of adding the `ModelSummary` callback with `max_depth` directly to the list of callbacks ([#9699](https://github.com/PyTorchLightning/pytorch-lightning/pull/9699))
363363

364364

365+
- Deprecated `GPUStatsMonitor` and `XLAStatsMonitor` in favor of `DeviceStatsMonitor` callback ([#9924](https://github.com/PyTorchLightning/pytorch-lightning/pull/9924))
366+
365367
### Removed
366368

367369
- Removed deprecated `metrics` ([#8586](https://github.com/PyTorchLightning/pytorch-lightning/pull/8586/))

pytorch_lightning/callbacks/gpu_stats_monitor.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,18 @@
2929

3030
import pytorch_lightning as pl
3131
from pytorch_lightning.callbacks.base import Callback
32-
from pytorch_lightning.utilities import DeviceType, rank_zero_only
32+
from pytorch_lightning.utilities import DeviceType, rank_zero_deprecation, rank_zero_only
3333
from pytorch_lightning.utilities.exceptions import MisconfigurationException
3434
from pytorch_lightning.utilities.parsing import AttributeDict
3535
from pytorch_lightning.utilities.types import STEP_OUTPUT
3636

3737

3838
class GPUStatsMonitor(Callback):
3939
r"""
40+
.. deprecated:: v1.5
41+
The `GPUStatsMonitor` callback was deprecated in v1.5 and will be removed in v1.7.
42+
Please use the `DeviceStatsMonitor` callback instead.
43+
4044
Automatically monitors and logs GPU stats during training stage. ``GPUStatsMonitor``
4145
is a callback and in order to use it you need to assign a logger in the ``Trainer``.
4246
@@ -91,6 +95,11 @@ def __init__(
9195
):
9296
super().__init__()
9397

98+
rank_zero_deprecation(
99+
"The `GPUStatsMonitor` callback was deprecated in v1.5 and will be removed in v1.7."
100+
" Please use the `DeviceStatsMonitor` callback instead."
101+
)
102+
94103
if shutil.which("nvidia-smi") is None:
95104
raise MisconfigurationException(
96105
"Cannot use GPUStatsMonitor callback because NVIDIA driver is not installed."

pytorch_lightning/callbacks/xla_stats_monitor.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,20 @@
2121
import time
2222

2323
from pytorch_lightning.callbacks.base import Callback
24-
from pytorch_lightning.utilities import _TPU_AVAILABLE, DeviceType, rank_zero_info
24+
from pytorch_lightning.utilities import _TPU_AVAILABLE, DeviceType, rank_zero_deprecation, rank_zero_info
2525
from pytorch_lightning.utilities.exceptions import MisconfigurationException
2626

2727
if _TPU_AVAILABLE:
2828
import torch_xla.core.xla_model as xm
2929

3030

3131
class XLAStatsMonitor(Callback):
32-
"""Automatically monitors and logs XLA stats during training stage. ``XLAStatsMonitor`` is a callback and in
32+
r"""
33+
.. deprecated:: v1.5
34+
The `XLAStatsMonitor` callback was deprecated in v1.5 and will be removed in v1.7.
35+
Please use the `DeviceStatsMonitor` callback instead.
36+
37+
Automatically monitors and logs XLA stats during training stage. ``XLAStatsMonitor`` is a callback and in
3338
order to use it you need to assign a logger in the ``Trainer``.
3439
3540
Args:
@@ -51,6 +56,11 @@ class XLAStatsMonitor(Callback):
5156
def __init__(self, verbose: bool = True) -> None:
5257
super().__init__()
5358

59+
rank_zero_deprecation(
60+
"The `XLAStatsMonitor` callback was deprecated in v1.5 and will be removed in v1.7."
61+
" Please use the `DeviceStatsMonitor` callback instead."
62+
)
63+
5464
if not _TPU_AVAILABLE:
5565
raise MisconfigurationException("Cannot use XLAStatsMonitor with TPUs are not available")
5666

tests/deprecated_api/test_remove_1-7.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import torch
1919

2020
from pytorch_lightning import Callback, LightningDataModule, Trainer
21+
from pytorch_lightning.callbacks.gpu_stats_monitor import GPUStatsMonitor
22+
from pytorch_lightning.callbacks.xla_stats_monitor import XLAStatsMonitor
2123
from pytorch_lightning.loggers import LoggerCollection, TestTubeLogger
2224
from tests.deprecated_api import _soft_unimport_module
2325
from tests.helpers import BoringModel
@@ -366,3 +368,15 @@ def test_v1_7_0_weights_summary_trainer(tmpdir):
366368

367369
with pytest.deprecated_call(match=r"Setting `Trainer.weights_summary` is deprecated in v1.5"):
368370
t.weights_summary = "blah"
371+
372+
373+
@RunIf(min_gpus=1)
374+
def test_v1_7_0_deprecate_gpu_stats_monitor(tmpdir):
375+
with pytest.deprecated_call(match="The `GPUStatsMonitor` callback was deprecated in v1.5"):
376+
_ = GPUStatsMonitor()
377+
378+
379+
@RunIf(tpu=True)
380+
def test_v1_7_0_deprecate_xla_stats_monitor(tmpdir):
381+
with pytest.deprecated_call(match="The `XLAStatsMonitor` callback was deprecated in v1.5"):
382+
_ = XLAStatsMonitor()

0 commit comments

Comments
 (0)