24

I am running the imagenet from TensorFlow models repository. I've instrumented sess.run as described in Github comment and got the following view in the chrome://tracing

enter image description here

I am wondering if TF sometime uses multiple cores or single core all the time. I'd think it is using multiple cores when ops can run in parallel as shown in the red box of the figure. However, all these 6 threads are listed under /job:localhost/replicate:0/task:0/cpu:0 which makes me question my interpretation. Does cpu:0 mean all CPU cores?

I am running on a desktop with 8 cores. I run htop to see core utilization during the TF run and I see only one core getting saturated 95-100%.

Nodir Kodirov
  • 899
  • 1
  • 10
  • 16

1 Answers1

35

I found existing answer to this question. All cores are wrapped in cpu:0, i.e., TensorFlow does indeed use multiple CPU cores by default.

Community
  • 1
  • 1
Nodir Kodirov
  • 899
  • 1
  • 10
  • 16
  • I want TensorFlow not to see/know more than one core of cpu:0. How can I do that? – fisakhan Sep 30 '20 at 13:33
  • There are two ways to go about this: 1) disable visibility of your cores on the Operating Systems level, and 2) tell TensorFlow NOT to use other cores in runtime. I think you want the latter one, or at least that's my preferred solution. If so, read an existing answer that nicely describes the details, here https://stackoverflow.com/a/41233901/4404659 If you really want the first option, it is somehow OS dependant. Here is a solution for Debian systems - https://unix.stackexchange.com/a/145815/236150 - http://www.upubuntu.com/2011/09/how-to-disable-cpu-core-on-ubuntudebian.html – Nodir Kodirov Oct 01 '20 at 20:25
  • The solution you suggest reduces the number of threads to number of cores but not to 1. device_count limits the number of CPUs being used, not the number of cores or threads. https://stackoverflow.com/questions/38187808/how-can-i-run-tensorflow-on-one-single-core/41819430#41819430 – fisakhan Oct 01 '20 at 20:49