Function: get_logic_dev_id_by_user_dev_id

Applicable Products

Product

Supported (√/x)

Ascend 950PR/Ascend 950DT

√

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

√

Description

Obtains the logical device ID based on the user device ID.

Prototype

  • C Prototype
    aclError aclrtGetLogicDevIdByUserDevId(const int32_t userDevid, int32_t *const logicDevId)
  • Python Function
    1
    logic_dev_id, ret = acl.rt.get_logic_dev_id_by_user_dev_id(user_dev_id)
    

Parameters

Parameter

Description

user_dev_id

Int, user device ID.

Return Values

Return Value

Description

logic_dev_id

Int, logical device ID.

ret

Int, 0 on success; else failure.

Relationships Between the User Device ID, Logical Device ID, and Physical Device ID

If the ASCEND_RT_VISIBLE_DEVICES environment variable is not set, the logical device ID is the same as the user device ID. In a non-container scenario, the physical device ID is the same as the logical device ID.

In the figure below, the ASCEND_RT_VISIBLE_DEVICES environment variable is set in the container scenario. The relationships between the three IDs are as follows: The device IDs set through the ASCEND_RT_VISIBLE_DEVICES environment variable are 1 and 2, and the corresponding device indexes are 0 and 1. The user device ID set through acl.rt.set_device is 0, and the corresponding device index is 0. Therefore, the user device ID 0 corresponds to the logical device ID 1, and the logical device ID 1 in the container is mapped to the physical device ID 6. Finally, the physical device with ID 6 is used for computation.

Figure 1

For details about the ASCEND_RT_VISIBLE_DEVICES environment, see Environment Variables.