Skip to content

Commit

Permalink
Add back GPUAccelerator and deprecate it
Browse files Browse the repository at this point in the history
  • Loading branch information
justusschock authored and rohitgr7 committed Jul 19, 2022
1 parent bd2dd35 commit 3247b1f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/pytorch_lightning/accelerators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
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: 31 additions & 0 deletions src/pytorch_lightning/accelerators/gpu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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__()
11 changes: 11 additions & 0 deletions tests/tests_pytorch/deprecated_api/test_remove_1-9.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import pytorch_lightning.loggers.base as logger_base
from pytorch_lightning import Trainer
from pytorch_lightning.accelerators.gpu import GPUAccelerator
from pytorch_lightning.core.module import LightningModule
from pytorch_lightning.demos.boring_classes import BoringModel
from pytorch_lightning.profiler.advanced import AdvancedProfiler
Expand Down Expand Up @@ -195,3 +196,13 @@ 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()

0 comments on commit 3247b1f

Please sign in to comment.