如何在一个内核上运行Tensorflow? [英] How can I run Tensorflow on one single core?

查看:117
本文介绍了如何在一个内核上运行Tensorflow?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在集群上使用Tensorflow,我想告诉Tensorflow仅在一个核心上运行(即使有更多可用的核心)。

I'm using Tensorflow on a cluster and I want to tell Tensorflow to run only on one single core (even though there are more available).

有人吗?知道这是否可能吗?

Does someone know if this is possible?

推荐答案

要在一个CPU线程上运行Tensorflow,我使用:

To run Tensorflow on one single CPU thread, I use:

session_conf = tf.ConfigProto(
      intra_op_parallelism_threads=1,
      inter_op_parallelism_threads=1)
sess = tf.Session(config=session_conf)

device_count 限制使用的CPU,而不是内核或线程的数量。

device_count limits the number of CPUs being used, not the number of cores or threads.

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个线程:


On Linux you can run sudo dmidecode -t 4 | egrep -i "Designation|Intel|core|thread" to see how many CPUs/cores/threads you have, e.g. the following has 2 CPUs, each of them has 8 cores, each of them has 2 threads, which gives a total of 2*8*2=32 threads:

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上进行了测试。

Tested with Tensorflow 0.12.1 and 1.0.0 with Ubuntu 14.04.5 LTS x64 and Ubuntu 16.04 LTS x64.

这篇关于如何在一个内核上运行Tensorflow?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆