pytorch - RuntimeError:意外的 EOF,预计多 3302200 个字节。文件可能已损坏
问题描述
我正在尝试实现以下存储库的预训练模型。我需要您的帮助来纠正错误。
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.
解决方案
查看这个 github 链接:https ://github.com/huggingface/transformers/issues/1491
它建议应该使用force_download
arg。这相当于force_reload
假设您正在使用torch.load.hub
加载预训练模型。另一个适用于 windows 用户的选项是删除下载的模型并重新下载。
我有同样的问题,但 --settingforce_reload=True
并没有为我清除它,我认为我有空间问题,但我认为值得一试。
推荐阅读
- android - 如何在电池优化处于活动状态时执行后台服务
- c# - 如何从读取文件中检索到的文本和其中的新内容写入新文件
- python - Keras 中的 BCEWithLogitsLoss
- java - BigQuery 和客户端库之间的数据传输是否安全?
- python - 是否有理由从 Python 中的数字中减去零?
- c++ - 在 DirectX9 [C++] 中渲染 3D 对象的最有效方法是什么?
- maven - 服务未注册 class='interface org.eclipse.tycho.core.shared.ProxyServiceFacade'
- javascript - 搜索嵌套的对象数组并在 JavaScript 中返回完整的父对象作为结果
- file-type - 如何检查文件是否为文本文件?
- scala - Scala Future 在块内调用惰性方法不起作用