Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: __init__() got an unexpected keyword argument 'mmap_mode' #3438

Closed
jnew123 opened this issue Mar 29, 2019 · 3 comments
Closed

TypeError: __init__() got an unexpected keyword argument 'mmap_mode' #3438

jnew123 opened this issue Mar 29, 2019 · 3 comments
Labels

Comments

@jnew123
Copy link

jnew123 commented Mar 29, 2019

I am implementing a normal mixture model in pymc3. It crashes if I don't specify the number of cores or if I use more than 1. the code generating the error is:

from matplotlib import pyplot as plt
import pymc3 as pm
import numpy as np
import theano.tensor as tt
from theano import shared

def test2():
	SEED = 383561
	np.random.seed(SEED) # from random.org, for reproducibility
	N = 1000
	W = np.array([0.35, 0.4, 0.25])	
	MU = np.array([0., 2., 5.])
	SIGMA = np.array([0.5, 0.5, 1.])
	component = np.random.choice(MU.size, size=N, p=W)
	x = np.random.normal(MU[component], SIGMA[component], size=N)
	idx_arr = []
	with pm.Model() as model:
		k = 10
		arr = []
		for j in range(k):
			arr.append(pm.Uniform('a'+str(j),lower=0,upper=0.99))#*pm.Bernoulli('ber'+str(j),p=berr))#*pm.DiscreteUniform('a'+str(j)+'d',lower=0,upper=1))

		w = pm.Dirichlet('w', a=tt.stack([arr[i] for i in range(k)]), shape=k)
		du = pm.DiscreteUniform('du',lower=0, upper=1,shape=k)
		
		idx_arr = []
		for i in range(k):
			if du[i]:
				idx_arr.append(i)

		mu = pm.Normal('mu', 0., 10., shape=k)
		tau = pm.Gamma('tau', 1., 1., shape=k)
		x_obs = pm.NormalMixture('x_obs', tt.stack([ w[h] for h in idx_arr ]), tt.stack([ mu[h] for h in idx_arr ]), tau=tt.stack([ tau[h] for h in idx_arr ]), observed=x)

	with model:	
		trace = pm.sample(3000,n_init=10000, tune=500, random_seed=SEED)[1000:]

	pm.traceplot(trace, varnames=['w', 'mu'])
	plt.show()
	pdb.set_trace()

test2()

Full traceback.

Multiprocess sampling (4 chains in 4 jobs)
CompoundStep
>Metropolis: [du]
>NUTS: [tau, mu, w, a9, a8, a7, a6, a5, a4, a3, a2, a1, a0]
Traceback (most recent call last):
  File "new_test.py", line 60, in <module>
    test2()
  File "new_test.py", line 53, in test2
    trace = pm.sample(10000)
  File "/usr/local/lib/python2.7/dist-packages/pymc3/sampling.py", line 439, in sample
    trace = _mp_sample(**sample_args)
  File "/usr/local/lib/python2.7/dist-packages/pymc3/sampling.py", line 1032, in _mp_sample
    traces = Parallel(n_jobs=cores, mmap_mode=None)(jobs)
TypeError: __init__() got an unexpected keyword argument 'mmap_mode'

Versions and main components

  • PyMC3 Version: 3.6
  • Theano Version: 1.0.4
  • Python Version: 2.7.16
  • Operating system: Ubuntu 14.04.3 LTS
  • How did you install PyMC3: pip
@ColCarroll
Copy link
Member

Python 2.7 is not supported (and I am surprised it got this far before crashing!) This branch of the code was removed last december.

It might be up to you to make the patch yourself, or maintain a 2.7 fork if you have no other options.

@jnew123
Copy link
Author

jnew123 commented Mar 29, 2019

Hi @ColCarroll , well actually I've the same code running in a different computer with Python 2.7.14 and works like a charm. Although in the computer (where it works) I have Ubuntu 14.04.5 LTS.

So where it doesn't work:
Python 2.7.16
Ubuntu 14.04.3 LTS

Where it works:
Python 2.7.14
Ubuntu 14.04.5 LTS

The trouble is that I need it to work in the computer where it doesn't work.
Any insights what might be the issue in case it is the version of Python?

@eigenfoo
Copy link
Member

eigenfoo commented Dec 5, 2019

Hi @jnew123, unfortunately we've already dropped Python 2.7 support for PyMC3 almost a year ago, and as much as we'd like to, we can't invest developer hours into supporting deprecated versions, irrespective of the platform it's being run on. In light of that, I'm labeling this as wontfix and closing this issue.

If this is still an issue for you, you could try asking your question on the PyMC discourse forum: perhaps other users have had the same problem as you. If push comes to shove, you could fork PyMC3 and patch it to maintain Python 2.7 support for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants