mindspore.hal.device_count
- mindspore.hal.device_count(device_target=None)[source]
Returns device count of specified backend.
Note
The api will be deprecated.
CPU hardware, please use the interface
mindspore.device_context.cpu.device_count()
.GPU hardware, please use the interface
mindspore.device_context.gpu.device_count()
.Ascend hardware, please use the interface
mindspore.device_context.ascend.device_count()
.
Note
If device_target is not specified, get the device count of the current backend set by context. For CPU backend, this method always returns 1.
- Parameters
device_target (str, optional) – The device name of backend, should be one of "CPU", "GPU" and "Ascend".
- Returns
int.
Examples
>>> import mindspore as ms >>> device_target = ms.context.get_context("device_target") >>> print(ms.hal.device_count(device_target))