# HuggingFace offline error

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhuggingface-offline-error%2F89170%3E%5C
**Category:** Models\
**Created:** [May 29, 2024, 10:41am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhuggingface-offline-error%2F89170 "2024-05-29T10:41:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![andysg2211](https://avatars.discourse-cdn.com/v4/letter/a/3bc359/32.png) [@andysg2211](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fandysg2211)%5C
**Post date:** [May 29, 2024, 10:41am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhuggingface-offline-error%2F89170%2F1 "2024-05-29T10:41:10Z")

</div>

```auto
OSError: We couldn't connect to 'https://huggingface.co' to load this file, couldn't find it in the cached files and it looks like custom-model
 is not the path to a directory containing a file named config.json.
Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'.

```

I have ensure to set:

HUGGINGFACE\_HUB\_CACHE to the dir /models

inside /models:  
contains custom-model which is a folder containing:

blobs config.json refs snapshots

---

<div class="post-metadata">

**Author:** ![linlinlin](https://avatars.discourse-cdn.com/v4/letter/l/e9bcb4/32.png) [@linlinlin](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Flinlinlin)%5C
**Post date:** [October 17, 2024, 9:31am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhuggingface-offline-error%2F89170%2F2 "2024-10-17T09:31:16Z")

</div>

When using .from\_pretrained(), try to specify the param `trust_remote_code=True` and not to set `local_file_only=True`. In addition, set the HF\_ENDPOINT with ‘[https://hf-mirror.com](https://hf-mirror.com)’. For example:

```python
# Set the hub_cache dir
os.environ['HF_HOME'] = '/data/shared_models/'
# can also be done by 
# os.environ['TRANSFORMERS_CACHE'] = '/data/shared_models/'

# set mirror
os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'

# load model by model_id
model_id = "Qwen/Qwen2-72B-Instruct"
model = AutoModelForCausalLM.from_pretrained(
    model_name, 
    device_map="auto", 
    torch_dtype=torch.bfloat16, 
    trust_remote_code=True, # without specify local_file_only
)

```
