apply fixes
This commit is contained in:
parent
4f221638d3
commit
c542968f63
|
@ -11,7 +11,7 @@
|
|||
# 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 List, Union
|
||||
from typing import Union
|
||||
|
||||
import torch
|
||||
from typing_extensions import override
|
||||
|
@ -45,7 +45,7 @@ class CPUAccelerator(Accelerator):
|
|||
|
||||
@staticmethod
|
||||
@override
|
||||
def get_parallel_devices(devices: Union[int, str]) -> List[torch.device]:
|
||||
def get_parallel_devices(devices: Union[int, str]) -> list[torch.device]:
|
||||
"""Gets parallel devices for the Accelerator."""
|
||||
devices = _parse_cpu_cores(devices)
|
||||
return [torch.device("cpu")] * devices
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
# 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, Dict, List, Union
|
||||
from typing import Any, Union
|
||||
|
||||
import torch
|
||||
from lightning_utilities.core.imports import RequirementCache
|
||||
|
@ -38,7 +38,7 @@ class CPUAccelerator(Accelerator):
|
|||
raise MisconfigurationException(f"Device should be CPU, got {device} instead.")
|
||||
|
||||
@override
|
||||
def get_device_stats(self, device: _DEVICE) -> Dict[str, Any]:
|
||||
def get_device_stats(self, device: _DEVICE) -> dict[str, Any]:
|
||||
"""Get CPU stats from ``psutil`` package."""
|
||||
return get_cpu_stats()
|
||||
|
||||
|
@ -54,7 +54,7 @@ class CPUAccelerator(Accelerator):
|
|||
|
||||
@staticmethod
|
||||
@override
|
||||
def get_parallel_devices(devices: Union[int, str]) -> List[torch.device]:
|
||||
def get_parallel_devices(devices: Union[int, str]) -> list[torch.device]:
|
||||
"""Gets parallel devices for the Accelerator."""
|
||||
devices = _parse_cpu_cores(devices)
|
||||
return [torch.device("cpu")] * devices
|
||||
|
@ -89,7 +89,7 @@ _CPU_SWAP_PERCENT = "cpu_swap_percent"
|
|||
_PSUTIL_AVAILABLE = RequirementCache("psutil")
|
||||
|
||||
|
||||
def get_cpu_stats() -> Dict[str, float]:
|
||||
def get_cpu_stats() -> dict[str, float]:
|
||||
if not _PSUTIL_AVAILABLE:
|
||||
raise ModuleNotFoundError(
|
||||
f"Fetching CPU device stats requires `psutil` to be installed. {str(_PSUTIL_AVAILABLE)}"
|
||||
|
|
Loading…
Reference in New Issue