mindspore.set_device

View Source On Gitee
mindspore.set_device(device_target, device_id=0)[source]

Set device target and device id for running environment.

Note

  • The device_target must be set in the ["CPU", "GPU", "Ascend"], there is no default value.

Parameters
  • device_target (str) – The target device to run, only support "Ascend", "GPU", and "CPU".

  • device_id (int) – ID of the target device, the value must be in [0, device_num_per_host-1], Default: 0 . "device_num_per_host" refers to the total number of devices on the host.

Examples

>>> import mindspore as ms
>>> ms.set_device("Ascend", 1)