Skip to content

[BUG]: GeminiStrategy save_pretrained CAN NOT be loaded with map_location #4292

@cwher

Description

@cwher

🐛 Describe the bug

These scripts can be used to reproduce this error. Just run run.sh.

  File "load.py", line 6, in <module>
    state_dict = torch.load("bloom/pytorch_model.bin", map_location=torch.device('cpu'))
  File "/home/lccwh/.conda/envs/cls-ai/lib/python3.8/site-packages/torch/serialization.py", line 789, in load
    return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
  File "/home/lccwh/.conda/envs/cls-ai/lib/python3.8/site-packages/torch/serialization.py", line 1131, in _load
    result = unpickler.load()
  File "/home/lccwh/.conda/envs/cls-ai/lib/python3.8/site-packages/torch/_tensor.py", line 60, in _rebuild_from_type_v2
    ret = func(*args)
  File "/home/lccwh/.conda/envs/cls-ai/lib/python3.8/site-packages/torch/_utils.py", line 153, in _rebuild_tensor_v2
    tensor = _rebuild_tensor(storage, storage_offset, size, stride)
  File "/home/lccwh/.conda/envs/cls-ai/lib/python3.8/site-packages/torch/_utils.py", line 147, in _rebuild_tensor
    return t.set_(storage.untyped(), storage_offset, size, stride)
RuntimeError: Trying to resize storage that is not resizable

Environment

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions