# Transformers cache not loading from a new vm

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftransformers-cache-not-loading-from-a-new-vm%2F111329%3E%5C
**Category:** 🤗Transformers\
**Created:** [October 11, 2024, 5:44am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftransformers-cache-not-loading-from-a-new-vm%2F111329 "2024-10-11T05:44:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jainhitesh9998](https://avatars.discourse-cdn.com/v4/letter/j/7ab992/32.png) [@jainhitesh9998](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjainhitesh9998)%5C
**Post date:** [October 11, 2024, 5:44am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftransformers-cache-not-loading-from-a-new-vm%2F111329%2F1 "2024-10-11T05:44:12Z")

</div>

We have setup an aws ec2 instance and initialized [https://huggingface.co/Qwen/Qwen2-VL-7B-Instruct](https://huggingface.co/Qwen/Qwen2-VL-7B-Instruct) and [mistralai/Pixtral-12B-2409 · Hugging Face](https://huggingface.co/mistralai/Pixtral-12B-2409) models.

when we create ami from these vm and create new instance, the transformers library isn’t able to load the pretrained models.

When i delete .cache in newly created instances, then it’s able to download and load models.

is it an expected beahaviour? as the instance configuration is exactly the same

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [October 11, 2024, 8:00am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftransformers-cache-not-loading-from-a-new-vm%2F111329%2F2 "2024-10-11T08:00:16Z")

</div>

The symptoms are different but the problem could be similar to this.

> [@"No space left on device" when using HuggingFace + SageMaker](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fno-space-left-on-device-when-using-huggingface-sagemaker%2F5406)%3A
>
> Hi, I’m trying to train a model using a HuggingFace estimator in SageMaker but I keep getting this error after a few minutes: [1,15]: File “pyarrow/ipc.pxi”, line 365, in pyarrow.lib.\_CRecordBatchWriter.write\_batch [1,15]: File “pyarrow/error.pxi”, line 97, in pyarrow.lib.check\_status [1,15]:OSError: [Errno 28] Error writing bytes to file. Detail: [errno 28] No space left on device [1,15]: I’m not sure what is triggering this problem because the volume size is high (volume\_size=1024) …

---

<div class="post-metadata">

**Author:** ![jainhitesh9998](https://avatars.discourse-cdn.com/v4/letter/j/7ab992/32.png) [@jainhitesh9998](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjainhitesh9998)%5C
**Post date:** [October 11, 2024, 10:19am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftransformers-cache-not-loading-from-a-new-vm%2F111329%2F3 "2024-10-11T10:19:26Z")

</div>

Space doesn’t seem to be issue , I have enough free space on vm. The moment I delete .cache it redownloads and starts working.

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [October 11, 2024, 10:22am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftransformers-cache-not-loading-from-a-new-vm%2F111329%2F4 "2024-10-11T10:22:16Z")

</div>

> Your error is coming from caching the dataset. Datasets is caching the dataset on disk to work with it properly. The default cache\_dir is `~/.cache/huggingface/datasets`. This directory seems not to be on the mounted EBS volume.

I think it’s not that way, it’s around here.

---

<div class="post-metadata">

**Author:** ![jainhitesh9998](https://avatars.discourse-cdn.com/v4/letter/j/7ab992/32.png) [@jainhitesh9998](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjainhitesh9998)%5C
**Post date:** [October 11, 2024, 10:35am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftransformers-cache-not-loading-from-a-new-vm%2F111329%2F5 "2024-10-11T10:35:50Z")

</div>

I’m not trying to cache dataset, it’s just model weights and the ami has the weights in the root for itself. The primary purpose is to boot the process as fast as possible

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [October 11, 2024, 10:39am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftransformers-cache-not-loading-from-a-new-vm%2F111329%2F6 "2024-10-11T10:39:33Z")

</div>

Perhaps unresolved issue?

> <https://github.com/huggingface/transformers/issues/29178>
>
> \### System Info
> 
> I am ubuntu, torch = "2.0.0"
> 
> The following code always re-do…wnload the models instead of re-using the cached files:
> 
> \` adapter = T2IAdapter.from\_pretrained("TencentARC/t2i-adapter-canny-sdxl-1.0",
> torch\_dtype=torch.float16, 
> varient="fp16").to(accelerator.device)
> 
> model\_id = 'stabilityai/stable-diffusion-xl-base-1.0'
> logger.info(f"model loading..")
> euler\_a = EulerAncestralDiscreteScheduler.from\_pretrained(model\_id, subfolder="scheduler")
> logger.info(f"model loading...")
> vae = AutoencoderKL.from\_pretrained("madebyollin/sdxl-vae-fp16-fix", torch\_dtype=torch.float16)
> 
> logger.info(f"model loading....")
> pipe = StableDiffusionXLAdapterPipeline.from\_pretrained(
> model\_id,
> vae=vae,
> adapter=adapter,
> scheduler=euler\_a,
> torch\_dtype=torch.float16,
> variant="fp16"
> ).to(accelerator.device)
> pipe.enable\_xformers\_memory\_efficient\_attention()
> logger.info(f"model weights loading")
> pipe.load\_lora\_weights(
> "stabilityai/stable-diffusion-xl-base-1.0", weight\_name="sd\_xl\_offset\_example-lora\_1.0.safetensors"
> )\`
>       
> I also tried with the \`cache\_dir\` param but same result.  
>         
> \<img width="1377" alt="Screenshot 2024-02-21 at 11 32 22 AM" src="https://github.com/huggingface/transformers/assets/13439477/562c4f1e-b033-4c03-883b-9dcf3b6a579a"\>
> 
>         
>         
> 
> \### Who can help?
> 
> \_No response\_
> 
> \### Information
> 
> \- \[\] The official example scripts
> \- \[\] My own modified scripts
> 
> \### Tasks
> 
> \- \[\] An officially supported task in the \`examples\` folder (such as GLUE/SQuAD, ...)
> \- \[\] My own task or dataset (give details below)
> 
> \### Reproduction
> 
> \` adapter = T2IAdapter.from\_pretrained("TencentARC/t2i-adapter-canny-sdxl-1.0",
> torch\_dtype=torch.float16, 
> varient="fp16").to(accelerator.device)
> 
> model\_id = 'stabilityai/stable-diffusion-xl-base-1.0'
> logger.info(f"model loading..")
> euler\_a = EulerAncestralDiscreteScheduler.from\_pretrained(model\_id, subfolder="scheduler")
> logger.info(f"model loading...")
> vae = AutoencoderKL.from\_pretrained("madebyollin/sdxl-vae-fp16-fix", torch\_dtype=torch.float16)
> 
> logger.info(f"model loading....")
> pipe = StableDiffusionXLAdapterPipeline.from\_pretrained(
> model\_id,
> vae=vae,
> adapter=adapter,
> scheduler=euler\_a,
> torch\_dtype=torch.float16,
> variant="fp16"
> ).to(accelerator.device)
> pipe.enable\_xformers\_memory\_efficient\_attention()
> logger.info(f"model weights loading")
> pipe.load\_lora\_weights(
> "stabilityai/stable-diffusion-xl-base-1.0", weight\_name="sd\_xl\_offset\_example-lora\_1.0.safetensors"
> )\`
> 
> \### Expected behavior
> 
> use the cached models/files and not download any files from the internet

I wonder if it’s possible to avoid this by manually clearing the cache before execution.

> **[Manage huggingface\_hub cache-system](https://huggingface.co/docs/huggingface_hub/guides/manage-cache)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

---

<div class="post-metadata">

**Author:** ![jainhitesh9998](https://avatars.discourse-cdn.com/v4/letter/j/7ab992/32.png) [@jainhitesh9998](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjainhitesh9998)%5C
**Post date:** [October 11, 2024, 10:49am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftransformers-cache-not-loading-from-a-new-vm%2F111329%2F7 "2024-10-11T10:49:30Z")

</div>

I have seen this issue in the GitHub issues

I’m not facing this , but in my case it starts loading weights and remains stuck at 0% when I spin up new instance
