Skip to content

Commit fd35ab1

Browse files
committed
modify front-end usage for pluggable device according to the review meeting
1 parent 0b3feb3 commit fd35ab1

File tree

1 file changed

+10
-25
lines changed

1 file changed

+10
-25
lines changed

rfcs/20200624-pluggable-device-for-tensorflow.md

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -73,44 +73,29 @@ This section describes the user scenarios that are supported/unsupported for Plu
7373
<img src=20200624-pluggable-device-for-tensorflow/scenario4.png>
7474
</div>
7575

76-
### Device mapping mechanism
77-
This section describes the device mapping mechanism for python users, pointing at previous user scenarios.
78-
* **Device type && Subdevice type**
79-
Device type is user visible. User can specify the device type for the ops. e.g, "gpu", "xpu", "cpu". Subdevice type is user visible and user can specify which subdevice to use for the device type(device mapping), e.g.("NVIDIA_GPU", "INTEL_GPU", "AMD_GPU").
76+
### Front-end device string
77+
This section describes the device string for python users, pointing at previous user scenarios.
78+
* **Device type**
79+
Device type is user visible. User can specify the device type for the ops. e.g, "gpu", "xpu", "cpu".
8080
```
8181
>> with tf.device("/gpu:0"):
8282
...
8383
>> with tf.device("/xpu:0"):
8484
...
8585
```
86-
* **Device mapping**
87-
In the case of two GPUs in the same system, e.g. NVIDIA GPU + X GPU and installing the X GPU plugin.
88-
* **Option 1**: override CUDA device, only plugged gpu device visible
89-
Only plugged gpu device is visible, PluggableDevice(X GPU) overrides the default GPUDevice(CUDA GPU). If users want to use CUDA GPU, they need to manually uninstall the plugin.
86+
* **Subdevice type**
87+
Subdevice type is user visible, aims at differentiating gpu devices between different hardware vendors. Users can query the subdevice type if they want to know whether the GPU device is "NVIDIA_GPU", "INTEL_GPU" or "AMD_GPU", by invoking [list_physical_devices](https://www.tensorflow.org/api_docs/python/tf/config/list_physical_devices).
88+
89+
This RFC proposes that plugged gpu device will override the default gpu device. When users invoke `list_physical_devices("GPU")`, they can only see the plugged gpu device. If users want to use default GPU device(CUDA), they need to manually uninstall the plugin.
90+
91+
For example, in the case of two GPUs in the same system, e.g. NVIDIA GPU + X GPU and installing the X GPU plugin, only X GPU is visible and usable. If users want to use Nvidia GPU, they need to uninstall the X GPU plugin.
9092
```
9193
>> gpu_device = tf.config.experimental.list_physical_devices(`GPU`)
9294
>> print(gpu_device)
9395
[PhysicalDevice(name = `physical_device:GPU:0`), device_type = `GPU`, subdevice_type = `X_GPU`]
9496
>> with tf.device("/gpu:0"):
9597
>> .. // place ops on PluggableDevice(X GPU)
9698
```
97-
* **Option 2**: both visible, but plugged gpu is default, user can set the device mapping
98-
Both plugged gpu device and default gpu device are visible, but only one gpu can work at the same time, plugged gpu device is default enabled(with higher priority), if users want to use NVIDIA GPU, they need to call device mapping API(set_sub_device_mapping()) to switch to CUDA device.
99-
```
100-
>> gpu_device = tf.config.experimental.list_physical_devices(`GPU`)
101-
>> print(gpu_device)
102-
[PhysicalDevice(name = `physical_device:GPU:0`), device_type = `GPU`, subdevice_type = `X_GPU`, enabled]
103-
[PhysicalDevice(name = `physical_device:GPU:0`), device_type = `GPU`, subdevice_type = `NVIDIA_GPU`, disabled]
104-
105-
>> tf.config.set_subdevice_mapping("NVIDIA_GPU")
106-
>> gpu_device = tf.config.experimental.list_physical_devices(`GPU`)
107-
>> print(gpu_device)
108-
[PhysicalDevice(name = `physical_device:GPU:0`), device_type = `GPU`, subdevice_type = `X_GPU`, disabled]
109-
[PhysicalDevice(name = `physical_device:GPU:0`), device_type = `GPU`, subdevice_type = `NVIDIA_GPU`, enabled]
110-
111-
>> with tf.device("/gpu:0"):
112-
>> .. // place ops on GPUDevice(NVIDIA GPU)
113-
```
11499
* **Physical device name**
115100
physical device name is user visible. User can query the physical device name(e.g. "Titan V") for the specified device instance through [tf.config.experimental.get_device_details()](https://www.tensorflow.org/api_docs/python/tf/config/experimental/get_device_details).
116101
```

0 commit comments

Comments
 (0)