huggingface / transformers

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

`local_files_only=True` not work #18623

Closed huchinlp closed 2 years ago

huchinlp commented 2 years ago

System Info

torch 1.12.1 transformers 4.21.1

Who can help?

No response

Information

Tasks

Reproduction

I have downloaded the pretrained weights and the model worked well. I am confused by the long loading time (~25s on a SSD) when using the from_pretrained API, and I set local_files_only=True to disable connections. But I still found the function called a http request and it spent many seconds on my desktop without Internet. Here is my log file:

File "/disk1/fewshot/anaconda3/envs/pet/lib/python3.9/site-packages/transformers/utils/hub.py", line 284, in cached_path output_path = get_from_cache( File "/disk1/fewshot/anaconda3/envs/pet/lib/python3.9/site-packages/transformers/utils/hub.py", line 501, in get_from_cache r = requests.head(url, headers=headers, allow_redirects=False, proxies=proxies, timeout=etag_timeout)

Expected behavior

When set local_files_only=True, it should disable connections to the website.

beyondguo commented 1 year ago

how did you solve it?