Limiting threads in TensorFlow
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- numpy, python, scikit-learn, tensorflow
调研方向
Start by reading the threadpoolctl code that discovers and controls native thread pools, then check whether TensorFlow exposes a supported control point in the version discussed (2.5.0). Reproduce the example with threadpool_limits(limits=1) and compare CPU time with and without the limit. Done means TensorFlow work respects the requested limit, or the issue documents why threadpoolctl cannot control it and what limitation users should expect.
由索引模型根据 Issue 内容生成。
描述
As far as I can tell, limiting the number of threads in TensorFlow with threadpoolctl currently doesn't work.
For instance with the following minimal example with Tensorflow 2.5.0,
example.py
import tensorflow as tf
import numpy as np
from threadpoolctl import threadpool_limits
with threadpool_limits(limits=1):
X = tf.constant(np.arange(0, 5000**2, dtype=np.int32), shape=(5000, 5000))
tf.matmul(X, X)
running,
time python example.py
on a 64 cores CPU, produces,
real 0m3.781s
user 1m8.685s
so the user (CPU) time is still >> real run time, meaning that many CPU are used.
This becomes an issue if people run scikit-learn's GridSearchCV or cross_validate on a Keras or TensorFlow model, since it then results in CPU over-subscription. I'm surprised there are no more issues about it at scikit-learn.
Tensorflow also regrettably doesn't recognize any environment variables to limit the number of CPU cores either. The only way I found around it is to set the CPU affinity mask with taskset. But then again it wouldn't help for cross-validation for instance, since joblib would then need to set the affinity mask when creating new processes which is currently not supported.
Has anyone looked into this in the past by any chance?
- 主要语言
- Python
- 星标
- 434
- 派生
- 38
- 平均合并
- 2 天 14 小时
- 30 天内合并 PR
- 8
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
joblib/threadpoolctl 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 25/100
joblib/threadpoolctl#271 ·
维护者通常 1 天内回复
-
Make it possible to inspect active/spin wait behavior of LLVM/Intel OpenMP via `kmp_get_blocktime`未关闭
难度 3/5 1-2 天 新手友好度 42/100
joblib/threadpoolctl#270 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 22/100
joblib/threadpoolctl#261 · 3 条评论 ·
维护者通常 1 天内回复
-
Opt-in API that has a cached `ThreadpoolController`可能已有人在做 @itamarst 于 27 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 25/100
joblib/threadpoolctl#254 · 3 条评论 ·
维护者通常 1 天内回复
-
Speed up usage of threadpoolctl可能已有人在做 @itamarst 于 35 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 18/100
joblib/threadpoolctl#246 ·
维护者通常 1 天内回复
查看 joblib/threadpoolctl 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
ansys/pyansys-common-mcp#213 ·
维护者通常 3 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 67/100
freedomofpress/dangerzone#1594 ·
维护者通常 3 天内回复
-
priority:P1 status:in-review type:bug
难度 2/5 1-3 小时 新手友好度 75/100
randomparity/kdive#3317 · 1 条评论 ·
维护者通常 1 天内回复
-
area:ci
难度 1/5 1 小时以内 新手友好度 90/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
mesonbuild/meson#16281 ·
维护者通常 1 天内回复