2016-07-04 7 views

答えて

1

device_countConfigProtoをセッションの作成時にconfig引数として渡すことで、TensorFlowが使用する特定の種類のデバイスの数を制限することができます。

config = tf.ConfigProto(device_count={'CPU': 1}) 
sess = tf.Session(config=config) 
with sess.as_default(): 
    print(tf.constant(42).eval()) 
+5

私はこれを試しましたが、動作しません。クラスタにジョブを投入すると、Tensorflowは1つのノードのすべての使用可能なコアでも動作します。私は次のようにしますINIT = tf.initialize_all_variables() #launchグラフコンフィグ= tf.ConfigProto(DEVICE_COUNT = { 'CPU':1}) のSES = tf.Session(設定=設定) sess.run (init) –

18

1つの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の数が使用されている制限はなく、次のようにたとえば、あなたは、CPUデバイスの数を制限することができますコアまたはスレッドの数

tensorflow/tensorflow/core/protobuf/config.proto氏は述べています:Linuxの

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; 

を使用すると、例えば、あなたが持っているどのように多くのCPU /コア/スレッドを参照してsudo dmidecode -t 4 | egrep -i "Designation|Intel|core|thread"を実行することができますTensorflow 0.12.1及び1.0でテスト

[email protected]:~$ 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 

:以下は、それらの各々は、* 2 = 32 * 8 2スレッドの合計を与える2つのスレッドを有し、それらの各々は、8つのコアを有し、2つのCPUを有しています。 0とUbuntu 14.04.5 LTS x64とUbuntu 16.04 LTS x64。

+0

残念ながら、これはWIndows 10(tf 1.5.0)で実行しても効果がないようです。コアを他のプログラムのために自由にする方法を持たないことは問題です。 – Elroch

+0

@LiamRoche私はこれが起こるはずだとは思わない。 tensorflow GitHubリポジトリに問題を提起したいかもしれません。 –

関連する問題