Skip to content

Corrupted checkpoint file #23

@juanwulu

Description

@juanwulu

Hello there, I have issue loading one of your fine-tuned checkpoint under ViT-B-16/Cars/finetuned.pt. The error message is

Error Message

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[155], [line 8](vscode-notebook-cell:?execution_count=155&line=8)
      1 # @title load checkpoints
      2 # uncomment the following line to load from the pretrained checkpoints
      3 # checkpoint = torch.load(
      4 #   os.path.join(_TA_CKPT_ROOT, MODEL_NAME, "zeroshot.pt")
      5 # )
      6 # uncomment the following line to load from the finetuned checkpoints
      7 dataset_name: str = "Cars"
----> [8](vscode-notebook-cell:?execution_count=155&line=8) checkpoint = torch.load(
      9   os.path.join(_TA_CKPT_ROOT, MODEL_NAME, dataset_name, "finetuned.pt")
     10 )
     12 for layer_name, layer_weight in checkpoint.state_dict().items():
     13   print(f"{layer_name} has parameters of shape {layer_weight.shape}.")

File ~/miniconda3/envs/task-vectors/lib/python3.10/site-packages/torch/serialization.py:795, in load(f, map_location, pickle_module, weights_only, **pickle_load_args)
    793     except RuntimeError as e:
    794         raise pickle.UnpicklingError(UNSAFE_MESSAGE + str(e)) from None
--> [795](https://vscode-remote+ssh-002dremote-002bcloudtop-002dwfh.vscode-resource.vscode-cdn.net/usr/local/google/home/chocodave/Desktop/research/task_vectors/notebooks/~/miniconda3/envs/task-vectors/lib/python3.10/site-packages/torch/serialization.py:795) return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)

File ~/miniconda3/envs/task-vectors/lib/python3.10/site-packages/torch/serialization.py:1004, in _legacy_load(f, map_location, pickle_module, **pickle_load_args)
   1002 magic_number = pickle_module.load(f, **pickle_load_args)
   1003 if magic_number != MAGIC_NUMBER:
-> [1004](https://vscode-remote+ssh-002dremote-002bcloudtop-002dwfh.vscode-resource.vscode-cdn.net/usr/local/google/home/chocodave/Desktop/research/task_vectors/notebooks/~/miniconda3/envs/task-vectors/lib/python3.10/site-packages/torch/serialization.py:1004)     raise RuntimeError("Invalid magic number; corrupt file?")
   1005 protocol_version = pickle_module.load(f, **pickle_load_args)
   1006 if protocol_version != PROTOCOL_VERSION:

RuntimeError: Invalid magic number; corrupt file?

Environment

Here is the output from running pip list:

Package             Version
------------------- -----------
absl-py             2.3.0
asttokens           3.0.0
brotlipy            0.7.0
certifi             2025.6.15
cffi                1.15.1
charset-normalizer  3.4.2
chex                0.1.82
comm                0.2.2
contourpy           1.3.2
cryptography        37.0.2
cycler              0.12.1
debugpy             1.8.14
decorator           5.2.1
etils               1.12.2
exceptiongroup      1.3.0
executing           2.2.0
filelock            3.18.0
flax                0.7.4
fonttools           4.58.4
fsspec              2025.5.1
ftfy                6.3.1
hf-xet              1.1.5
huggingface-hub     0.33.1
idna                3.10
importlib_resources 6.5.2
ipykernel           6.29.5
ipympl              0.9.7
ipython             8.37.0
ipywidgets          8.1.7
jax                 0.4.13
jaxlib              0.4.13
jedi                0.19.2
jupyter_client      8.6.3
jupyter_core        5.8.1
jupyterlab_widgets  3.0.15
kiwisolver          1.4.8
markdown-it-py      3.0.0
matplotlib          3.10.3
matplotlib-inline   0.1.7
mdurl               0.1.2
mkl-fft             1.3.1
mkl-random          1.2.2
mkl-service         2.4.0
ml_collections      1.1.0
ml_dtypes           0.5.1
msgpack             1.1.1
nest-asyncio        1.6.0
numpy               1.26.4
open-clip-torch     2.0.2
opt_einsum          3.4.0
optax               0.2.1
orbax-checkpoint    0.5.16
packaging           25.0
parso               0.8.4
pexpect             4.9.0
pillow              11.2.1
pip                 22.2.2
platformdirs        4.3.8
prompt_toolkit      3.0.51
protobuf            6.31.1
psutil              7.0.0
ptyprocess          0.7.0
pure_eval           0.2.3
pycparser           2.22
Pygments            2.19.2
pyparsing           3.2.3
python-dateutil     2.9.0.post0
PyYAML              6.0.2
pyzmq               27.0.0
regex               2024.11.6
requests            2.32.4
rich                14.0.0
safetensors         0.5.3
scipy               1.15.3
setuptools          63.4.1
six                 1.17.0
stack-data          0.6.3
tensorstore         0.1.75
timm                1.0.16
toolz               1.0.0
torch               1.13.1+cpu
torchaudio          0.13.1+cpu
torchvision         0.14.1+cpu
tornado             6.5.1
tqdm                4.67.1
traitlets           5.14.3
typing_extensions   4.14.0
urllib3             2.5.0
wcwidth             0.2.13
wheel               0.45.1
widgetsnbextension  4.0.14
zipp                3.23.0

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