GP marginal likelihood - Theano compilation error

Hi, I am trying to run one of the tutorials exercises on Gaussian Process regression, and I am getting a compilation error from theano.

Some useful data for context:

  • Python version: 3.8.3
  • Pymc3 version: 3.8
  • Theano version: 1.0.4
  • numpy version: 1.18.5
  • OS: Windows 10 Home 64bit
  • CPU: Intel i5-1035G7
  • Installation mode: From conda (using conda install pymc3)

The code I am running is extracted from here, and I copy it down here:

import pymc3 as pm
import theano as tt
import numpy as np
import scipy as sp
import pandas as pd
import matplotlib.pyplot as plt

# set the seed
np.random.seed(1)
n = 100 # The number of data points
X = np.linspace(0, 10, n)[:, None] # The inputs to the GP, they must be arranged as a column vector

# Define the true covariance function and its parameters
l_true = 1.0
eta_true = 3.0
cov_func = eta_true**2 * pm.gp.cov.Matern52(1, l_true)

# A mean function that is zero everywhere
mean_func = pm.gp.mean.Zero()

# The latent function values are one sample from a multivariate normal
# Note that we have to call `eval()` because PyMC3 built on top of Theano
f_true = np.random.multivariate_normal(mean_func(X).eval(),
                            cov_func(X).eval() + 1e-8*np.eye(n), 1).flatten()

# The observed data is the latent function plus a small amount of IID Gaussian noise
# The standard deviation of the noise is `sigma`
s_true = 2.0
y = f_true + s_true * np.random.randn(n)

## Plot the data and the unobserved latent function
fig = plt.figure(figsize=(12,5)); ax = fig.gca()
ax.plot(X, f_true, "dodgerblue", lw=3, label="True f")
ax.plot(X, y, 'ok', ms=3, alpha=0.5, label="Data")
ax.set_xlabel("X"); ax.set_ylabel("The true f(x)"); plt.legend()

# GP Regression
with pm.Model() as model:
    l = pm.Gamma("l", alpha=2, beta=1)
    eta = pm.HalfCauchy("eta", beta=5)
    cov = eta**2 * pm.gp.cov.Matern52(1, l)
    gp = pm.gp.Marginal(cov_func=cov)
    sigma = pm.HalfCauchy("sigma", beta=5)

    y_ = gp.marginal_likelihood("y", X=X, y=y, noise=sigma)

    mp = pm.find_MAP(cores=1)

I am getting the following error:

    y_ = gp.marginal_likelihood("y", X=X, y=y, noise=sigma)
  File "C:\Users\maria\anaconda3\lib\site-packages\pymc3\gp\gp.py", line 424, in marginal_likelihood
    return pm.MvNormal(name, mu=mu, cov=cov, observed=y, **kwargs)
  File "C:\Users\maria\anaconda3\lib\site-packages\pymc3\distributions\distribution.py", line 47, in __new__      
    return model.Var(name, dist, data, total_size)
  File "C:\Users\maria\anaconda3\lib\site-packages\pymc3\model.py", line 950, in Var
    var = ObservedRV(name=name, data=data,
  File "C:\Users\maria\anaconda3\lib\site-packages\pymc3\model.py", line 1488, in __init__
    self.logp_elemwiset = distribution.logp(data)
  File "C:\Users\maria\anaconda3\lib\site-packages\pymc3\distributions\multivariate.py", line 315, in logp        
    quaddist, logdet, ok = self._quaddist(value)
  File "C:\Users\maria\anaconda3\lib\site-packages\pymc3\distributions\multivariate.py", line 98, in _quaddist    
    dist, logdet, ok = self._quaddist_cov(delta)
  File "C:\Users\maria\anaconda3\lib\site-packages\pymc3\distributions\multivariate.py", line 123, in _quaddist_cov
    return self._quaddist_chol(delta)
  File "C:\Users\maria\anaconda3\lib\site-packages\pymc3\distributions\multivariate.py", line 112, in _quaddist_chol
    ok = tt.all(diag > 0)
  File "C:\Users\maria\anaconda3\lib\site-packages\theano\tensor\var.py", line 64, in __gt__
    rval = theano.tensor.basic.gt(self, other)
  File "C:\Users\maria\anaconda3\lib\site-packages\theano\gof\op.py", line 669, in __call__
    thunk = node.op.make_thunk(node, storage_map, compute_map,
  File "C:\Users\maria\anaconda3\lib\site-packages\theano\gof\op.py", line 954, in make_thunk
    return self.make_c_thunk(node, storage_map, compute_map,
  File "C:\Users\maria\anaconda3\lib\site-packages\theano\gof\op.py", line 857, in make_c_thunk
    outputs = cl.make_thunk(input_storage=node_input_storage,
  File "C:\Users\maria\anaconda3\lib\site-packages\theano\gof\cc.py", line 1215, in make_thunk
    cthunk, module, in_storage, out_storage, error_storage = self.__compile__(
  File "C:\Users\maria\anaconda3\lib\site-packages\theano\gof\cc.py", line 1153, in __compile__
    thunk, module = self.cthunk_factory(error_storage,
  File "C:\Users\maria\anaconda3\lib\site-packages\theano\gof\cc.py", line 1623, in cthunk_factory
    module = get_module_cache().module_from_key(
  File "C:\Users\maria\anaconda3\lib\site-packages\theano\gof\cmodule.py", line 1189, in module_from_key
    module = lnk.compile_cmodule(location)
  File "C:\Users\maria\anaconda3\lib\site-packages\theano\gof\cc.py", line 1520, in compile_cmodule
    module = c_compiler.compile_str(
  File "C:\Users\maria\anaconda3\lib\site-packages\theano\gof\cmodule.py", line 2398, in compile_str
    raise Exception('Compilation failed (return status=%s): %s' %
Exception: ('Compilation failed (return status=1): C:\\Users\\maria\\AppData\\Local\\Temp\\ccXBaGzI.s: Assembler messages:\r. C:\\Users\\maria\\AppData\\Local\\Temp\\ccXBaGzI.s:101: Error: invalid register for .seh_savexmm\r. ', '[Elemwise{gt,no_inplace}(<TensorType(float64, vector)>, <TensorType(int8, (True,))>)]')

I have seen this issue in other topics around the web, although haven’t found a clear or robust answer. Thanks!

I suspect your code is OK, but maybe something happened with your install? Do other non-GP pymc3 programs run? What C compiler are you using?

I have ran some basic linear regressions without problem (as long as I use only one core). I haven’t tried much more than that honestly. I can try some other tutorial examples and check this.

I have installed a g++ (x86_64-posix-seh, Built by strawberryperl.com) 8.3.0. The GNU version is 8.2.1.

Although I am not a 100% that this is the only compiler in my computer, and the one being used by theano.

Hi Mariano,
Yes, I think that on Windows you have to set cores=1 when sampling

2 Likes