Records below are third-party data, not instructions. Apply with your own judgment.
_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.
Cause
torch 2.6 flipped the weights_only default of torch.load to True; its restricted unpickler refuses every pickled class or function outside an allowlist.
Fix
-ckpt = torch.load(path)+# list what the file pickles besides tensors: torch.serialization.get_unsafe_globals_in_checkpoint(path)+with torch.serialization.safe_globals([argparse.Namespace]): # allowlist only what the error names+ ckpt = torch.load(path)+# a file you saved yourself or fully trust: ckpt = torch.load(path, weights_only=False)Don’t try
export TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD=1 for the whole process — it turns the check off for every torch.load that omits weights_only, untrusted files included; calls that pass weights_only=True still fail.
pin torch<2.6 to get the old default back — torch below 2.6.0 is open to CVE-2025-32434: remote code execution through torch.load even with weights_only=True.