diff --git a/CHANGELOG.md b/CHANGELOG.md index 5232cc793163f..92d9e899fa0df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -147,7 +147,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Deprecated `DataModule` properties: `train_transforms`, `val_transforms`, `test_transforms`, `size`, `dims` ([#8851](https://github.com/PyTorchLightning/pytorch-lightning/pull/8851)) -- Deprecated `prepare_data_per_node` flag on Trainer and set it as a property of `DataHooks`, accessible in the `LightningModule` and `LightningDataModule` [#8958](https://github.com/PyTorchLightning/pytorch-lightning/pull/8958) +- Deprecated `prepare_data_per_node` flag on Trainer and set it as a property of `DataHooks`, accessible in the `LightningModule` and `LightningDataModule` ([#8958](https://github.com/PyTorchLightning/pytorch-lightning/pull/8958)) + + +- Deprecated `log_gpu_memory` flag on the Trainer in favor of passing the `GPUStatsMonitor` callback to the Trainer ([#9124](https://github.com/PyTorchLightning/pytorch-lightning/pull/9124/)) ### Removed diff --git a/pytorch_lightning/trainer/connectors/logger_connector/logger_connector.py b/pytorch_lightning/trainer/connectors/logger_connector/logger_connector.py index a965699510689..1392c07282942 100644 --- a/pytorch_lightning/trainer/connectors/logger_connector/logger_connector.py +++ b/pytorch_lightning/trainer/connectors/logger_connector/logger_connector.py @@ -24,11 +24,17 @@ from pytorch_lightning.utilities.apply_func import apply_to_collection, move_data_to_device from pytorch_lightning.utilities.metrics import metrics_to_scalars from pytorch_lightning.utilities.types import _EVALUATE_OUTPUT +from pytorch_lightning.utilities.warnings import rank_zero_deprecation class LoggerConnector: def __init__(self, trainer: "pl.Trainer", log_gpu_memory: Optional[str] = None) -> None: self.trainer = trainer + if log_gpu_memory is not None: + rank_zero_deprecation( + "Setting `log_gpu_memory` with the trainer flag is deprecated and will be removed in v1.7.0! " + "Please monitor GPU stats with the `GPUStatsMonitor` callback directly instead." + ) self.log_gpu_memory = log_gpu_memory self.eval_loop_results = [] self._val_log_step: int = 0 diff --git a/pytorch_lightning/trainer/trainer.py b/pytorch_lightning/trainer/trainer.py index 7ebbc55ae7ac9..c1a3f0bcd0a32 100644 --- a/pytorch_lightning/trainer/trainer.py +++ b/pytorch_lightning/trainer/trainer.py @@ -236,6 +236,10 @@ def __init__( log_gpu_memory: None, 'min_max', 'all'. Might slow performance + .. deprecated:: v1.5 + Deprecated in v1.5.0 and will be removed in v1.7.0 + Please use the ``GPUStatsMonitor`` callback directly instead. + log_every_n_steps: How often to log within steps (defaults to every 50 steps). prepare_data_per_node: If True, each LOCAL_RANK=0 will call prepare data. diff --git a/tests/deprecated_api/test_remove_1-7.py b/tests/deprecated_api/test_remove_1-7.py index 7581bf2b0c142..5fd26602f4b25 100644 --- a/tests/deprecated_api/test_remove_1-7.py +++ b/tests/deprecated_api/test_remove_1-7.py @@ -87,3 +87,10 @@ def test_v1_7_0_trainer_prepare_data_per_node(tmpdir): match="Setting `prepare_data_per_node` with the trainer flag is deprecated and will be removed in v1.7.0!" ): _ = Trainer(prepare_data_per_node=False) + + +def test_v1_7_0_trainer_log_gpu_memory(tmpdir): + with pytest.deprecated_call( + match="Setting `log_gpu_memory` with the trainer flag is deprecated and will be removed in v1.7.0!" + ): + _ = Trainer(log_gpu_memory="min_max")