Skip to content

Maybe a bug about path_lm_ft.py #1

Description

@xuhuanchen

When I run this python file on my own datasets.
It reported a bug about this code:
if global_step in ckpt_steps:
ckpt_path = os.path.join(args.output_dir, f'step_{global_step}.bin')
torch.save(model, ckpt_path) ###this one report a bug.

INFO about this bug:
File "path_lm_ft_2.py", line 1320, in
train(args, train_dataset, model, criterion, tokenizer, load_id=args.load_id, load_element_id=args.load_element_id)
File "path_lm_ft_2.py", line 833, in train
torch.save(model, ckpt_path)
File "/users7/hcxu/miniconda3/lib/python3.7/site-packages/torch/serialization.py", line 379, in save
_save(obj, opened_zipfile, pickle_module, pickle_protocol)
File "/users7/hcxu/miniconda3/lib/python3.7/site-packages/torch/serialization.py", line 484, in _save
pickler.dump(obj)
TypeError: can't pickle torch._C.ScriptFunction objects

Now I just used "torch.save(model.state_dict(), ckpt_path)" to avoid this bug, but I don`t know why this bug occurs.

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