Function: get_logic_dev_id_by_user_dev_id
Applicable Products
Product |
Supported (√/x) |
|---|---|
√ |
|
√ |
|
√ |
|
√ |
|
√ |
|
√ |
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
1logic_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.

For details about the ASCEND_RT_VISIBLE_DEVICES environment, see Environment Variables.