Connection error, and we cannot find the requested files in the cached path
Author: yanan1116
Pull request: no

transformers ver: 4.8.2
torch: 1.9.1 

the `pipeline` method does not offer cache_dir option. Therefore, users can only cache the model in default path.
```
from transformers import pipeline
nli_nlp = pipeline("zero-shot-classification", model="facebook/bart-large-mnli", device=0)
```

This happens randomly, with the same code on the same machine.
> ---------------------------------------------------------------------------
> ValueError                                Traceback (most recent call last)
> <ipython-input-1-e362258c0296> in <module>
>       1 from transformers import pipeline
> ----> 2 nli_nlp = pipeline("zero-shot-classification", model="facebook/bart-large-mnli", device=0)
> 
> /usr/local/lib/python3.6/dist-packages/transformers/pipelines/__init__.py in pipeline(task, model, config, tokenizer, feature_extractor, framework, revision, use_fast, use_auth_token, model_kwargs, **kwargs)
>     441
>     442             tokenizer = AutoTokenizer.from_pretrained(
> --> 443                 tokenizer_identifier, revision=revision, use_fast=use_fast, _from_pipeline=task, **tokenizer_kwargs
>     444             )
>     445
> 
> /usr/local/lib/python3.6/dist-packages/transformers/models/auto/tokenization_auto.py in from_pretrained(cls, pretrained_model_name_or_path, *inputs, **kwargs)
>     561             tokenizer_class_py, tokenizer_class_fast = TOKENIZER_MAPPING[type(config)]
>     562             if tokenizer_class_fast and (use_fast or tokenizer_class_py is None):
> --> 563                 return tokenizer_class_fast.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs)
>     564             else:
>     565                 if tokenizer_class_py is not None:
> 
> /usr/local/lib/python3.6/dist-packages/transformers/tokenization_utils_base.py in from_pretrained(cls, pretrained_model_name_or_path, *init_inputs, **kwargs)
>    1678                         local_files_only=local_files_only,
>    1679                         use_auth_token=use_auth_token,
> -> 1680                         user_agent=user_agent,
>    1681                     )
>    1682
> 
> /usr/local/lib/python3.6/dist-packages/transformers/file_utils.py in cached_path(url_or_filename, cache_dir, force_download, proxies, resume_download, user_agent, extract_compressed_file, force_extract, use_auth_token, local_files_only)
>    1335             user_agent=user_agent,
>    1336             use_auth_token=use_auth_token,
> -> 1337             local_files_only=local_files_only,
>    1338         )
>    1339     elif os.path.exists(url_or_filename):
> 
> /usr/local/lib/python3.6/dist-packages/transformers/file_utils.py in get_from_cache(url, cache_dir, force_download, proxies, etag_timeout, resume_download, user_agent, use_auth_token, local_files_only)
>    1551                 else:
>    1552                     raise ValueError(
> -> 1553                         "Connection error, and we cannot find the requested files in the cached path."
>    1554                         " Please try again or make sure your Internet connection is on."
>    1555                     )
> 
> ValueError: Connection error, and we cannot find the requested files in the cached path. Please try again or make sure your Internet connection is on.


For reference, this codes below never break down.
```
from transformers import GPT2Tokenizer, GPT2LMHeadModel
gpt2 = GPT2LMHeadModel.from_pretrained('gpt2', cache_dir="./cache", local_files_only=True)
```

It seems that the first snippet need to download models, or configs from the internet.

Any way to fix this ?


Comments:
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.