huggingface / transformers

đŸ¤— Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
https://huggingface.co/transformers
Apache License 2.0
134.72k stars 26.94k forks source link

OSError: file bert-base-uncased/config.json not found #10918

Closed pkuzengqi closed 3 years ago

pkuzengqi commented 3 years ago

Environment info

Information

The problem arises when using:

from transformers import BertModel
model = BertModel.from_pretrained('bert-base-uncased')

Error Info (Some personal info has been replaced by ---)

file bert-base-uncased/config.json not found
Traceback (most recent call last):
  File "---/anaconda3/envs/attn/lib/python3.6/site-packages/transformers-4.2.2-py3.8.egg/transformers/configuration_utils.py", line 420, in get_config_dict
  File "---/anaconda3/envs/attn/lib/python3.6/site-packages/transformers-4.2.2-py3.8.egg/transformers/file_utils.py", line 1063, in cached_path
OSError: file bert-base-uncased/config.json not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "---.py", line 107, in <module>
    from_pretrained_input()
  File "---.py", line 96, in from_pretrained_input
    model = BertModel.from_pretrained('bert-base-uncased')
  File "---/anaconda3/envs/attn/lib/python3.6/site-packages/transformers-4.2.2-py3.8.egg/transformers/modeling_utils.py", line 962, in from_pretrained
  File "---/anaconda3/envs/attn/lib/python3.6/site-packages/transformers-4.2.2-py3.8.egg/transformers/configuration_utils.py", line 372, in from_pretrained
  File "---/anaconda3/envs/attn/lib/python3.6/site-packages/transformers-4.2.2-py3.8.egg/transformers/configuration_utils.py", line 432, in get_config_dict
OSError: Can't load config 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 config.json file

what I have read:

https://github.com/huggingface/transformers/issues/353

what I have tried:

  1. loading from a downloaded model file works well
wget https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-uncased.tar.gz

unzip the file and rename bert_config.json as config.json, then

model = BertModel.from_pretrained(BERT_BASE_UNCASED_CACHE)
  1. enough disk space, enough memory, free GPU

  2. open internet connection, no proxy

  3. import pytorch_pretrained_bert as ppb
    assert 'bert-large-cased' in ppb.modeling.PRETRAINED_MODEL_ARCHIVE_MAP
  4. The following models work well

    
    model = BertModel.from_pretrained('bert-base-cased')

model = RobertaModel.from_pretrained('roberta-base')



6. working well in server cmd but not in local pycharm (remote deployment to server)

Observation: 
- Pycharm can found the ```transfromers``` installed with pip, but that will trigger this problem 
- Pycharm cannot find the current  ```transformers```  installed with conda 
```conda install transformers=4.4 -n env -c huggingface```
theainerd commented 3 years ago

I'm also facing the same issue. Did you find any fix yet . ??

github-actions[bot] commented 3 years ago

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 are likely to be ignored.

stepbystep88 commented 3 years ago

I'm also facing the same issue. Did you guys find any fix yet . ??

github-actions[bot] commented 3 years ago

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 are likely to be ignored.

VlaDanilov commented 3 years ago

Same problem here, please write if someone found a valid solution.

thak123 commented 3 years ago

Facing same error

github-actions[bot] commented 3 years ago

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 are likely to be ignored.

vildhet commented 3 years ago

Hi, I've had the same error but with roberta-base. It appeared that I had an empty folder named roberta-base in my working directory. Removing it solved the issue.

leoliu0 commented 3 years ago

I found this issue is caused by setting cache directory using checkpoint name TrainingArguments(checkpoint,evaluation_strategy='steps')

change checkpoint to something else resolve the issue

github-actions[bot] commented 3 years ago

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 are likely to be ignored.

vikas95 commented 2 years ago

353

Got the same issue, thanks for reporting it here. Was able to fix it following after going through your comment.

3ricchen commented 9 months ago

Hi, I've had the same error but with roberta-base. It appeared that I had an empty folder named roberta-base in my working directory. Removing it solved the issue.

You are literally an angel.