Closed anandmg101 closed 3 years ago
Found a work around, in case anyone is having the same issue.
from transformers import GPT2Model, GPT2Config config = GPT2Config.from_json_file('./checkpoint/run1/hparams.json') model = GPT2Model.from_pretrained('./checkpoint/run1/model-955.index', from_tf=True, config=config) model.save_pretrained('./pytorch', saved_model=True)
This saves the config and pytorch_model.bin files
Hi, trying to convert gpt2-simple fine tuned model. I'm getting this error. I guess its not able to save the pytorch model. Not sure why.
Any suggestions?
Save PyTorch model to pytorch/pytorch_model.bin Traceback (most recent call last): File "/home/XXXX/XXXX/djgpt2env/bin/transformers-cli", line 8, in
sys.exit(main())
File "/home/XXXX/XXXX/djgpt2env/lib/python3.8/site-packages/transformers/commands/transformers_cli.py", line 51, in main
service.run()
File "/home/XXXX/XXXX/djgpt2env/lib/python3.8/site-packages/transformers/commands/convert.py", line 152, in run
convert_gpt2_checkpoint_to_pytorch(self._tf_checkpoint, self._config, self._pytorch_dump_output)
File "/home/XXXX/XXXX/djgpt2env/lib/python3.8/site-packages/transformers/models/gpt2/convert_gpt2_original_tf_checkpoint_to_pytorch.py", line 45, in convert_gpt2_checkpoint_to_pytorch
torch.save(model.state_dict(), pytorch_weights_dump_path)
File "/home/XXXX/XXXX/djgpt2env/lib/python3.8/site-packages/torch/serialization.py", line 369, in save
with _open_file_like(f, 'wb') as opened_file:
File "/home/XXXX/XXXX/djgpt2env/lib/python3.8/site-packages/torch/serialization.py", line 230, in _open_file_like
return _open_file(name_or_buffer, mode)
File "/home/XXXX/XXXX/djgpt2env/lib/python3.8/site-packages/torch/serialization.py", line 211, in init
super(_open_file, self).init(open(name, mode))
FileNotFoundError: [Errno 2] No such file or directory: 'pytorch/pytorch_model.bin'