Why Tensorflow creates so many CPU threads

爱⌒轻易说出口 提交于 2021-02-10 18:06:42

问题


Even with

inter_op_parallelism_threads = 1
intra_op_parallelism_threads = 1

values set, TensorFlow 1.5 process is not single-threaded. Why? Is there a way to completely disable unexpected thread spawning?


回答1:


First of all, TensorFlow is a multi-level software stack, and each layer tries to be smart and introduces some worker threads of its own:

  • One thread is created by Python runtime
  • Two more threads are created by NVIDIA CUDA runtime

Next, there are threads originating from the way how TensorFlow administers internal compute jobs:

  • Threads are created/joined all the time to poll on job completion (GRPC engine)

Thus, TensorFlow cannot be single-threaded, even with all options set to 1. Perhaps, this design is intended to reduce latencies for async jobs. Yet, there is a certain drawback: multicore compute libraries, such as linear algebra, do cache-intensive operations best with static symmetric core-thread mapping. And dangling callback threads produced by TensorFlow will disturb this symmetry all the time.



来源:https://stackoverflow.com/questions/48696900/why-tensorflow-creates-so-many-cpu-threads

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!