Skip to content

Bug: UnpicklingError When Loading the Checkpoint on Rank 0 #548

@wyin1632

Description

@wyin1632

I got the following error during a model sweep.

[rank0]:   File "/home/ubuntu/miniconda3/envs/torch_tabular/lib/python3.10/site-packages/pytorch_tabular/utils/python_utils.py", line 85, in pl_load
[rank0]:     return torch.load(f, map_location=map_location)
[rank0]:   File "/home/ubuntu/miniconda3/envs/torch_tabular/lib/python3.10/site-packages/torch/serialization.py", line 1470, in load
[rank0]:     raise pickle.UnpicklingError(_get_wo_message(str(e))) from None
[rank0]: _pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, do those steps only if you trust the source of the checkpoint. 
[rank0]:        (1) In PyTorch 2.6, we changed the default value of the `weights_only` argument in `torch.load` from `False` to `True`. Re-running `torch.load` with `weights_only` set to `False` w
ill likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
[rank0]:        (2) Alternatively, to load with `weights_only=True` please check the recommended steps in the following error message.
[rank0]:        WeightsUnpickler error: Unsupported global: GLOBAL omegaconf.dictconfig.DictConfig was not an allowed global by default. Please use `torch.serialization.add_safe_globals([DictConfi
g])` or the `torch.serialization.safe_globals([DictConfig])` context manager to allowlist this global if you trust this class/function.

[rank0]: Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html.

Chaging to torch.load(f, map_location=map_location, weights_only=False) solved the error. Should we set weights_only=False in the code by default?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingwontfixThis will not be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions