【问题标题】:RuntimeError: unexpected EOF, expected 3302200 more bytes. The file might be corruptedRuntimeError:意外的 EOF,预计多 3302200 个字节。文件可能已损坏
【发布时间】:2021-06-26 19:46:54
【问题描述】:

我正在尝试实现以下存储库的预训练模型。我需要您的帮助来纠正错误。

RuntimeError: 意外 EOF,预计多 3302200 个字节。文件可能已损坏。

我尝试使用 google Collab 在以下 repo 中实现 CANNet 的预训练模型,并遵循(先决条件、克隆、数据准备和测试)的所有步骤

https://github.com/gjy3035/NWPU-Crowd-Sample-Code.git

下面给出详细错误

Traceback (most recent call last):
File "test.py", line 118, in
main()
File "test.py", line 46, in main
test(lines, model_path)
File "test.py", line 55, in test
net.load_state_dict(torch.load(model_path))
File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 593, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 779, in _legacy_load
deserialized_objects[key]._set_from_file(f, offset, f_should_read_directly)
RuntimeError: unexpected EOF, expected 3302200 more bytes. The file might be corrupted.

【问题讨论】:

    标签: pytorch pre-trained-model torchvision


    【解决方案1】:

    查看这个 github 链接:https://github.com/huggingface/transformers/issues/1491 它建议应该使用force_download arg。这相当于force_reload 假设您使用torch.load.hub 加载预训练模型。建议的另一个适用于 windows 用户的选项是删除下载的模型并重新下载。

    我也有同样的问题,但 --setting force_reload=True 并没有为我解决这个问题,我想我有空间问题,但我认为你值得一试。

    【讨论】:

    • 我通过删除损坏的下载解决了它。
    【解决方案2】:

    当我在 google collab 上评估我的训练模型时,我也遇到了同样的问题。我发现模型需要很长时间才能完全上传到机器上。我正在使用未完全上传的模型进行测试。当我确保模型已完全上传然后我运行时,它就起作用了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-17
      • 1970-01-01
      • 2019-10-03
      • 2019-11-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多