aclrtGetLogicDevIdByUserDevId

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

Atlas inference product

Atlas training product

Description

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

Prototype

1
aclError aclrtGetLogicDevIdByUserDevId(const int32_t userDevid, int32_t *const logicDevId)

Parameters

Parameter

Input/Output

Description

userDevid

Input

User device ID.

logicDevId

Output

Logical device ID.

Returns

0 on success; otherwise, failure. For details, see aclError.

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 following figure, 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 aclrtSetDevice 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.

For details about ASCEND_RT_VISIBLE_DEVICES, see Environment Variables.