dpctl.SyclDevice.get_device_id

SyclDevice.get_device_id()

For an unpartitioned device, returns the canonical index of this device in the list of devices visible to dpctl.

Returns:

The index of the device.

Return type:

int

Raises:

ValueError – If the device could not be found.

Example:
import dpctl
gpu_dev = dpctl.SyclDevice("gpu")
i = gpu_dev.get_device_id
devs = dpctl.get_devices()
assert devs[i] == gpu_dev