AttributeError: 'torch._C.PyTorchFileReader' object has no attribute 'seek'

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

I cannot reproduce this issue using the provided code snippet and am not sure what might cause this error.
Are you also using torchvision==0.7?

Same here, my pytorch is alos 1.6. I also used AMP library.
I have been working with this code for so long. With pytorch 1.3 I never faced this problem.

torchvision.version = 0.7.0
torch.version= 1.6.0
cu 10.2

I have the same problem. The same code works on local but does not work on company cloud. Did anybody find a solution?