is_available
- paddle.device. is_available ( ) bool [source]
-
Check whether any supported device is available in the current environment.
This function checks whether Paddle is built with support for at least one type of accelerator (e.g., CUDA, XPU, CustomDevice) and whether there is at least one device of that type available.
If any supported device is available, this function returns True. Otherwise, it returns False.
- Returns
-
True if there is at least one available device (GPU/XPU/CustomDevice), False otherwise.
- Return type
-
bool
Examples
>>> import paddle >>> if paddle.device.is_available(): ... print("At least one device is available") ... else: ... print("No supported devices available")
