"Connection error, and we cannot find the requested files in the cached path." 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.
Author: keloemma
Pull request: no

## Environment info
<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->

## Environment info
<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->

- `transformers` version: 4.4.2
- Platform:
- Python version: 3.7.6
- PyTorch version (GPU?): torch                             1.5.0
- Tensorflow version (GPU?):
- Using GPU in script?: no ( I just mentionned the number of gpu in a shell script and launch (ex . #SBATCH --partition=gpu_p2; #SBATCH --qos=qos_gpu-dev ; #SBATCH --cpus-per-task=3 )
- Using distributed or parallel set-up in script?: no 
### Who can help

- albert, bert, xlm: @LysandreJik

Library:
- tokenizers: @LysandreJik
- pipelines: @LysandreJik

Documentation: @sgugger

Model I am using (FlauBERT):

The problem arises when downloading the model from transformers library:
* [ ] the official example scripts: (I did not change much , pretty close to the original)

```
def get_flaubert_layer(texte):

	modelname ='flaubert-small-cased'
	
	flaubert, log = FlaubertModel.from_pretrained(modelname, output_loading_info=True)
	flaubert_tokenizer = FlaubertTokenizer.from_pretrained(modelname, do_lowercase=False)
	tokenized = texte.apply((lambda x: flaubert_tokenizer.encode(x, add_special_tokens=True)))
	max_len = 0
	for i in tokenized.values:
		if len(i) > max_len:
			max_len = len(i)
	padded = np.array([i + [0] * (max_len - len(i)) for i in tokenized.values])
	token_ids = torch.tensor(padded)
	with torch.no_grad():
		last_layer = flaubert(token_ids)[0][:,0,:].numpy()
		
	return last_layer, modelname

### What I added to the code 
def read_file(filename):

	sentences = pd.read_excel(filename, sheet_name= 0)
	data_id = sentences.identifiant
	print("Total phrases: ", len(data_id))
	data = sentences.verbatim
	data_label = sentences.etiquette
	classes = sentences['etiquette'].unique()
	len_classes = len(classes)
	return data_id, data, data_label, len_classes

def cross_validation_prediction(id_, texte, ylabels, file_, len_classes):
	
	features, modelname = get_flaubert_layer(texte)
```
The tasks I am working on is:
* [ ] my own task or dataset: I just want to use the model of FlauBert to producve vectors for my dataset that's all 

## To reproduce

Steps to reproduce the behavior:

1. get the requirements (librairies mentionned above)
2. Final part of the script to reproduce it : 
```
filename = 'test'
fil = filename + ".xlsx"
os.chdir('/linkhome/rech/genlig01/umg16uw/Test_CLASS_avec_FlauBert/corpus')
print("File preprocessing: " , fil)
id_, texte_, ylabels_, len_classes_ = read_file(fil)
cross_validation_prediction(id_, texte_, ylabels_, filename, len_classes_)	

```
3. stack trace error :
```
Loading pytorch-gpu/py3/1.5.0
  Loading requirement: cuda/10.1.2 nccl/2.5.6-2-cuda cudnn/10.1-v7.5.1.10
    gcc/8.2.0 intel-compilers/19.0.4 openmpi/4.0.1-cuda
Traceback (most recent call last):
  File "test.py", line 227, in <module>
    cross_validation_prediction(id_, texte_, ylabels_, filename, len_classes_)	
  File "test.py", line 107, in cross_validation_prediction
    features, modelname = get_flaubert_layer(texte)
  File "test.py", line 56, in get_flaubert_layer
    flaubert, log = FlaubertModel.from_pretrained(modelname, output_loading_info=True)
  File "/gpfslocalsup/pub/anaconda-py3/2020.02/envs/pytorch-gpu-1.5.0/lib/python3.7/site-packages/transformers/modeling_utils.py", line 986, in from_pretrained
    **kwargs,
  File "/gpfslocalsup/pub/anaconda-py3/2020.02/envs/pytorch-gpu-1.5.0/lib/python3.7/site-packages/transformers/configuration_utils.py", line 386, in from_pretrained
    config_dict, kwargs = cls.get_config_dict(pretrained_model_name_or_path, **kwargs)
  File "/gpfslocalsup/pub/anaconda-py3/2020.02/envs/pytorch-gpu-1.5.0/lib/python3.7/site-packages/transformers/configuration_utils.py", line 438, in get_config_dict
    use_auth_token=use_auth_token,
  File "/gpfslocalsup/pub/anaconda-py3/2020.02/envs/pytorch-gpu-1.5.0/lib/python3.7/site-packages/transformers/file_utils.py", line 1142, in cached_path
    local_files_only=local_files_only,
  File "/gpfslocalsup/pub/anaconda-py3/2020.02/envs/pytorch-gpu-1.5.0/lib/python3.7/site-packages/transformers/file_utils.py", line 1349, in get_from_cache
    "Connection error, and we cannot find the requested files in the cached path."
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.
srun: error: jean-zay-ia808: task 0: Exited with exit code 1
srun: Terminating job step 841126.0
```


I expected the model to load and get the vectors in the appropriate varaible, instead Iget this error above.
I have internet and when trying to do it locally and not on the server with small sample it works but when I load a vritual env with the specific library I get this error;

Comments:
Pinging @stas00 since I see in your stack trace you are working on jean-zay and I know Stas has some experience with it.

@keloemma, please have a look at the special offline mode https://huggingface.co/transformers/installation.html#offline-mode - if your gpu instance is firewalled (which is the case on JZ) it explains how to solve this problem.

@sgugger, I'm thinking the installation doc is not quite the right place for the offline mode feature. Somehow I'd never think to look there. Could you think of a better placement?

Also perhaps we should start a troubleshooting doc like we had @ fastai with pointers to solutions based on symptoms? So this could be the first entry.

I wouldn't remove the doc for offline feature from the installation page, but we can certainly duplicate it elsewhere. Why not in the `main_classes/model` apge since it has the from_pretrained method?

We can also start a troubleshooting document, that's also helpful.

Thank you for this feedback, @sgugger - I will do both.

https://github.com/huggingface/transformers/pull/11236

@stas00  Hello and thank you for your response. I have just a question, 

#Setting environment variable TRANSFORMERS_OFFLINE=1 will tell 🤗 Transformers to use local files only and will not try to look things up"
=> if I understand , this means that I have to save locally FlauBert model size on a specific directory in the local and then provided the path to that directory in my original script and then I set the variable as mentionned in the doc; 

so I should have something like this :   

HF_DATASETS_OFFLINE=1 TRANSFORMERS_OFFLINE=1 \
srun python test.py --model_name_or_path t5-small ( path is already written in the script "test.py)



If I understand correctly the instructions aren't too clear, right?

So you run in your login shell that is not firewalled:
```
cd /path/to/transformers
python examples/seq2seq/run_translation.py --model_name_or_path t5-small --dataset_name wmt16 --dataset_config ro-en ...
```

then for example let's do an interactive session with  `srun`, e.g.:
```
srun --pty --ntasks=1 --cpus-per-task=10 --gres=gpu:2 --hint=nomultithread --time=60 bash
```
which opens a new interactive bash shell on the gpu instance, and then you repeat exactly the same command, but this time with 2 env vars:
```
cd /path/to/transformers
HF_DATASETS_OFFLINE=1 TRANSFORMERS_OFFLINE=1 \
python examples/seq2seq/run_translation.py --model_name_or_path t5-small --dataset_name wmt16 --dataset_config ro-en ...
```
Of course, you will need to figure out to load the right `modules`, etc., to get the desired environment. But I trust you have already done so.

It should work exactly the same with the non-interactive shell if you use `sbatch`.

Bottom line: do the same thing as you normally do, but the key here is to first to launch the script in your login shell (no gpus!) so that it would download the model and the dataset files. You don't need to let the script complete - it will take forever since you're running on CPU, but just the first batch is enough since by that time all files would be downloaded.

Please let me know if this helped and if it did how can I improve the documentation to make it easier to understand.

> HF_DATASETS_OFFLINE=1 TRANSFORMERS_OFFLINE=1
> srun python test.py --model_name_or_path t5-small ( path is already written in the script "test.py)

I suppose you could try that as well, I haven't tried, I would start a bash shell via `srun` and then start the script from there. Since this is what you'd do if you were to use SLURM normally  via `sbatch`.


@stas00 Thank you for your clear explanation, I will try all that and tell you back what works

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.