Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running with local models from the hugging face .cache #2

Open
piekvossen opened this issue Oct 18, 2021 · 2 comments
Open

Running with local models from the hugging face .cache #2

piekvossen opened this issue Oct 18, 2021 · 2 comments

Comments

@piekvossen
Copy link
Contributor

Running with local models does not work even though the models are in the hugging face .cache:

/Users/piek/.cache/huggingface/transformers

E.g. there is. json file with the following info:

{"url": "https://huggingface.co/CLTL/icf-domains/resolve/main/special_tokens_map.json", "etag": ""e97d1993365bb21c88f390e8703e4c1af564821f"”}%

docker run -v /Users/piek/Desktop/r-COVID-19-TM/CovidHerstelZorg-ZonMW/data -e TRANSFORMERS_OFFLINE=1 piekvossen/a-proof-icf-classifier --in_csv example/input.csv --text_col text

Error message is below:

Loading input csv file: example/input.csv
Input csv file (example/input.csv) is successfuly loaded!
Anonymizing the text in "text" column. This might take a while.
Splitting the text in "text" column to sentences. This might take a while.
Generating domains predictions. This might take a while.
CUDA device not available; running on a CPU!
Cannot find the requested files in the cached path and outgoing traffic has been disabled. To enable model look-ups and downloads online, set 'local_files_only' to False.
Downloading the model from https://huggingface.co/CLTL/icf-domains
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/transformers/configuration_utils.py", line 546, in get_config_dict
resolved_config_file = cached_path(
File "/usr/local/lib/python3.8/site-packages/transformers/file_utils.py", line 1402, in cached_path
output_path = get_from_cache(
File "/usr/local/lib/python3.8/site-packages/transformers/file_utils.py", line 1620, in get_from_cache
raise FileNotFoundError(
FileNotFoundError: Cannot find the requested files in the cached path and outgoing traffic has been disabled. To enable model look-ups and downloads online, set 'local_files_only' to False.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "./main.py", line 154, in
main(
File "./main.py", line 121, in main
sents['predictions'] = predict_domains(
File "/icfc/src/icf_classifiers.py", line 49, in predict_domains
model = MultiLabelClassificationModel(
File "/usr/local/lib/python3.8/site-packages/simpletransformers/classification/multi_label_classification_model.py", line 194, in init
self.config = config_class.from_pretrained(model_name, **self.args.config)
File "/usr/local/lib/python3.8/site-packages/transformers/configuration_utils.py", line 489, in from_pretrained
config_dict, kwargs = cls.get_config_dict(pretrained_model_name_or_path, **kwargs)
File "/usr/local/lib/python3.8/site-packages/transformers/configuration_utils.py", line 570, in get_config_dict
raise EnvironmentError(msg)
OSError: Can't load config for 'CLTL/icf-domains'. Make sure that:

  • 'CLTL/icf-domains' is a correct model identifier listed on 'https://huggingface.co/models'

  • or 'CLTL/icf-domains' is the correct path to a directory containing a config.json file

@sandertan
Copy link
Contributor

sandertan commented Oct 18, 2021

Hi @piekvossen , if the above command is the one you executed, I think it's missing the -v parameter to mount your local cache directory to the container's cache dir. Could you try:

docker run \
  -v /Users/piek/.cache/huggingface/transformers:/root/.cache/huggingface/transformers/ \
  -e TRANSFORMERS_OFFLINE=1 \
  piekvossen/a-proof-icf-classifier --in_csv example/input.csv --text_col text

It's possible to mount multiple directories, so you can add a -v to also mount a custom data folder.

@piekvossen
Copy link
Contributor Author

piekvossen commented Oct 18, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants