# Inference takes too long the first time

**URL:** <https://discuss.roboflow.com/t/inference-takes-too-long-the-first-time/7152>\
**Category:** 🤝  Community Help\
**Created:** [September 27, 2024, 8:26pm UTC](https://discuss.roboflow.com/t/inference-takes-too-long-the-first-time/7152 "2024-09-27T20:26:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Crisaq](https://avatars.discourse-cdn.com/v4/letter/c/bc79bd/32.png) [@Crisaq](https://discuss.roboflow.com/u/Crisaq)\
**Post date:** [September 27, 2024, 8:26pm UTC](https://discuss.roboflow.com/t/inference-takes-too-long-the-first-time/7152/1 "2024-09-27T20:26:33Z")

</div>

Hi, I am using the Roboflow Hosted API to deploy a Workflow but everytime I run the code for the first time after a while I either get a 500 error response or it takes around 20-30 seconds to infer. After that, any new run takes around 3 seconds, doesn´t matter if I change the image, which is okay. But I am wondering why it takes too long the first time, is it normal? My code is exactly as it is in the documentation.  
I also tried running the inference server locally and I have the same issue. I have a 4060 GPU and after the first run that takes some time (one time I waited like 3 minutes) all other runs take like 3 seconds. I would like to know if anyone has this same issue or if is not an issue and that is just how it works.

---

<div class="post-metadata">

**Author:** ![Jacob\_Witt](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/jacob_witt/32/347_2.png) [@Jacob\_Witt](https://discuss.roboflow.com/u/Jacob_Witt)\
**Post date:** [September 27, 2024, 8:52pm UTC](https://discuss.roboflow.com/t/inference-takes-too-long-the-first-time/7152/2 "2024-09-27T20:52:13Z")

</div>

Hi @Crisaq: in both cases we need to load the Workflow and the models used within, I would expect some delay on the first request.

In the case of the 4060 it might be poor internet connection? I can check but 3 minutes sounds like far too long.

---

<div class="post-metadata">

**Author:** ![Jacob\_Witt](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/jacob_witt/32/347_2.png) [@Jacob\_Witt](https://discuss.roboflow.com/u/Jacob_Witt)\
**Post date:** [September 27, 2024, 10:02pm UTC](https://discuss.roboflow.com/t/inference-takes-too-long-the-first-time/7152/3 "2024-09-27T22:02:08Z")

</div>

@Crisaq - one other thing, if you are using models like SAM or Florence, those are quite large models (several GB) that need to get loaded.

---

<div class="post-metadata">

**Author:** ![Crisaq](https://avatars.discourse-cdn.com/v4/letter/c/bc79bd/32.png) [@Crisaq](https://discuss.roboflow.com/u/Crisaq)\
**Post date:** [September 28, 2024, 12:34am UTC](https://discuss.roboflow.com/t/inference-takes-too-long-the-first-time/7152/4 "2024-09-28T00:34:20Z")

</div>

That makes sense then, is usually not an issue but I was wondering if I was the only one since I couldn´t find anything about it.  
In the other case I believe I was using a Workflow with both Florence and SAM so may be the long wait makes sense.  
Thank you very much for your answers!

---

<div class="post-metadata">

**Author:** ![Jacob\_Witt](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/jacob_witt/32/347_2.png) [@Jacob\_Witt](https://discuss.roboflow.com/u/Jacob_Witt)\
**Post date:** [September 30, 2024, 1:53pm UTC](https://discuss.roboflow.com/t/inference-takes-too-long-the-first-time/7152/5 "2024-09-30T13:53:43Z")

</div>

One thing that might help is our [Dedicated Deployments](https://docs.roboflow.com/roboflow-cli/dedicated-deployments) functionality that lets you spin up a GPU pre-configured with your workflow. It will still have that early delay, but then will stay “warm” as you need it.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex029/uploads/roboflow1/original/1X/bb6edbfa56d0cf2ee603f061e9e09103502cc8cc.png) [@system](https://discuss.roboflow.com/u/system)\
**Post date:** [October 21, 2024, 1:54pm UTC](https://discuss.roboflow.com/t/inference-takes-too-long-the-first-time/7152/6 "2024-10-21T13:54:11Z")

</div>

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
