# A simple example But run very slow~

**URL:** <https://discourse.pymc.io/t/a-simple-example-but-run-very-slow/1358>\
**Category:** Questions\
**Created:** [June 12, 2018, 1:04am UTC](https://discourse.pymc.io/t/a-simple-example-but-run-very-slow/1358 "2018-06-12T01:04:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gaolei786](https://avatars.discourse-cdn.com/v4/letter/g/dbc845/32.png) [@gaolei786](https://discourse.pymc.io/u/gaolei786)\
**Post date:** [June 12, 2018, 1:04am UTC](https://discourse.pymc.io/t/a-simple-example-but-run-very-slow/1358/1 "2018-06-12T01:04:50Z")

</div>

![image](https://canada1.discourse-cdn.com/flex036/uploads/pymc3/original/1X/20ecc8406ef8212559da09af1f52a965632cfbf1.png)

Yesterday I install the pymc3.You see,the model is very simple,but the sampling is very very slow.

---

<div class="post-metadata">

**Author:** ![adam](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/adam/32/694_2.png) [@adam](https://discourse.pymc.io/u/adam)\
**Post date:** [June 12, 2018, 2:07am UTC](https://discourse.pymc.io/t/a-simple-example-but-run-very-slow/1358/2 "2018-06-12T02:07:59Z")

</div>

from my experience, the first time you run a model after installing theano and pymc3 might be slow. But subsequent times speed up.

---

<div class="post-metadata">

**Author:** ![Michal\_Oleszak](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/michal_oleszak/32/3606_2.png) [@Michal\_Oleszak](https://discourse.pymc.io/u/Michal_Oleszak)\
**Post date:** [January 26, 2021, 11:40pm UTC](https://discourse.pymc.io/t/a-simple-example-but-run-very-slow/1358/3 "2021-01-26T23:40:55Z")

</div>

I’m experiencing the same issue and I need my model to run quickly the first time I run it. Is there anything I could manually cache before running pm.sample() to make it faster? The issue is not the sampling itself, but rather what pymc3 is doing behind the hood before it even assigns the sampler.

I’ve tried running the model as a Python script right after installing all the packages in a fresh environment, but it did not help.

---

<div class="post-metadata">

**Author:** ![rosgori](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/rosgori/32/1077_2.png) [@rosgori](https://discourse.pymc.io/u/rosgori)\
**Post date:** [January 31, 2021, 2:08am UTC](https://discourse.pymc.io/t/a-simple-example-but-run-very-slow/1358/4 "2021-01-31T02:08:11Z")

</div>

I don’t think you can achieve that with PyMC3. PyMC3 uses Theano (renamed as [Aesara](https://github.com/pymc-devs/aesara)), which uses C. That means that the program you run needs to be compiled first in order to be used for sampling.

---

<div class="post-metadata">

**Author:** ![TimS](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/tims/32/3646_2.png) [@TimS](https://discourse.pymc.io/u/TimS)\
**Post date:** [February 11, 2021, 10:03am UTC](https://discourse.pymc.io/t/a-simple-example-but-run-very-slow/1358/5 "2021-02-11T10:03:09Z")

</div>

Is it PyMC3 that needs to compile or is it the model? Would it be possible to run each model once/ a few times so that its compiled to make sure it runs faster afterwards or is their no guarantee that once a model is compiled, it will always run faster/the compiled version will be used? Thank you in advance
