Skip to content
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

Remove the deprecated GPUAccelerator #16050

Merged
merged 3 commits into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions src/pytorch_lightning/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions src/pytorch_lightning/_graveyard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions src/pytorch_lightning/_graveyard/accelerator.py
Original file line number Diff line number Diff line change
@@ -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()
1 change: 0 additions & 1 deletion src/pytorch_lightning/accelerators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 0 additions & 31 deletions src/pytorch_lightning/accelerators/gpu.py

This file was deleted.

11 changes: 0 additions & 11 deletions tests/tests_pytorch/deprecated_api/test_remove_1-9.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
13 changes: 13 additions & 0 deletions tests/tests_pytorch/graveyard/test_accelerator.py
Original file line number Diff line number Diff line change
@@ -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()