Skip to content

Weights only load failed #256

@dmendez92

Description

@dmendez92

Hello,

I just installed ms2query according to the instructions, downloaded the libraries and tried to run a query, but I got the following error message:

Traceback (most recent call last):
File "/home/daniel/anaconda3/envs/ms2query/bin/ms2query", line 8, in
sys.exit(command_line())
File "/home/daniel/anaconda3/envs/ms2query/lib/python3.9/site-packages/ms2query/init.py", line 80, in command_line
ms2library = create_library_object_from_one_dir(ms2query_library_files_directory)
File "/home/daniel/anaconda3/envs/ms2query/lib/python3.9/site-packages/ms2query/ms2library.py", line 448, in create_library_object_from_one_dir
return MS2Library(dict_with_file_paths["sqlite"], dict_with_file_paths["s2v_model"],
File "/home/daniel/anaconda3/envs/ms2query/lib/python3.9/site-packages/ms2query/ms2library.py", line 79, in init
self.ms2ds_model = load_ms2ds_model(ms2ds_model_file_name)
File "/home/daniel/anaconda3/envs/ms2query/lib/python3.9/site-packages/ms2deepscore/models/load_model.py", line 34, in load_model
model_settings = torch.load(filename, map_location=device)
File "/home/daniel/anaconda3/envs/ms2query/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 numpy.core.multiarray._reconstruct was not an allowed global by default. Please use torch.serialization.add_safe_globals([_reconstruct]) or the torch.serialization.safe_globals([_reconstruct]) 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.

Any help is appreciated. Thanks

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