Skip to content

Failed to load model #44

@johnnytam100

Description

@johnnytam100

Hi @bjing2016 ! AlphaFlow has a very unique niche and I am trying hard to use it!
Do you know how to tackle the following error?

(alphaflow) a4038764@pdgx001:/data/a4038764/test/test_AlphaFlow/alphaflow$ python predict.py --mode esmfold --input_csv ./splits/atlas_test.csv --weights ./weights/esmflow_md_distilled_202402.pt --samples 100 --outpdb ./

2025-02-06 15:38:47,382 [pdgx001:3887448] [INFO] Loading the model
Traceback (most recent call last):
  File "/data/a4038764/test/test_AlphaFlow/alphaflow/predict.py", line 133, in <module>
    main()
  File "/share/a4038764/miniconda3/envs/alphaflow/lib/python3.9/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
    return func(*args, **kwargs)
  File "/data/a4038764/test/test_AlphaFlow/alphaflow/predict.py", line 76, in main
    ckpt = torch.load(args.weights, map_location='cpu')
  File "/share/a4038764/miniconda3/envs/alphaflow/lib/python3.9/site-packages/torch/serialization.py", line 1470, in load
    raise pickle.UnpicklingError(_get_wo_message(str(e))) from None
_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. 
        (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` will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
        (2) Alternatively, to load with `weights_only=True` please check the recommended steps in the following error message.
        WeightsUnpickler error: Unsupported global: GLOBAL ml_collections.config_dict.config_dict.ConfigDict was not an allowed global by default. Please use `torch.serialization.add_safe_globals([ConfigDict])` or the `torch.serialization.safe_globals([ConfigDict])` context manager to allowlist this global if you trust this class/function.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions