Loading fine-tuned models 
Author: chughe22
Pull request: no

Since the transformers update, I am unable to load a newly trained model.

OSError: Unable to load weights from pytorch checkpoint file for './model_source_450_v2' at './model_source_450_v2/pytorch_model.bin'If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True. 

Have tried to set "from_tf=True" but still not loading successfully

The model is being created in pytorch

Comments:
Hello, could you please provide all the information requested in the issue template? The environment is important, so is your code.

Which update did you do? To v4.1.1? From which version?

Thank you.

Working in Google Colab, so the second to most recent version and then the most recent version. 
Using BertForSequenceClassification and fine-tuning the model I'm trying to output and reload.

```
 #Save a trained model, configuration and tokenizer using `save_pretrained()`.
model_to_save = model.module if hasattr(model, 'module') else model  # Take care of distributed/parallel training
model_to_save.save_pretrained(output_dir)
tokenizer.save_pretrained(output_dir)

# Copy the model files to a directory in your Google Drive.
!cp -r './model_source_450_v2/' "./drive/My Drive"

```
Then this code for a GPU node on a supercomputer which works on previously created model files
```
from transformers import AutoTokenizer, AutoModel
import torch
import random

# setting device to GPU if available
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
print('using device: ', device)
print()

"""model_source_450_v2 files

*   config.json
*   pytorch_model.bin
*   special_tokens_map.json
*   tokenizer_config.json
*   vocab.txt
"""
#set modelpath
modelpath = "./model_source_450_v2" #location of fully trained model


from transformers import BertTokenizer, BertModel

# Retrieve fine-tuned BERT.
bert_model = BertModel.from_pretrained(modelpath,
                                  output_hidden_states = True) 
bert_tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')

bert_model.eval()
bert_model.to(device)
```

Could you share your PyTorch versions as well? On both setups. PyTorch changed their saved models format, so you may have the issue of saving in a newer torch version (>= 1.6.0), and reloading in an older (<1.6.0) torch version

on supercomputer: "import torch; print(torch.__version__)"
1.7.0
on colab:
1.7.0+cu101

Hmmm, I'm having a hard time understanding what might be happening from the stack-trace. You wouldn't happen to have the entire stack-trace, would you? If you do, please share it. 

Is it possible the file was corrupted between saving and loading?

I tried resaving and had the same issue.

```
using device:  cuda

Traceback (most recent call last):
  File "/afs/crc.nd.edu/user/d/dheryadi/mcob/lib/python3.8/site-packages/transformers/modeling_utils.py", line 951, in from_pretrained
    state_dict = torch.load(resolved_archive_file, map_location="cpu")
  File "/afs/crc.nd.edu/user/d/dheryadi/mcob/lib/python3.8/site-packages/torch/serialization.py", line 587, in load
    with _open_zipfile_reader(opened_file) as opened_zipfile:
  File "/afs/crc.nd.edu/user/d/dheryadi/mcob/lib/python3.8/site-packages/torch/serialization.py", line 242, in __init__
    super(_open_zipfile_reader, self).__init__(torch._C.PyTorchFileReader(name_or_buffer))
RuntimeError: [enforce fail at inline_container.cc:145] . PytorchStreamReader failed reading zip archive: failed finding central directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "gpu_v2.py", line 77, in <module>
    bert_model = BertModel.from_pretrained(modelpath,
  File "/afs/crc.nd.edu/user/d/dheryadi/mcob/lib/python3.8/site-packages/transformers/modeling_utils.py", line 953, in from_pretrained
    raise OSError(
OSError: Unable to load weights from pytorch checkpoint file for './model_source_450_v2' at './model_source_450_v2/pytorch_model.bin'If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True. 
```

Do you manage to reload the checkpoint without moving it to the new "supercomputer environment" ? 

The error seems to be with PyTorch rather than with Transformers given the error message: 
```
PytorchStreamReader failed reading zip archive: failed finding central directory
```

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 have the same error, is anyone able to solve this problem
line 477, in load_state_dict
    raise OSError(
OSError: Unable to load weights from pytorch checkpoint file for '{Mydict}.cache\huggingface\transformers\4a74c6c9128ba518e61fbdf559d03e64b6bd0ad6db588419dfd865ace535942a.a48b7b4437be34e24274c9cf6cf57e2424d3f1eec537ec03b905e6f01d19ed77' at '{Mydict}.cache\huggingface\transformers\4a74c6c9128ba518e61fbdf559d03e64b6bd0ad6db588419dfd865ace535942a.a48b7b4437be34e24274c9cf6cf57e2424d3f1eec537ec03b905e6f01d19ed77'. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.
Hey Please can you help me to solve this problem