Remove the deprecated code in `pl.utilities.device_parser` (#16412)
This commit is contained in:
parent
003937246a
commit
172be3653f
|
@ -68,6 +68,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
|
|||
|
||||
- Removed the deprecated code in `pl.utilities.xla_device` ([#16404](https://github.com/Lightning-AI/lightning/pull/16404))
|
||||
|
||||
- Removed the deprecated code in `pl.utilities.device_parser` ([#16412](https://github.com/Lightning-AI/lightning/pull/16412))
|
||||
|
||||
- Mark the `forward_module` argument as required ([#16386](https://github.com/Lightning-AI/lightning/pull/16386))
|
||||
* Removed the deprecated `pl_module` argument from the distributed module wrappers
|
||||
* Removed the deprecated `pytorch_lightning.overrides.base.unwrap_lightning_module` function
|
||||
|
|
|
@ -1,79 +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 typing import Any
|
||||
|
||||
from lightning_fabric.accelerators.cpu import _parse_cpu_cores as new_parse_cpu_cores
|
||||
from lightning_fabric.accelerators.cuda import is_cuda_available as new_is_cuda_available
|
||||
from lightning_fabric.accelerators.cuda import num_cuda_devices as new_num_cuda_devices
|
||||
from lightning_fabric.accelerators.tpu import _parse_tpu_devices as new_parse_tpu_cores
|
||||
from lightning_fabric.utilities.device_parser import _determine_root_gpu_device as new_determine_root_gpu_device
|
||||
from lightning_fabric.utilities.device_parser import _parse_gpu_ids as new_parse_gpu_ids
|
||||
from pytorch_lightning.accelerators.hpu import _parse_hpus as new_parse_hpus
|
||||
from pytorch_lightning.utilities.rank_zero import rank_zero_deprecation
|
||||
|
||||
|
||||
def parse_hpus(*args: Any, **kwargs: Any) -> Any:
|
||||
rank_zero_deprecation(
|
||||
"`pytorch_lightning.utilities.device_parser.parse_hpus` has been deprecated in v1.8.0 and will"
|
||||
" be removed in v2.0.0. This function is internal but you can copy over its implementation."
|
||||
)
|
||||
return new_parse_hpus(*args, **kwargs)
|
||||
|
||||
|
||||
def determine_root_gpu_device(*args: Any, **kwargs: Any) -> Any:
|
||||
rank_zero_deprecation(
|
||||
"`pytorch_lightning.utilities.device_parser.determine_root_gpu_device` has been deprecated in v1.8.0 and will"
|
||||
" be removed in v2.0.0. This function is internal but you can copy over its implementation."
|
||||
)
|
||||
return new_determine_root_gpu_device(*args, **kwargs)
|
||||
|
||||
|
||||
def is_cuda_available() -> bool:
|
||||
rank_zero_deprecation(
|
||||
"`pytorch_lightning.utilities.device_parser.is_cuda_available` has been deprecated in v1.8.0 and will"
|
||||
" be removed in v2.0.0. Please use `lightning_fabric.accelerators.cuda.is_cuda_available` instead."
|
||||
)
|
||||
return new_is_cuda_available()
|
||||
|
||||
|
||||
def num_cuda_devices() -> int:
|
||||
rank_zero_deprecation(
|
||||
"`pytorch_lightning.utilities.device_parser.num_cuda_devices` has been deprecated in v1.8.0 and will"
|
||||
" be removed in v2.0.0. Please use `lightning_fabric.accelerators.cuda.num_cuda_devices` instead."
|
||||
)
|
||||
return new_num_cuda_devices()
|
||||
|
||||
|
||||
def parse_cpu_cores(*args: Any, **kwargs: Any) -> Any:
|
||||
rank_zero_deprecation(
|
||||
"`pytorch_lightning.utilities.device_parser.parse_cpu_cores` has been deprecated in v1.8.0 and will"
|
||||
" be removed in v2.0.0. This function is internal but you can copy over its implementation."
|
||||
)
|
||||
return new_parse_cpu_cores(*args, **kwargs)
|
||||
|
||||
|
||||
def parse_gpu_ids(*args: Any, **kwargs: Any) -> Any:
|
||||
rank_zero_deprecation(
|
||||
"`pytorch_lightning.utilities.device_parser.parse_gpu_ids` has been deprecated in v1.8.0 and will"
|
||||
" be removed in v2.0.0. This function is internal but you can copy over its implementation."
|
||||
)
|
||||
return new_parse_gpu_ids(*args, **kwargs)
|
||||
|
||||
|
||||
def parse_tpu_cores(*args: Any, **kwargs: Any) -> Any:
|
||||
rank_zero_deprecation(
|
||||
"`pytorch_lightning.utilities.device_parser.parse_tpu_cores` has been deprecated in v1.8.0 and will"
|
||||
" be removed in v2.0.0. This function is internal but you can copy over its implementation."
|
||||
)
|
||||
return new_parse_tpu_cores(*args, **kwargs)
|
|
@ -33,15 +33,6 @@ from pytorch_lightning.utilities.apply_func import (
|
|||
)
|
||||
from pytorch_lightning.utilities.cloud_io import atomic_save, get_filesystem, load
|
||||
from pytorch_lightning.utilities.data import has_iterable_dataset, has_len
|
||||
from pytorch_lightning.utilities.device_parser import (
|
||||
determine_root_gpu_device,
|
||||
is_cuda_available,
|
||||
num_cuda_devices,
|
||||
parse_cpu_cores,
|
||||
parse_gpu_ids,
|
||||
parse_hpus,
|
||||
parse_tpu_cores,
|
||||
)
|
||||
from pytorch_lightning.utilities.optimizer import optimizer_to_device, optimizers_to_device
|
||||
from pytorch_lightning.utilities.seed import pl_worker_init_function, reset_seed, seed_everything
|
||||
|
||||
|
@ -104,29 +95,6 @@ def test_v1_10_deprecated_data_utilities():
|
|||
has_len(DataLoader(RandomDataset(2, 4)))
|
||||
|
||||
|
||||
def test_v1_10_deprecated_device_parser_utilities():
|
||||
with pytest.deprecated_call(match="device_parser.determine_root_gpu_device` has been deprecated in v1.8.0"):
|
||||
determine_root_gpu_device(None)
|
||||
|
||||
with pytest.deprecated_call(match="device_parser.is_cuda_available` has been deprecated in v1.8.0"):
|
||||
is_cuda_available()
|
||||
|
||||
with pytest.deprecated_call(match="device_parser.num_cuda_devices` has been deprecated in v1.8.0"):
|
||||
num_cuda_devices()
|
||||
|
||||
with pytest.deprecated_call(match="device_parser.parse_hpus` has been deprecated in v1.8.0"):
|
||||
parse_hpus(1)
|
||||
|
||||
with pytest.deprecated_call(match="device_parser.parse_cpu_cores` has been deprecated in v1.8.0"):
|
||||
parse_cpu_cores(1)
|
||||
|
||||
with pytest.deprecated_call(match="device_parser.parse_gpu_ids` has been deprecated in v1.8.0"):
|
||||
parse_gpu_ids(None)
|
||||
|
||||
with pytest.deprecated_call(match="device_parser.parse_tpu_cores` has been deprecated in v1.8.0"):
|
||||
parse_tpu_cores(None)
|
||||
|
||||
|
||||
def test_v1_10_deprecated_optimizer_utilities():
|
||||
with pytest.deprecated_call(match="optimizer.optimizers_to_device` has been deprecated in v1.8.0"):
|
||||
optimizers_to_device([torch.optim.Adam(torch.nn.Linear(1, 1).parameters())], "cpu")
|
||||
|
|
Loading…
Reference in New Issue