# Model loading gets stuck when calling "from\_pretrained"

**URL:** <https://discuss.huggingface.co/t/model-loading-gets-stuck-when-calling-from-pretrained/112807>\
**Category:** 🤗Transformers\
**Created:** [October 19, 2024, 1:10pm UTC](https://discuss.huggingface.co/t/model-loading-gets-stuck-when-calling-from-pretrained/112807 "2024-10-19T13:10:23Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yiveen](https://avatars.discourse-cdn.com/v4/letter/y/a5b964/32.png) [@Yiveen](https://discuss.huggingface.co/u/Yiveen)\
**Post date:** [October 19, 2024, 1:10pm UTC](https://discuss.huggingface.co/t/model-loading-gets-stuck-when-calling-from-pretrained/112807/1 "2024-10-19T13:10:23Z")

</div>

Hi, when I use the GroundingDino from the huggingface, the model loading is always got stuck when calling the “from\_pretrained(model\_id)”. The issue happens today and before I have not met this kind of issue and the loading process is normal.

I tried to switch different version of “transformers” library and also deleted the local downloaded files for several times. But all of these don’t work. I also tried this on another machine, this weird issue will not happen. Could you please give me some suggestions to solve this?

The code I used is from the official repo:

```auto
import requests
import torch
from PIL import Image
from transformers import AutoProcessor, AutoModelForZeroShotObjectDetection 

model_id = "IDEA-Research/grounding-dino-base"
device = "cuda" if torch.cuda.is_available() else "cpu"

processor = AutoProcessor.from_pretrained(model_id)
model = AutoModelForZeroShotObjectDetection.from_pretrained(model_id).to(device)

image_url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(image_url, stream=True).raw)

```

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [October 21, 2024, 11:21pm UTC](https://discuss.huggingface.co/t/model-loading-gets-stuck-when-calling-from-pretrained/112807/2 "2024-10-21T23:21:46Z")

</div>

It is a really strange problem. I don’t see anything particularly odd in your code or in the repo.  
The last commit to this model repo was in May, and I don’t think it has anything to do with the problem.  
Do you get the same symptoms with other models?

> **[IDEA-Research/grounding-dino-base · Hugging Face](https://huggingface.co/IDEA-Research/grounding-dino-base)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

---

<div class="post-metadata">

**Author:** ![andrstercorp](https://avatars.discourse-cdn.com/v4/letter/a/a587f6/32.png) [@andrstercorp](https://discuss.huggingface.co/u/andrstercorp)\
**Post date:** [February 13, 2025, 8:25am UTC](https://discuss.huggingface.co/t/model-loading-gets-stuck-when-calling-from-pretrained/112807/3 "2025-02-13T08:25:39Z")

</div>

I’m getting the same exact issue, for Grounding DINO, did you find a solution?

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [February 13, 2025, 8:51am UTC](https://discuss.huggingface.co/t/model-loading-gets-stuck-when-calling-from-pretrained/112807/4 "2025-02-13T08:51:07Z")

</div>

This will fix the mild symptoms…

```auto
pip install -U huggingface_hub

```

---

<div class="post-metadata">

**Author:** ![andrstercorp](https://avatars.discourse-cdn.com/v4/letter/a/a587f6/32.png) [@andrstercorp](https://discuss.huggingface.co/u/andrstercorp)\
**Post date:** [February 13, 2025, 10:29am UTC](https://discuss.huggingface.co/t/model-loading-gets-stuck-when-calling-from-pretrained/112807/5 "2025-02-13T10:29:56Z")

</div>

hm, didn’t seem to work I’m still getting stuck.

Sample code:

```auto
import torch
from transformers import AutoModelForMaskGeneration, AutoModelForZeroShotObjectDetection, AutoProcessor

print('starting')
dino_processor = AutoProcessor.from_pretrained("IDEA-Research/grounding-dino-base")
dino_model = AutoModelForZeroShotObjectDetection.from_pretrained("IDEA-Research/grounding-dino-base").to('cuda')
print('done')

```

I am using `Poetry` for package handling and `huggingface_hub` was upgraded to version `0.28.1`

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [February 13, 2025, 10:48am UTC](https://discuss.huggingface.co/t/model-loading-gets-stuck-when-calling-from-pretrained/112807/6 "2025-02-13T10:48:30Z")

</div>

I tried it now and got this error…

> **[IDEA-Research/grounding-dino-base · Could not load the custom kernel](https://huggingface.co/IDEA-Research/grounding-dino-base/discussions/4)**
>
> environment: Centos 7.6 cuda:11.4. torch:2.0.1 transformers:4.41.0.dev0

---

<div class="post-metadata">

**Author:** ![andrstercorp](https://avatars.discourse-cdn.com/v4/letter/a/a587f6/32.png) [@andrstercorp](https://discuss.huggingface.co/u/andrstercorp)\
**Post date:** [February 13, 2025, 10:59am UTC](https://discuss.huggingface.co/t/model-loading-gets-stuck-when-calling-from-pretrained/112807/7 "2025-02-13T10:59:41Z")

</div>

What’s your torch and transformers version? Mine are:

```auto
torch: 2.4.0+cu121
transformers: 4.48.1

```

EDIT: HF doesn’t let me reply because I’m a new user. Anyhow, the PR fixing the issue was merged with the main branch 🤔

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [February 13, 2025, 11:01am UTC](https://discuss.huggingface.co/t/model-loading-gets-stuck-when-calling-from-pretrained/112807/8 "2025-02-13T11:01:26Z")

</div>

This.

```auto
torch 2.4.0+cu124
transformers 4.48.3

```

And I found a similar issue.

> <https://github.com/huggingface/transformers/issues/30765>
>
> \### System Info
> 
> Latest including master as of 5/11/24
> Ubuntu, 4090 GPU
> 
> \### Wh…o can help?
> 
> @amyeroberts 
> 
> \### Information
> 
> \- \[X\] The official example scripts
> \- \[\] My own modified scripts
> 
> \### Tasks
> 
> \- \[\] An officially supported task in the \`examples\` folder (such as GLUE/SQuAD, ...)
> \- \[X\] My own task or dataset (give details below)
> 
> \### Reproduction
> 
> When running any GroundingDINO model you get the following. I have confirmed the kernels do not exist in the transformers repo:
> \`\`\`
> Could not load the custom kernel for multi-scale deformable attention: \[Errno 2\] No such file or directory: '/.../transformers-main/src/transformers/kernels/grounding\_dino/vision.cpp'".
> Could not load the custom kernel for multi-scale deformable attention: \[Errno 2\] No such file or directory: '.../transformers-main/src/transformers/kernels/grounding\_dino/vision.cpp'".
> \`\`\`
> 
> \### Expected behavior
> 
> Either the kernels are not necessary and should be removed or they are necessary and causing performance issues. GroundingDINO does seem to under perform in transformers but this is purely anecdotal

Could there be a problem with this class…? =\> AutoModelForZeroShotObjectDetection

---

<div class="post-metadata">

**Author:** ![Yiveen](https://avatars.discourse-cdn.com/v4/letter/y/a5b964/32.png) [@Yiveen](https://discuss.huggingface.co/u/Yiveen)\
**Post date:** [February 13, 2025, 12:41pm UTC](https://discuss.huggingface.co/t/model-loading-gets-stuck-when-calling-from-pretrained/112807/9 "2025-02-13T12:41:49Z")

</div>

Hi, I solve this issue by re-installing my conda environment from scratch. I guess it might due to some library conflicts.

---

<div class="post-metadata">

**Author:** ![lziiid](https://avatars.discourse-cdn.com/v4/letter/l/e56c9b/32.png) [@lziiid](https://discuss.huggingface.co/u/lziiid)\
**Post date:** [February 22, 2025, 7:27am UTC](https://discuss.huggingface.co/t/model-loading-gets-stuck-when-calling-from-pretrained/112807/10 "2025-02-22T07:27:36Z")

</div>

I’m getting the exact same problems ☹ May I know what version your transformers and pytorch are?

---

<div class="post-metadata">

**Author:** ![Dzmitry-P](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/dzmitry-p/32/55085_2.png) [@Dzmitry-P](https://discuss.huggingface.co/u/Dzmitry-P)\
**Post date:** [October 23, 2025, 10:37am UTC](https://discuss.huggingface.co/t/model-loading-gets-stuck-when-calling-from-pretrained/112807/11 "2025-10-23T10:37:41Z")

</div>

Try to downgrade to `ipykernel==6.30.1`. Link to the [bug report](https://github.com/huggingface/xet-core/issues/526#issuecomment-3401504858).

```python
# Downgrade to `ipykernel==6.30.1` to fix the following error:
# ERROR Python exception updating progress:, error: PyErr ...
pip install ipykernel==6.30.1

```
