huggingface / transformers

🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
https://huggingface.co/transformers
Apache License 2.0
134.57k stars 26.91k forks source link

FileNotFoundError: [Errno 2] No such file or directory: 'cached_train_BertTokenizer_180.lock' #8959

Closed Stimmot closed 3 years ago

Stimmot commented 3 years ago

I want to train the model bert-base-german-cased on some documents, but when I try to run run_ner.py with the config.json it tells me, that it can't find the file mentioned above. I don't quite know what's the issue here, because it worked the last time I tried. Do I have to tell the model it shouldn't use any cached files? I tried that with the overwrite_cache flag. Does anyone have a clue what could be the problem?

LysandreJik commented 3 years ago

Hi! Could you provide the information related to your environment, as well as the command that you used to launch the script, as it's requested in the issue template? Thank you.

Stimmot commented 3 years ago

Yes sure!

Model I am using: BERT, specifically "bert-base-german-cased"

The problem arises when using:

The tasks I am working on is:

Traceback: `Traceback (most recent call last): File "run_ner.py", line 324, in main() File "run_ner.py", line 187, in main TokenClassificationDataset( File "/home/IAIS/tschmude/bert_remote/examples/token-classification/utils_ner.py", line 240, in init with FileLock(lock_path): File "/home/IAIS/tschmude/anaconda3/envs/bert_env_remote/lib/python3.8/site-packages/filelock.py", line 323, in enter self.acquire() File "/home/IAIS/tschmude/anaconda3/envs/bert_env_remote/lib/python3.8/site-packages/filelock.py", line 271, in acquire self._acquire() File "/home/IAIS/tschmude/anaconda3/envs/bert_env_remote/lib/python3.8/site-packages/filelock.py", line 384, in _acquire fd = os.open(self._lock_file, open_mode) FileNotFoundError: [Errno 2] No such file or directory: '/home/tschmude/PycharmProjects/smart-sentencing/examples/token-classification/Data processing scripts/Data_Preprocessed/cached_train_BertTokenizer_180.lock'

Expected behavior

I'm running python run_ner.py Data/config.json to train the model for custom NER recognition. I have a couple self defined labels. It has worked before, but I can't quite tell what has changed since then. I already deleted cached .lock files that I could find.

LysandreJik commented 3 years ago

Would you mind providing the config.json as well, given that it contains your launch command? Thank you!

Stimmot commented 3 years ago

Sure, this is my config.json:

{ "data_dir": "/home/tschmude/PycharmProjects/smart-sentencing/examples/token-classification/Data processing scripts/Data_Preprocessed", "labels": "./Data/labels.txt", "model_name_or_path": "bert-base-german-cased", "output_dir": "./Data/Models", "task_type": "NER", "max_seq_length": 180, "num_train_epochs": 6, "per_device_train_batch_size": 48, "learning_rate": 0.001, "seed": 1, "overwrite_cache": true, "fp16": true, "do_train": true, "do_predict": true, "do_eval": true }

Stimmot commented 3 years ago

Issue solved... it had to do with a dumb typo in the path, sorry for the confusion!

LysandreJik commented 3 years ago

No problem, glad you solved your issue!