Sampling hangs with multiple cores

Hi

I was trying out some example code from another poster and ran into issues while sampling.

When I run the code with no arguments passed to .sample(), the sampling hangs, and I notice 4 files called core.XYZW are created in the same folder as my jupyter notebook. XYZW is some arbitrary integer sequence, e.g. core.2946

When I run the code with .sample(core=1), sampling runs fine.

Any ideas how to fix sampling with multiple cores? Here is the code

import numpy as np
import pymc3 as pm
import matplotlib.pyplot as lt
%matplotlib inline

# Specify number of individuals and covariates
n = 200
p = 2

# Create a fake dataset
true_x = np.random.randn(n,p)
true_intercept = 3
true_coefficients = np.asarray([1.,-2.])
y = true_intercept + np.dot(true_x,true_coefficients) + np.random.randn(n) * 0.1

# Create a mask to apply to fake dataset
mask = np.zeros([n,p],dtype=bool)
mask[0:5,0] = True
print('Missing values of x are:',true_x[0:5,0])
observed_x = np.ma.masked_array(data = true_x, mask=mask)

# Model with prior placed on 'x'
with pm.Model() as model:
    x = pm.Normal('x',observed = observed_x)
    intercept    = pm.Normal('intercept',sd=10)
    coefficients = pm.Normal('coefficients',sd=10,shape = p)
    mean = intercept + pm.math.dot(x,coefficients)
    response = pm.Normal('response',mu=mean,observed=y)

    trace = pm.sample() # changing to pm.sample(cores=1) solves issue, but only uses one core.

# Visualize posterior estimates of missing data
pm.plot_posterior(trace,varnames=['x_missing']

What OS are you on?

linux

Could you tell me if your problem has been solved? I’m having the same problem in the win7 environment, how do you solve the problem with multiple cores?

Hi,
On Windows I think you have to do pm.sample(cores=1), i.e you can’t use multiple cores.

thank you