Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Model checkpointed using torch.save() unable to be loaded using torch.load() #12042

Closed
@deepakn94

Description

@deepakn94

I have created a PyTorch model checkpoint usingtorch.save; however, I'm unable to load this model usingtorch.load. I run into the following error:

>>> torch.load('model_best.pth.tar')Traceback (most recent call last):  File "<stdin>", line 1, in <module>  File "/home/ubuntu/anaconda3/envs/pytorch_source/lib/python3.7/site-packages/torch/serialization.py", line 358, in load    return _load(f, map_location, pickle_module)  File "/home/ubuntu/anaconda3/envs/pytorch_source/lib/python3.7/site-packages/torch/serialization.py", line 549, in _load    deserialized_objects[key]._set_from_file(f, offset, f_should_read_directly)RuntimeError: storage has wrong size: expected -7659745797817883467 got 512

The model was saved using code like this:

defsave_checkpoint(epoch,model,best_top5,optimizer,is_best=False,filename='checkpoint.pth.tar'):state= {'epoch':epoch+1,'state_dict':model.state_dict(),'best_top5':best_top5,'optimizer' :optimizer.state_dict(),    }torch.save(state,filename)ifargs.local_rank==0:ifis_best:save_checkpoint(epoch,model,best_top5,optimizer,is_best=True,filename='model_best.pth.tar')

The model was trained across multiplep3.16xlarge instances.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp