imate.device.get_num_gpu_devices#

imate.device.get_num_gpu_devices()#

Returns the number of available GPU devices in multi-GPU platforms.

Returns:
num_gpuint

Number of GPU devices.

Notes

The returned value is not the total number of GPU devices on the machine. Rather, the number of available GPU devices that is allocated to the user is returned.

This function parses the output of nvidia-smi command by

nvidia-smi --list-gpus | wc -l

The nvidia-smi command is part of NVIDIA graphic driver. See Install NVIDIA Graphic Driver for further details. If a graphic driver is not installed, this function returns 0.

Examples

>>> from imate.device import get_num_gpu_devices
>>> get_num_gpu_devices()
4