mindspore.hal.get_device_properties

View Source On Gitee
mindspore.hal.get_device_properties(device_id, device_target=None)[source]

Get specified device's properties.

Note

  • The api will be deprecated.

Note

If device_target is not specified, get the device properties of the current backend set by context. For Ascend, backend must be initialized before calling this method, or total_memory and free_memory will be 0, and device_id will be ignored since this method only returns current device's properties.

Parameters
  • device_id (int) – The device id of which the properties will be returned.

  • device_target (str, optional) – The device name of backend, should be one of "CPU", "GPU" and "Ascend".

Returns

  • cudaDeviceProp for GPU.

    cudaDeviceProp {
        name(str),
        major(int),
        minor(int),
        is_multi_gpu_board(int),
        is_integrated(int),
        multi_processor_count(int),
        total_memory(int),
        warp_size(int)
    }
    
  • AscendDeviceProperties for Ascend.

    AscendDeviceProperties {
        name(str),
        total_memory(int),
        free_memory(int)
    }
    
  • None for CPU.

Examples

>>> import mindspore as ms
>>> device_target = ms.context.get_context("device_target")
>>> print(ms.hal.get_device_properties(0, device_target))