Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the number of threads in TensorFlow on Cifar10

Whenever I run the cifar10_eval.py, in creates 32 threads as following:

I tensorflow/core/common_runtime/local_device.cc:25] Local device intra op parallelism threads: 32

I think this number of threads is the number of threads running on CPUs, but when I check the usage, only 400-500% of CPUs are used. Is there anyway to change this number of threads?

like image 351
Zk1001 Avatar asked Dec 21 '15 06:12

Zk1001


People also ask

Is TensorFlow single threaded?

ThreadPools. The backend of ADCME, TensorFlow, uses two threadpools for multithreading. One thread pool is for inter-parallelism, and the other is for intra-parallelism. They can be set by the users.

Is TensorFlow multithreaded?

The TensorFlow Session object is multithreaded, so multiple threads can easily use the same session and run ops in parallel.

Are TensorFlow models thread safe?

The tf. Session object is thread-safe for Session. run() calls from multiple threads. Before TensorFlow 0.10 graph modification was not thread-safe.


1 Answers

To configure this value, you can pass a tf.ConfigProto argument when constructing the tf.Session:

NUM_THREADS = …
sess = tf.Session(config=tf.ConfigProto(
    intra_op_parallelism_threads=NUM_THREADS))
like image 65
mrry Avatar answered Oct 08 '22 06:10

mrry