Can't load weights of models
Author: jhqian0909
Pull request: no

When I run below codes, I can successfully load the tokenizer but fail with loading the models.
from transformers import AutoTokenizer, AutoModelWithLMHead
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
model = AutoModelWithLMHead.from_pretrained("bert-base-uncased")

Here is the error:
OSError: Can't load weights for 'bert-base-uncased'. Make sure that:
- 'bert-base-uncased' is a correct model identifier listed on 'https://huggingface.co/models'
- or 'bert-base-uncased' is the correct path to a directory containing a file named one of pytorch_model.bin, tf_model.h5, model.ckpt.

I can load models after manually downloading them but I do want to directly load them via transformers.

Comments:
I think you can try code :
```
from transformers import BertTokenizer, BertModel
tokenizer = BertTokenizer.from_pretrained("bert-base-uncased")
model = BertModel.from_pretrained("bert-base-uncased")
```

> I think you can try code :
> 
> ```
> from transformers import BertTokenizer, BertModel
> tokenizer = BertTokenizer.from_pretrained("bert-base-uncased")
> model = BertModel.from_pretrained("bert-base-uncased")
> ```
still succeed in running tokenizer but fail with modeling

could due to the website limitaition of my company

I have been banging my head on the same issue for a few days now. 
Just observed, it downloads these weights from AWS links ( check configuration_bert.py or configuration_distilbert.py, you'll find these files in /Anaconda3/envs/envName/Lib/site-packages/transformers/ ) and my company blocks AWS and GCP links.
This, most likely, seems to be the issue.

> When I run below codes, I can successfully load the tokenizer but fail with loading the models.
> from transformers import AutoTokenizer, AutoModelWithLMHead
> tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
> model = AutoModelWithLMHead.from_pretrained("bert-base-uncased")
> 
> Here is the error:
> OSError: Can't load weights for 'bert-base-uncased'. Make sure that:
> 
> * 'bert-base-uncased' is a correct model identifier listed on 'https://huggingface.co/models'
> * or 'bert-base-uncased' is the correct path to a directory containing a file named one of pytorch_model.bin, tf_model.h5, model.ckpt.
> 
> I can load models after manually downloading them but I do want to directly load them via transformers.

hello, I meet the same problem ,and if I download the model manually, and where I should put the file in ?

> > When I run below codes, I can successfully load the tokenizer but fail with loading the models.
> > from transformers import AutoTokenizer, AutoModelWithLMHead
> > tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
> > model = AutoModelWithLMHead.from_pretrained("bert-base-uncased")
> > Here is the error:
> > OSError: Can't load weights for 'bert-base-uncased'. Make sure that:
> > 
> > * 'bert-base-uncased' is a correct model identifier listed on 'https://huggingface.co/models'
> > * or 'bert-base-uncased' is the correct path to a directory containing a file named one of pytorch_model.bin, tf_model.h5, model.ckpt.
> > 
> > I can load models after manually downloading them but I do want to directly load them via transformers.
> 
> hello, I meet the same problem ,and if I download the model manually, and where I should put the file in ?


anywhere is ok, just put your file location in BertTokenizer.from_pretrained(location)

> > When I run below codes, I can successfully load the tokenizer but fail with loading the models.
> > from transformers import AutoTokenizer, AutoModelWithLMHead
> > tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
> > model = AutoModelWithLMHead.from_pretrained("bert-base-uncased")
> > Here is the error:
> > OSError: Can't load weights for 'bert-base-uncased'. Make sure that:
> > 
> > * 'bert-base-uncased' is a correct model identifier listed on 'https://huggingface.co/models'
> > * or 'bert-base-uncased' is the correct path to a directory containing a file named one of pytorch_model.bin, tf_model.h5, model.ckpt.
> > 
> > I can load models after manually downloading them but I do want to directly load them via transformers.
> 
> hello, I meet the same problem ,and if I download the model manually, and where I should put the file in ?

Where did u download the model manually from?

You can browse to https://huggingface.co/bert-base-uncased/tree/main for example and download pretrained models.