Function: reset_device

Applicable Products

  • Ascend 950PR&950DT products: Supported
  • Atlas A3 products: Supported
  • Atlas A2 products: Supported
  • Atlas 200I/500 A2 inference products: Supported
  • Atlas inference products: Supported
  • Atlas training products: Supported

Function

Resets the current compute device and releases the resources on the device. The resources to be released include the default context, default stream, and all streams created in the default context. If tasks in the default context or default stream have not yet completed, the system will wait for the tasks to finish before releasing the resources.

Prototype

  • C Prototype

    aclError aclrtResetDevice(int32_t deviceId)
    
  • Python Function

    ret = acl.rt.reset_device(device_id)
    

Parameters

Parameter Description
device_id Int, device ID.

Return Values

Return Value Description
ret Int, error code. If 0 is returned, the operation is successful. If other values are returned, the operation fails.

Constraints

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

API call sequence: Call acl.rt.destroy_event to destroy the event, 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 process and example, see "Runtime Resource Allocation and Deallocation" and "Synchronous Wait" in "Application Development (Python)".