Rate this Page

torch.accelerator.is_available#

torch.accelerator.is_available()[source]#

Check if the current accelerator is available at runtime: it was build, all the required drivers are available and at least one device is visible. See accelerator for details.

Returns

A boolean indicating if there is an available accelerator.

Return type

bool

Note

This API delegates to the device-specific version of is_available. On CUDA, when the environment variable PYTORCH_NVML_BASED_CUDA_CHECK=1 is set, this function will NOT poison fork. Otherwise, it will. For more details, see Poison fork in multiprocessing.

Example:

>>> assert torch.accelerator.is_available() "No available accelerators detected."