Limiting threads in TensorFlow
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 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時間
- マージ済み PR(30日)
- 8
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
changelog investigate
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
ramnes/notion-sdk-py#423 ·
-
type-bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信