Function: reset_device

Applicability

Product

Supported (√/x)

Atlas A3 training products / Atlas A3 inference products

Atlas A2 training products / Atlas A2 inference products

Atlas training products

Atlas inference products

Atlas 200I/500 A2 inference products

Function Usage

Resets the current device and releases the resources on the device. The resources it releases include the default context, default stream, and all streams created in the default context. If a task in the default context or stream is not complete, the system releases the context or stream after the task is complete.

Prototype

  • C Prototype
    1
    aclError aclrtResetDevice(int32_t deviceId)
    
  • Python Function
    1
    ret = acl.rt.reset_device(device_id)
    

Parameter Description

Parameter

Description

device_id

Int, device ID.

Return Value Description

Return Value

Description

ret

Int, error code: 0 on success; else, failure.

Restrictions

If there are explicitly created contexts, streams, or events on the device to be reset, you are advised to follow the following call sequence before resetting. Otherwise, exceptions may occur.

The API call sequence is as follows: call acl.rt.destroy_event to destroy the event or call acl.rt.destroy_stream to destroy the explicitly created stream --> call acl.rt.destroy_context to destroy the explicitly created context --> call acl.rt.reset_device.

Reference

For details about the API call sequence and example, see Runtime Resource Allocation and Deallocation and Synchronous Wait.