Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Can not pickle `torch.utils.data.DataLoader`

未关闭
#587 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
20/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
python, pytorch

调研方向

首先复现使用 torch.utils.data.DataLoader 的 cloudpickle.dumps 调用,重点关注 torch.utils.data.dataloader.py 中显示的 getstate 失败。该 issue 没有指出 cloudpickle 文件或测试,因此首先确定预期的序列化行为,并在实现任何内容之前为受支持的情况定义测试。

由索引模型根据 Issue 内容生成。

描述

Hi team,

I'm working on some distributed system for AI, and I'd like to pickle an object to transfer it. But it seems I can not pickle DataLoader, is there any suggestions or best practice for that?

  File "/opt/examples/ps/.venv/lib/python3.12/site-packages/flamepy/client.py", line 325, in create_session
    object_ref = put_object(session_id, attrs.common_data)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/examples/ps/.venv/lib/python3.12/site-packages/flamepy/cache.py", line 74, in put_object
    data = cloudpickle.dumps(obj, protocol=cloudpickle.DEFAULT_PROTOCOL)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/examples/ps/.venv/lib/python3.12/site-packages/cloudpickle/cloudpickle.py", line 1544, in dumps
    cp.dump(obj)
  File "/opt/examples/ps/.venv/lib/python3.12/site-packages/cloudpickle/cloudpickle.py", line 1313, in dump
    return super().dump(obj)
           ^^^^^^^^^^^^^^^^^
  File "/opt/examples/ps/.venv/lib/python3.12/site-packages/torch/utils/data/dataloader.py", line 761, in __getstate__
    raise NotImplementedError("{} cannot be pickled", self.__class__.__name__)
NotImplementedError: ('{} cannot be pickled', '_SingleProcessDataLoaderIter')
主要语言
Python
星标
1.9k
派生
197
平均合并
1 天 10 小时
30 天内合并 PR
1

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

cloudpipe/cloudpickle 的其他 Issue

查看 cloudpipe/cloudpickle 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。