# Load model from cache or disk not working

**URL:** <https://discuss.huggingface.co/t/load-model-from-cache-or-disk-not-working/19541>\
**Category:** 🤗Transformers\
**Created:** [June 23, 2022, 5:35pm UTC](https://discuss.huggingface.co/t/load-model-from-cache-or-disk-not-working/19541 "2022-06-23T17:35:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![s0ap](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@s0ap](https://discuss.huggingface.co/u/s0ap)\
**Post date:** [June 23, 2022, 5:35pm UTC](https://discuss.huggingface.co/t/load-model-from-cache-or-disk-not-working/19541/1 "2022-06-23T17:35:04Z")

</div>

Library versions in my conda environment:  
pytorch == 1.10.2  
tokenizers == 0.10.1  
transformers == 4.6.1 (cannot really upgrade due to a GLIB lib issue on linux)

I am trying to load a model and tokenizer - ProsusAI/finbert (already cached on disk by an earlier run in ~/.cache/huggingface/transformers/) using the transformers/tokenizers library, on a machine with no internet access.

However, when I try to load up the model using the below command, it throws up a connection error:

```auto
model = AutoModelForSequenceClassification.from_pretrained("ProsusAI/finbert", local_files_only=True)
tokenizer = AutoTokenizer.from_pretrained("ProsusAI/finbert", local_files_only=True)

```

However I still get the error: 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.

So, then, I download all model files from [here](https://huggingface.co/ProsusAI/finbert/tree/main) and tried loading the model from that directory using the below command:

```auto
model = AutoModelForSequenceClassification.from_pretrained("./PATH_TO_FILES/", local_files_only=True)
tokenizer = AutoTokenizer.from_pretrained("./PATH_TO_FILES/", local_files_only=True)

```

This throws the same error I got above. This error persists on setting the environment variable to offline mode by

```auto
os.environ["TRANSFORMERS_OFFLINE"] = "1"

```

Is there a way to really load models from cache if I don’t have access to internet on the machine?

Thanks!

---

<div class="post-metadata">

**Author:** ![Kontrabas](https://avatars.discourse-cdn.com/v4/letter/k/fbc32d/32.png) [@Kontrabas](https://discuss.huggingface.co/u/Kontrabas)\
**Post date:** [October 16, 2022, 11:56am UTC](https://discuss.huggingface.co/t/load-model-from-cache-or-disk-not-working/19541/2 "2022-10-16T11:56:53Z")

</div>

@s0ap, have you managed to solve your problem?
