mindspore.hal.device_count
- mindspore.hal.device_count(device_target=None)[source]
- Return device count of specified device, this api will be deprecated and removed in future versions, please use the api - mindspore.device_context.cpu.device_count(),- mindspore.device_context.gpu.device_count(),- mindspore.device_context.ascend.device_count()instead.- Note - For CPU device, this method always returns 1. - Parameters
- device_target (str, optional) – The target device specified, should be one of - "CPU",- "GPU"and- "Ascend". Default- None, represents the current device set by context.
- Returns
- int 
 - Examples - >>> import mindspore >>> device_target = mindspore.context.get_context("device_target") >>> print(mindspore.hal.device_count(device_target))