OSError: Can't load config for saved_model when deploying on EC2.
Author: katreparitosh
Pull request: no

I was deploying a trained model on AWS EC2 instance (t3a.xlarge) using a dockerized image and Flask. The model was trained using [fast-bert](https://github.com/kaushaltrivedi) that implements transformers as a dependency.  

When I passed a sentence on the rendered page, I received 

`"In get_config_dict raise EnvironmentError OSError"` 

and 

```
OSError: Can't load config for 'model/final_model'. Make sure that:
'path/to/final_model' is a correct model identifier listed on 'https://huggingface.co/models'
or 'path/to/final_model' is the correct path to a directory containing a config.json file
```
As suggested in certain threads, I re-installed the image with the latest transformers==3.3.1 release. 

However, I am unable to figure out the issue.

Kindly help. 

Similar to #6267 #5803 #7412 

![config_Error](https://user-images.githubusercontent.com/42617598/95229583-5e5b1280-081e-11eb-9a8b-e47a0f9131ab.png)




Comments:
This can happen if you're fetching a model from S3 but you have no internet access, or if you're using an incorrect URL to a local folder.

Hello @LysandreJik 

I have uploaded the saved model in a folder on my EC2 instance. Therefore, the location for the model is from the instance file directory which I have verified multiple times.

Also, the model functions properly when deployed using Flask over localhost. 

Do I need to download the pre-trained models as a command in the dockerfile? 

Kindly help.


This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.


I'm seeing the same issue on my community model

```
OSError: Can't load config for 'model_path'. Make sure that:

- 'model_path' is a correct model identifier listed on 'https://huggingface.co/models'

- or 'model_path' is the correct path to a directory containing a config.json file
```

I verified the model files are there. How can i work around this?

It would be helpful if you opened a new issue with everything related to your environment, as well as the code you use. Are you also on EC2? What is in the `model_path` folder? What is your `transformers` version? All that's asked in the template would be very helpful for us to help you.

@LysandreJik Thanks for the reply! I created a new issue https://github.com/huggingface/transformers/issues/9106. Other old huggingtweets models still work but not the new ones, not sure what the problem is.

> OSError: Can't load config for 'model_path'. Make sure that:
> 
> - 'model_path' is a correct model identifier listed on 'https://huggingface.co/models'

Hye I'm facing the same. Did you solve that ? 

I have the same error message. It also says that it can't find url"/resolve/main/config.json". I saved my model like they said but only have a folder "results" containing "pytorch_model.bin" and "training_args.bin".

Edit: I tried to also save the tokenizer (despite only having fine-tuned). This gave me a tokenizer_config.json which still isn't enough.

How do I get a config.json in my directory? I'm using a custom BERT modeled after BertForTokenClassification (https://huggingface.co/transformers/_modules/transformers/models/bert/modeling_bert.html#BertForTokenClassification) which doesn't specify a config attribute.

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.