I tried to load the parameters of the model, but reported this error
Code:
from naie.datasets import get_data_reference
import torch
import torchvision.models as models
from utils import EarlyStopping
if __name__ == "__main__":
model=models.resnet50()
model=model.cuda()
torch.save(model.state_dict(),'/cache/step1.pt')
checkpoint=torch.load('/cache/step1.pt')
model.load_state_dict(checkpoint)
Error:
Traceback (most recent call last):
File "test_code.py", line 11, in <module>
checkpoint=torch.load('/cache/step1.pt')
File "/home/work/anaconda/lib/python3.6/site-packages/torch/serialization.py", line 584, in load
return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
File "/home/work/anaconda/lib/python3.6/site-packages/moxing/framework/file/file_io_patch.py", line 200, in _load
_check_seekable(f)
File "/home/work/anaconda/lib/python3.6/site-packages/torch/serialization.py", line 309, in _check_seekable
raise_err_msg(["seek", "tell"], e)
File "/home/work/anaconda/lib/python3.6/site-packages/torch/serialization.py", line 302, in raise_err_msg
raise type(e)(msg)
AttributeError: 'torch._C.PyTorchFileReader' object has no attribute 'seek'. You can only torch.load from a file that is seekable. Please pre-load the data into a buffer like io.BytesIO and try to load from it instead.
my pytorch version is 1.6