- TensorFlow Machine Learning Projects
- Ankit Jain Armando Fandango Amita Kapoor
- 294字
- 2021-06-10 19:15:29
Executing graphs across compute devices – CPU and GPGPU
A graph can be partitioned into several parts, and each part can be placed and executed on different devices, such as a CPU or GPU. All of the devices that are available for graph execution can be listed with the following command:
from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
The output is listed as follows (the output for your machine will be different because this will depend on the available compute devices in your specific system):
[name: "/device:CPU:0" device_type: "CPU" memory_limit: 268435456 locality { } incarnation: 12900903776306102093 , name: "/device:GPU:0" device_type: "GPU" memory_limit: 611319808 locality { bus_id: 1 } incarnation: 2202031001192109390 physical_device_desc: "device: 0, name: Quadro P5000, pci bus id: 0000:01:00.0, compute capability: 6.1" ]
The devices in TensorFlow are identified with the string /device:<device_type>:<device_idx>. In the last output, CPU and GPU denote the device type, and 0 denotes the device index.
One thing to note about the last output is that it shows only one CPU, whereas our computer has 8 CPUs. The reason for this is that TensorFlow implicitly distributes the code across the CPU units and thus, by default, CPU:0 denotes all of the CPUs available to TensorFlow. When TensorFlow starts executing graphs, it runs the independent paths within each graph in a separate thread, with each thread running on a separate CPU. We can restrict the number of threads used for this purpose by changing the number of inter_op_parallelism_threads. Similarly, if, within an independent path, an operation is capable of running on multiple threads, TensorFlow will launch that specific operation on multiple threads. The number of threads in this pool can be changed by setting the number of intra_op_parallelism_threads.
- 高效能辦公必修課:Word圖文處理
- 三菱FX3U/5U PLC從入門到精通
- 我的J2EE成功之路
- Getting Started with Clickteam Fusion
- 計算機(jī)應(yīng)用復(fù)習(xí)與練習(xí)
- Associations and Correlations
- 永磁同步電動機(jī)變頻調(diào)速系統(tǒng)及其控制(第2版)
- Blender Compositing and Post Processing
- 統(tǒng)計學(xué)習(xí)理論與方法:R語言版
- 信息物理系統(tǒng)(CPS)測試與評價技術(shù)
- 網(wǎng)絡(luò)布線與小型局域網(wǎng)搭建
- Excel 2007技巧大全
- 智能生產(chǎn)線的重構(gòu)方法
- Mastering Exploratory Analysis with pandas
- 經(jīng)典Java EE企業(yè)應(yīng)用實(shí)戰(zhàn)