ASCEND_RT_VISIBLE_DEVICES
Description
Specifies the devices that are visible to the current process. One or more device IDs can be specified at a time. By using this environment variable, you can adjust the devices without modifying the application.
Device ID indicates the logical ID of the Ascend AI Processor. For example, if the number of available devices is 8, the device IDs are 0, 1, 2, 3, 4, 5, 6, and 7. The application scenarios are as follows:
- Setting export ASCEND_RT_VISIBLE_DEVICES to 1: The current process can use only the device whose device ID is 1. The number of available devices is 1, and its index value is 0. Subsequently, when specifying which device to use for computations, you should use this index value (0 in this case) to refer to the device.
- Setting export ASCEND_RT_VISIBLE_DEVICES to 1,2,3: The current process can use only the devices whose device ID is 1, 2, or 3. The number of available devices is 3, and their index values are 0, 1, and 2, respectively. Subsequently, when specifying which device to use for computations, you should use these index values (0, 1, and 2 in this case) to refer to the corresponding device.
Use commas (,) to separate multiple device IDs. The value cannot contain other characters. If any, only the device IDs before the other characters are read. For example, if there is a space before 2 in the command export ASCEND_RT_VISIBLE_DEVICES=1, 2,3, only the device ID before the space is read, that is, 1.
- This environment variable is for trial use and may be changed in later versions. Therefore, it cannot be used in commercial products.
- In the current version, only specified device IDs can be configured in ascending order.
Use cases:
Execute the offline inference program.
The TensorFlow/PyTorch framework network performs training or online inference on the Ascend platform.
Example
- Specify a device ID:
export ASCEND_RT_VISIBLE_DEVICES=1
- Specify multiple device IDs:
export ASCEND_RT_VISIBLE_DEVICES=1,2,3
Restrictions
In the scenario where the TensorFlow framework network performs training or online inference on the Ascend platform, the priority of the ASCEND_RT_VISIBLE_DEVICES environment variable is higher than that of ASCEND_DEVICE_ID. If ASCEND_DEVICE_ID and ASCEND_RT_VISIBLE_DEVICES are used together, ASCEND_DEVICE_ID can be set only to the device index value in ASCEND_RT_VISIBLE_DEVICES. Otherwise, the training or inference application runs abnormally.