When ever I tried running NUTS sampling my notebook gets disconnected from kernel


Hi I am Trying to run below code:
This code perfectly working on 8gb ram and i7 processor laptop (it was slow but it worked)
Now I am trying to run this code on my new laptop with same installation of anaconda and jupyter notebook. laptop config is 16gb ram and i7 processor . But this time my notebook gets disconnected from kernel.

Here is my code:

g1 = df.groupby('i_away')
att_starting_points = np.log(g1['away_team/goals'].fillna(0).mean())
g2 = df.groupby('i_home')
def_starting_points = -np.log(g2['home_team/goals'].fillna(0).mean())

with pm.Model() as model:
# global model priors: standard deviation and intercept
home = pm.Flat('home') #flat pdf is uninformative - means we have no idea
sd_att = pm.HalfStudentT('sd_att', nu=3, sd=2.5)
sd_def = pm.HalfStudentT('sd_def', nu=3, sd=2.5)
intercept = pm.Flat('intercept')

# team-specific model parameters
atts_star = pm.Normal("atts_star", mu=0, sd=sd_att, shape=num_teams)
defs_star = pm.Normal("defs_star", mu=0, sd=sd_def, shape=num_teams)

# To allow samples of expressions to be saved, we need to wrap them in pymc3 Deterministic objects
atts = pm.Deterministic('atts', atts_star - tt.mean(atts_star))
defs = pm.Deterministic('defs', defs_star - tt.mean(defs_star))

# Assume exponential search on home_theta and away_theta. With pymc3, need to rely on theano.
# tt is theano.tensor.. why Sampyl may be easier to use..
home_theta = tt.exp(intercept + home + atts[home_team] + defs[away_team])  
away_theta = tt.exp(intercept + atts[away_team] + defs[home_team])

# likelihood of observed data
home_points = pm.Poisson('home_points', mu=home_theta, observed=observed_home_goals)
away_points = pm.Poisson('away_points', mu=away_theta, observed=observed_away_goals)
with model:
trace = pm.sample(1000, tune=1000, cores=2)

Even if I do 10 samples it will still crash.

Versions and main components
PyMC3 Version: PyMC3 v3.4.1

Theano Version:

pygpu: 0.7.6-py36_0 mila-udem
pymc3: 3.4.1-py36_0
theano: 1.0.2-py36_0 mila-udem

Python Version: python 3.6

Operating system: windows 10

How did you install PyMC3: (conda/pip): conda
conda install pymc3


I replied to you on Github as well, but in case you didnt see it:
Please try upgrade to master branch of PyMC3 - this might be fixed on master.
Alternatively, try setting cores=1 - pickling is sometimes also the source of the problem.

  • Hi i tried the core 1 solution it dosent work. I will try to upgrade to master branch .

how can i upgrade to master using conda

will this upgrade it to master

conda install -c conda-forge pymc3


I think the only way is to use pip:

pip3 install git+https://github.com/pymc-devs/pymc3@master


@junpenglao Thank you so much . That solved the issue.