Please support prefetch with python datasets
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 20/100
- Issue 类型
- 功能
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- python, tensorflow
- 领域
- data, machine-learning
调研方向
首先检查 tf.data.Dataset 中与 prefetch 和 generator 相关的入口点;该 issue 没有指出仓库文件或测试。使用 Python generator 和 prefetch 重现报告的行为,然后确定受支持的行为和约束。完成这项工作需要达成一致的设计,并提供测试来证明自定义 Python dataset 的准备过程可以进行预取,而不会阻塞 accelerator 工作。
由索引模型根据 Issue 内容生成。
描述
Is your feature request related to a problem? Please describe.
There's a tremendous performance difference between datasets which are fully tensor end-to-end and datasets where some data wrangling happens in Python.
I was hoping to use "prefetch" to prepare data with the CPU while the GPU does work, but unfortunately, this only works if the data preparation is fully tensorflow-ish (? not sure the right term here)
Python IO operations are often exponentially slower and act as a bottleneck and prevent computers from keeping accelerators working at capacity.
Describe the solution you'd like
I wish tf.data.Dataset prefetch was more broadly compatible with prefetching of non-tensorflow vanilla-python data preparations.
Would it be possible for prefetch to use some performant C++ to sidestep Python GIL issues and juggle python data wrangling CPU processes alongside GPU training / inference without depending on such python CPU work happening in the main python driver process? I just want to be able to prefetch custom python datasets. Often there's some prep involved, not every dataset is tensorflow end-to-end.
i.e. instead of (python)->(gpu) what if it were
(python)->(cpp)
(cpp)->(python_prefetch)
(cpp)->(gpu/tpu accelerator)
Since C++ lacks a GIL, it could just run the python generator in a process which is isolated from the main python driver process' GIL, you'd still have a GIL per generator, but that's an easy fix, just run more python processes with different random seeds etc.
Describe alternatives you've considered
Torch DataLoader could be an option but it also seems to be a python-driven solution and therefore not super performant. I tried Threading, but pickling and unpickling overhead in python can be pretty bad. I think maybe C++ could run a background python process to prefetch python data in a more performant way than python could.
Additional context
Broader accessibility of custom dataset prefetching could enable new use-cases for tf.data especially in prototyping or infinite search spaces where it might not make sense to convert entire datasets to tensors in advance.
Apologies if I misunderstand the intricacies involved. I just want to prefetch datasets built from generators. I tried doing this last week but it didn't work, so hopefully I'm not mentioning an issue which is fixed and I missed a way to pull it off. It's hard to provide an example since the code in question is closed-source and quite extensive anyway. For a good example of when this might be handy, consider RL gym envs or datasets which involve making GET requests.
- 主要语言
- Python
- 星标
- 4.6k
- 派生
- 1.6k
- 平均合并
- 14 小时 3 分钟
- 30 天内合并 PR
- 5
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
tensorflow/datasets 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
tensorflow/datasets#11260 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
tensorflow/datasets#11253 ·
-
DatasetInfo.read_from_directory reads the deprecated FieldDescriptor.label eagerly, warning on every open可能已有人在做 @jabrailkhalil 于 48 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
tensorflow/datasets#11245 · 1 条评论 ·
-
required dependency on importlib_resources missing可能已有人在做 @ArS377 于 128 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 68/100
tensorflow/datasets#11212 · 2 条评论 · 1 个 reaction ·
-
C4 badwords filter: capitalized entries in upstream wordlists never match (text is lower-cased, list entries are not)可能已有人在做 @Jefferyjia 于 3 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 20/100
tensorflow/datasets#11258 ·
查看 tensorflow/datasets 的全部 Issue
相似的 Issue
-
difficulty:1 documentation
难度 2/5 1-3 小时 新手友好度 82/100
MakazhanAlpamys/Soup#3533 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
onyx-dot-app/onyx#18730 ·
维护者通常 1 天内回复
-
namespace team:operations
难度 1/5 1 小时以内 新手友好度 65/100
EclipseFdn/open-vsx.org#16509 ·
维护者通常 1 天内回复
-
难度 1/5 1-3 小时 新手友好度 88/100
langflow-ai/langflow#16689 ·
维护者通常 1 天内回复
-
ScoringSystem.get() and compute() return NotImplementedError instead of raising it可能已有人在做 @sc-lacanlale 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 83/100
aboutcode-org/vulnerablecode#2552 ·
维护者通常 5 天内回复