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.

    Multiple device IDs are separated by commas (,). Other characters or invalid device IDs are not allowed. If other characters or invalid device IDs are contained, only the device IDs before them are read. For example, if there is a space before 2 in the environment variable setting command export ASCEND_RT_VISIBLE_DEVICES=1, 2,3, only the device ID before the space (1) is read; if 8 is an invalid device ID in the environment variable setting command export ASCEND_RT_VISIBLE_DEVICES=1,3,8, only device IDs before 8 (1 and 3) are read.

  • This environment variable is for trial use and may be changed in later versions. Therefore, it cannot be used in commercial products.
  • Only specified device IDs can be configured in ascending order.
  • This environment variable cannot be used when the DCMI APIs are used. For details about the DCMI APIs, see DCMI API Reference.
  • This environment variable cannot be used when the HCCN Tool APIs are used. For details about the HCCN Tool APIs, see HCCN Tool API Reference.
  • This environment variable cannot be used when the profiling function is used.

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.

Applicability

Atlas A3 training products/Atlas A3 inference products

Atlas A2 training products/Atlas A2 inference products

Atlas 200I/500 A2 inference products

Atlas inference products

Atlas training products