Avoid instantiating every accelerator in the registry (#14591)

* Avoid instantiating every accelerator in the registry when listing available ones
This commit is contained in:
Adrian Wälchli 2022-09-09 21:08:34 +02:00 committed by GitHub
parent 3a66798a6c
commit 2b50cbb4d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -524,7 +524,9 @@ class AcceleratorConnector:
if not self.accelerator.is_available():
available_accelerator = [
acc_str for acc_str in self._accelerator_types if AcceleratorRegistry.get(acc_str).is_available()
acc_str
for acc_str in self._accelerator_types
if AcceleratorRegistry[acc_str]["accelerator"].is_available()
]
raise MisconfigurationException(
f"{self.accelerator.__class__.__qualname__} can not run on your system"