torch.accelerator.is_available#
- torch.accelerator.is_available()[source]#
Check if the current accelerator is available at runtime: it was build, all therequired drivers are available and at least one device is visible.Seeaccelerator for details.
- Returns
A boolean indicating if there is an availableaccelerator.
- Return type
Note
This API delegates to the device-specific version ofis_available.On CUDA, when the environment variable
PYTORCH_NVML_BASED_CUDA_CHECK=1is set,this function will NOT poison fork. Otherwise, it will. For more details, seePoison fork in multiprocessing.Example:
>>>asserttorch.accelerator.is_available()"No available accelerators detected."