sciai.context.set_context_auto

View Source On Gitee
sciai.context.set_context_auto(mode=ms.GRAPH_MODE, device_id=None)[source]

Automatically set context as given mode, recognize platform. If device_id is None, no card would be set.

Parameters
  • mode (int) – Mindspore running mode, which can be ms.PYNATIVE_MODE or ms.GRAPH_MODE. Default: ms.GRAPH_MODE.

  • device_id (Union(int, None)) – Set device_id if given. Default: None.

Raises

ValueError – If device_id is illegal.

Supported Platforms:

GPU CPU Ascend

Examples

>>> import mindspore as ms
>>> from sciai.context import set_context_auto
>>> set_context_auto(mode=ms.GRAPH_MODE, device_id=2)