diff --git a/CHANGELOG.md b/CHANGELOG.md index 38d1c7c3f2833..26d4f5aa8070c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -98,6 +98,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Added a `_Stateful` support for `LightningDataModule` ([#11637](https://github.com/PyTorchLightning/pytorch-lightning/pull/11637)) +- Added checks to `IPUAccelerator` to assert device availability ([#11799](https://github.com/PyTorchLightning/pytorch-lightning/pull/11798)) + + ### Changed - Implemented a new native and rich format in `_print_results` method of the `EvaluationLoop` ([#11332](https://github.com/PyTorchLightning/pytorch-lightning/pull/11332)) diff --git a/pytorch_lightning/accelerators/ipu.py b/pytorch_lightning/accelerators/ipu.py index 155dce5275a9b..5b8573e884500 100644 --- a/pytorch_lightning/accelerators/ipu.py +++ b/pytorch_lightning/accelerators/ipu.py @@ -16,11 +16,25 @@ import torch from pytorch_lightning.accelerators.accelerator import Accelerator +from pytorch_lightning.utilities.exceptions import MisconfigurationException +from pytorch_lightning.utilities.imports import _IPU_AVAILABLE class IPUAccelerator(Accelerator): """Accelerator for IPUs.""" + def __init__(self) -> None: + """ + Raises: + MisconfigurationException: + If the IPU device is not available. + """ + if not _IPU_AVAILABLE: + raise MisconfigurationException( + "The IPU Accelerator requires IPU devices to run. " + "Learn more or get started with IPUs at https://www.graphcore.ai/getstarted" + ) + def get_device_stats(self, device: Union[str, torch.device]) -> Dict[str, Any]: """IPU device stats aren't supported yet.""" return {}