我在集群上使用Tensorflow,我想告诉Tensorflow仅在一个内核上运行(即使有更多可用的内核)。
有人知道这是否可能吗?
要在一个CPU线程上运行Tensorflow,我使用:
session_conf = tf.ConfigProto(
intra_op_parallelism_threads=1,
inter_op_parallelism_threads=1)
sess = tf.Session(config=session_conf)
device_count
限制使用的CPU数量,而不是内核或线程的数量。
tensorflow/tensorflow/core/protobuf/config.proto
说:
message ConfigProto {
// Map from device type name (e.g., "CPU" or "GPU" ) to maximum
// number of devices of that type to use. If a particular device
// type is not found in the map, the system picks an appropriate
// number.
map<string, int32> device_count = 1;
在Linux上,您可以运行sudo dmidecode -t 4 | egrep -i "Designation|Intel|core|thread"
以查看有多少个CPU /核/线程,例如,以下有2个CPU,每个核有8个核,每个核有2个线程,总共2 * 8 * 2 = 32线程:
fra@s:~$ sudo dmidecode -t 4 | egrep -i "Designation|Intel|core|thread"
Socket Designation: CPU1
Manufacturer: Intel
HTT (Multi-threading)
Version: Intel(R) Xeon(R) CPU E5-2667 v4 @ 3.20GHz
Core Count: 8
Core Enabled: 8
Thread Count: 16
Multi-Core
Hardware Thread
Socket Designation: CPU2
Manufacturer: Intel
HTT (Multi-threading)
Version: Intel(R) Xeon(R) CPU E5-2667 v4 @ 3.20GHz
Core Count: 8
Core Enabled: 8
Thread Count: 16
Multi-Core
Hardware Thread
在Tensorflow 0.12.1和1.0.0以及Ubuntu 14.04.5 LTS x64和Ubuntu 16.04 LTS x64上进行了测试。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句