diff --git a/src/pytorch_lightning/CHANGELOG.md b/src/pytorch_lightning/CHANGELOG.md index 184be7cd56ded..09f0bf5442215 100644 --- a/src/pytorch_lightning/CHANGELOG.md +++ b/src/pytorch_lightning/CHANGELOG.md @@ -92,6 +92,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Removed the deprecated `LightningDeepSpeedModule` ([#16041](https://github.com/Lightning-AI/lightning/pull/16041)) +- Removed the deprecated `pytorch_lightning.accelerators.GPUAccelerator` in favor of `pytorch_lightning.accelerators.CUDAAccelerator` ([#16050](https://github.com/Lightning-AI/lightning/pull/16050)) + + + ### Fixed - Enhanced `reduce_boolean_decision` to accommodate `any`-analogous semantics expected by the `EarlyStopping` callback ([#15253](https://github.com/Lightning-AI/lightning/pull/15253)) diff --git a/src/pytorch_lightning/_graveyard/__init__.py b/src/pytorch_lightning/_graveyard/__init__.py index ae4154b5421b3..a4f1d5ca661cf 100644 --- a/src/pytorch_lightning/_graveyard/__init__.py +++ b/src/pytorch_lightning/_graveyard/__init__.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import pytorch_lightning._graveyard.accelerator import pytorch_lightning._graveyard.callbacks import pytorch_lightning._graveyard.core import pytorch_lightning._graveyard.legacy_import_unpickler diff --git a/src/pytorch_lightning/_graveyard/accelerator.py b/src/pytorch_lightning/_graveyard/accelerator.py new file mode 100644 index 0000000000000..3da6a4ac8ddb9 --- /dev/null +++ b/src/pytorch_lightning/_graveyard/accelerator.py @@ -0,0 +1,28 @@ +import sys +from typing import Any + +import pytorch_lightning as pl + + +def _patch_sys_modules() -> None: + # TODO: Remove in v2.0.0 + self = sys.modules[__name__] + sys.modules["pytorch_lightning.accelerators.gpu"] = self + + +class GPUAccelerator: + # TODO: Remove in v2.0.0 + def __init__(self, *_: Any, **__: Any) -> None: + raise NotImplementedError( + "`pytorch_lightning.accelerators.gpu.GPUAccelerator` was deprecated in v1.7.0 and is no" + " longer supported as of v1.9.0. Please use `pytorch_lightning.accelerators.CUDAAccelerator` instead" + ) + + +def _patch_classes() -> None: + # TODO: Remove in v2.0.0 + setattr(pl.accelerators, "GPUAccelerator", GPUAccelerator) + + +_patch_sys_modules() +_patch_classes() diff --git a/src/pytorch_lightning/accelerators/__init__.py b/src/pytorch_lightning/accelerators/__init__.py index c56b22705a23a..fb5fa4ede2a0d 100644 --- a/src/pytorch_lightning/accelerators/__init__.py +++ b/src/pytorch_lightning/accelerators/__init__.py @@ -14,7 +14,6 @@ from pytorch_lightning.accelerators.accelerator import Accelerator # noqa: F401 from pytorch_lightning.accelerators.cpu import CPUAccelerator # noqa: F401 from pytorch_lightning.accelerators.cuda import CUDAAccelerator # noqa: F401 -from pytorch_lightning.accelerators.gpu import GPUAccelerator # noqa: F401 from pytorch_lightning.accelerators.hpu import HPUAccelerator # noqa: F401 from pytorch_lightning.accelerators.ipu import IPUAccelerator # noqa: F401 from pytorch_lightning.accelerators.mps import MPSAccelerator # noqa: F401 diff --git a/src/pytorch_lightning/accelerators/gpu.py b/src/pytorch_lightning/accelerators/gpu.py deleted file mode 100644 index a7d054b946393..0000000000000 --- a/src/pytorch_lightning/accelerators/gpu.py +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright The PyTorch Lightning team. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -from pytorch_lightning.accelerators.cuda import CUDAAccelerator -from pytorch_lightning.utilities.rank_zero import rank_zero_deprecation - - -class GPUAccelerator(CUDAAccelerator): - """Accelerator for NVIDIA GPU devices. - - .. deprecated:: 1.9 - - Please use the ``CUDAAccelerator`` instead. - """ - - def __init__(self) -> None: - rank_zero_deprecation( - "The `GPUAccelerator` has been renamed to `CUDAAccelerator` and will be removed in v1.9." - " Please use the `CUDAAccelerator` instead!" - ) - super().__init__() diff --git a/tests/tests_pytorch/deprecated_api/test_remove_1-9.py b/tests/tests_pytorch/deprecated_api/test_remove_1-9.py index 54c59bec62b5d..90dd4372bf89e 100644 --- a/tests/tests_pytorch/deprecated_api/test_remove_1-9.py +++ b/tests/tests_pytorch/deprecated_api/test_remove_1-9.py @@ -20,7 +20,6 @@ import pytorch_lightning.loggers.base as logger_base import pytorch_lightning.utilities.cli as old_cli from pytorch_lightning import Trainer -from pytorch_lightning.accelerators.gpu import GPUAccelerator from pytorch_lightning.cli import LightningCLI, SaveConfigCallback from pytorch_lightning.core.module import LightningModule from pytorch_lightning.demos.boring_classes import BoringModel @@ -207,13 +206,3 @@ def test_pytorch_profiler_schedule_wrapper_deprecation_warning(): def test_pytorch_profiler_register_record_function_deprecation_warning(): with pytest.deprecated_call(match="RegisterRecordFunction` is deprecated in v1.7 and will be removed in in v1.9."): _ = RegisterRecordFunction(None) - - -def test_gpu_accelerator_deprecation_warning(): - with pytest.deprecated_call( - match=( - "The `GPUAccelerator` has been renamed to `CUDAAccelerator` and will be removed in v1.9." - + " Please use the `CUDAAccelerator` instead!" - ) - ): - GPUAccelerator() diff --git a/tests/tests_pytorch/graveyard/test_accelerator.py b/tests/tests_pytorch/graveyard/test_accelerator.py new file mode 100644 index 0000000000000..67b41e251621e --- /dev/null +++ b/tests/tests_pytorch/graveyard/test_accelerator.py @@ -0,0 +1,13 @@ +import pytest + + +def test_removed_gpuaccelerator(): + from pytorch_lightning.accelerators.gpu import GPUAccelerator + + with pytest.raises(NotImplementedError, match="GPUAccelerator`.*no longer supported as of v1.9"): + GPUAccelerator() + + from pytorch_lightning.accelerators import GPUAccelerator + + with pytest.raises(NotImplementedError, match="GPUAccelerator`.*no longer supported as of v1.9"): + GPUAccelerator()