# Pymc3 getting stuck after initialization

**URL:** <https://discourse.pymc.io/t/pymc3-getting-stuck-after-initialization/2535>\
**Category:** Questions\
**Created:** [January 16, 2019, 2:44pm UTC](https://discourse.pymc.io/t/pymc3-getting-stuck-after-initialization/2535 "2019-01-16T14:44:56Z")\
**Posts on this page:** 1\
**Showing post:** 38

<div class="post-metadata">

**Author:** ![lucianopaz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/lucianopaz/32/2186_2.png) [@lucianopaz](https://discourse.pymc.io/u/lucianopaz)\
**Post date:** [January 28, 2019, 9:32am UTC](https://discourse.pymc.io/t/pymc3-getting-stuck-after-initialization/2535/38 "2019-01-28T09:32:54Z")

</div>

Thanks for the code and data @jordan.howell2. However, I still can’t reproduce your error ☹. Your code runs fine (after adding an `if __name__ == " __main__"`) across multiple cores using the pymc3’s master branch on my machine. I think that you must be running into an installation issue or maybe `theano` finding another c compiler (and python headers) instead of the one you installed through conda.

I would try uninstalling theano, pymc3, pygpu and running:

```auto
conda install numpy scipy mkl-service libpython m2w64-toolchain
conda install theano pygpu
conda install pymc3

```

As a side note, my only change to your script was adding an `if __name__ == " __main__":` before sampling:

```python
with pm.Model() as sales_model:
    # define the priors
    mu_a = pm.Normal('mu_a', mu=0, sd=10)
    sigma_a = pm.HalfCauchy('sigma_a', 5)
    # mu_d = pm.Normal('mu_d', mu = 0, sd = 10)
    # sigma_d = pm.HalfCauchy('sigma_d', 5)

    alpha = pm.Normal('intercept', mu=mu_a, sd=sigma_a, shape=n_dept)
    beta_2 = pm.Normal('IsHoliday_T', mu=0, sd=20)
    beta_3 = pm.Normal('Week', mu=0, sd=20)

    s = pm.HalfCauchy('sd', 5)

    # define the likelihood
    mu = alpha[dept_idx] + beta_2 * train['IsHoliday_True'].values + beta_3 * train['Week'].values

    y = pm.StudentT('sales', nu=5, mu=mu, sd=s
                    , observed=train['Weekly_Sales'], shape=train['Weekly_Sales'].shape)

if __name__ == " __main__":
    with sales_model:
        trace = pm.sample(draws=5000, init='advi', progressbar=True)
        print(sales_model.check_test_point())
        trace_plot = pm.traceplot(trace[1000:], grid=True)
        ppc = pm.plot_posterior(trace[1000:])
        summary = pm.summary(trace)
        posterior = pm.trace_to_dataframe(trace)

```

---

_[View the full topic](https://discourse.pymc.io/t/pymc3-getting-stuck-after-initialization/2535)._
