Transformers-CLI not saving pytorch model after conversion
@patrickvonplaten, @LysandreJik

Hi, I'm using transformers CLI as per https://docs.aitextgen.io/gpt-2-simple/

But getting this error, where transformers is not saving the pytorch model. Not sure why. I tried in both Ubuntu and Windows. Two different system, but getting same error. So not sure what is the issue

Save PyTorch model to pytorch/pytorch_model.bin
Traceback (most recent call last):
  File "c:\programdata\anaconda3\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\programdata\anaconda3\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\XXX\AppData\Roaming\Python\Python38\Scripts\transformers-cli.exe\__main__.py", line 7, in <module>
  File "C:\Users\XXX\AppData\Roaming\Python\Python38\site-packages\transformers\commands\transformers_cli.py", line 51, in main
    service.run()
  File "C:\Users\XXX\AppData\Roaming\Python\Python38\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 "C:\Users\XXX\AppData\Roaming\Python\Python38\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 "c:\programdata\anaconda3\lib\site-packages\torch\serialization.py", line 376, in save
    with _open_file_like(f, 'wb') as opened_file:
  File "c:\programdata\anaconda3\lib\site-packages\torch\serialization.py", line 230, in _open_file_like
    return _open_file(name_or_buffer, mode)
  File "c:\programdata\anaconda3\lib\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'


## Environment info
- `transformers` version: 4.7.0
- Platform: Windows
- Python version: 3.8.3 
- PyTorch version (GPU?): 1.9.0+cpu
- Tensorflow version (GPU?): 2.5.0 
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: no

## Information

Model I am using: GPT2

The problem arises when using:
* [X] the official example scripts: (give details below)
* [ ] my own modified scripts: (give details below)

The tasks I am working on is:
* [ ] an official GLUE/SQUaD task: (give the name)
* [x] my own task or dataset: (give details below)

## To reproduce

Steps to reproduce the behavior:

1. Run the command transformers-cli convert --model_type gpt2 --tf_checkpoint checkpoint/run1 --pytorch_dump_output pytorch --config checkpoint/run1/hparams.json


## Expected behavior
The script should save pytorch_model.bin but it seems it is not saving. Hence it is unable to load it. 

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md) are likely to be ignored.<|||||>I did this

https://github.com/minimaxir/aitextgen/issues/141


On Mon, Nov 22, 2021 at 4:48 PM ryanhampton ***@***.***>
wrote:

> This is also not working for me - any fix?
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/huggingface/transformers/issues/12275#issuecomment-975984018>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AFZRJKCPEX7W4YLIZHPKYETUNLCCDANCNFSM47ARIHXQ>
> .
> Triage notifications on the go with GitHub Mobile for iOS
> <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
> or Android
> <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
>
>
