mindspore_lite.GPUDeviceInfo
- class mindspore_lite.GPUDeviceInfo(device_id=0, enable_fp16=False)[source]
Helper class to set gpu device info, and it inherits DeviceInfo base class.
- Parameters
- Raises
TypeError – device_id is not an int.
TypeError – enable_fp16 is not a bool.
ValueError – device_id is less than 0.
Examples
>>> import mindspore_lite as mslite >>> gpu_device_info = mslite.GPUDeviceInfo(device_id=1, enable_fp16=False) >>> print(gpu_device_info) device_type: DeviceType.kGPU, device_id: 1, enable_fp16: False. >>> cpu_device_info = mslite.CPUDeviceInfo(enable_fp16=False) >>> context = mslite.Context() >>> context.append_device_info(gpu_device_info) >>> context.append_device_info(cpu_device_info) >>> print(context) thread_num: 0, inter_op_parallel_num: 0, thread_affinity_mode: 0, thread_affinity_core_list: [], enable_parallel: False, device_list: 1, 0, .
- get_group_size()[source]
Get the number of the clusters from context.
- Returns
int, the number of the clusters.
Examples
>>> import mindspore_lite as mslite >>> device_info = mslite.GPUDeviceInfo(device_id=1, enable_fp16=True) >>> group_size = device_info.get_group_size() >>> print(group_size) 1
- get_rank_id()[source]
Get the ID of the current device in the cluster from context.
- Returns
int, the ID of the current device in the cluster, which starts from 0.
Examples
>>> import mindspore_lite as mslite >>> device_info = mslite.GPUDeviceInfo(device_id=1, enable_fp16=True) >>> rank_id = device_info.get_rank_id() >>> print(rank_id) 0