gpt4 book ai didi

python - TensorFlow默认使用多少个内核(不使用Coordinator)?

转载 作者:行者123 更新时间:2023-12-03 13:08:39 25 4
gpt4 key购买 nike

我猜默认情况下(当我不使用'Coordinator'时)tensorflow使用单核,因为tensorflow是python库。

但是,当我在运行TensorFlow代码的Mac上看到 Activity 监视器时
在默认设置下,python 3.6的$ CPU大于100%,线程数大于10。

tensorflow默认使用多核吗?

最佳答案

Tensorflow是一个python库,但实际上是对 native C++实现的包装。每当您定义操作时,如下所示:

with tf.device("/cpu:0"):
a = tf.Variable(3.0)
b = tf.constant(4.0)
c = a * b

... c不是python变量 ab的乘积,而是 tf.multiply op,但它不是那么琐碎的 CPU and GPU implementations

因此,它不会让您感到困惑:tensorflow引擎正在尝试使用所有可用的硬件功能来执行操作,尤其是 FAQ states是多核的:

The individual ops have parallel implementations, using multiple cores in a CPU, or multiple threads in a GPU.



顺便说一句,值得注意的是 "/cpu:0"设备聚集了多CPU系统上的所有CPU。
当前无法将节点固定在特定CPU上或使用
只是所有CPU的一个子集。

关于python - TensorFlow默认使用多少个内核(不使用Coordinator)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47287628/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com