Exception: ('Compilation failed (return status=1)... error after installing PyMC3 for the first time (original) (raw)

I’m completely new to PyMC and this exception occurred after installing for the first time (with Anaconda) and trying to execute this basic example script.

System: Mac OS X 10.14.6

Steps taken to install:

conda create --name pymc python=3.9
conda activate pymc
conda install -c conda-forge pymc3
conda install ipython
ipython

Code entered into iPython console (note the warning after the first statement) and the full exception details:

Python 3.9.1 | packaged by conda-forge | (default, Jan 10 2021, 02:52:42) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.19.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import pymc3 as pm
WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions.

In [2]: import numpy as np

In [3]: RANDOM_SEED = 8927
   ...: np.random.seed(RANDOM_SEED)

In [4]: # True parameter values
   ...: alpha, sigma = 1, 1
   ...: beta = [1, 2.5]
   ...: 
   ...: # Size of dataset
   ...: size = 100
   ...: 
   ...: # Predictor variable
   ...: X1 = np.random.randn(size)
   ...: X2 = np.random.randn(size) * 0.2
   ...: 
   ...: # Simulate outcome variable
   ...: Y = alpha + beta[0] * X1 + beta[1] * X2 + np.random.randn(size) * sigma

In [5]: basic_model = pm.Model()

In [6]: with basic_model:
   ...: 
   ...:     # Priors for unknown model parameters
   ...:     alpha = pm.Normal("alpha", mu=0, sigma=10)
   ...:     beta = pm.Normal("beta", mu=0, sigma=10, shape=2)
   ...:     sigma = pm.HalfNormal("sigma", sigma=1)
   ...: 
   ...:     # Expected value of outcome
   ...:     mu = alpha + beta[0] * X1 + beta[1] * X2
   ...: 
   ...:     # Likelihood (sampling distribution) of observations
   ...:     Y_obs = pm.Normal("Y_obs", mu=mu, sigma=sigma, observed=Y)
   ...: 

You can find the C code in this temporary file: /var/folders/y3/28pc8qrx3dd36zwcys8z1rzc0000gn/T/theano_compilation_error_ykos32pu
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-6-b30e265ab1ff> in <module>
      2 
      3     # Priors for unknown model parameters
----> 4     alpha = pm.Normal("alpha", mu=0, sigma=10)
      5     beta = pm.Normal("beta", mu=0, sigma=10, shape=2)
      6     sigma = pm.HalfNormal("sigma", sigma=1)

/anaconda3/envs/pymc/lib/python3.9/site-packages/pymc3/distributions/distribution.py in __new__(cls, name, *args, **kwargs)
    119             dist = cls.dist(*args, **kwargs, shape=shape)
    120         else:
--> 121             dist = cls.dist(*args, **kwargs)
    122         return model.Var(name, dist, data, total_size, dims=dims)
    123 

/anaconda3/envs/pymc/lib/python3.9/site-packages/pymc3/distributions/distribution.py in dist(cls, *args, **kwargs)
    128     def dist(cls, *args, **kwargs):
    129         dist = object.__new__(cls)
--> 130         dist.__init__(*args, **kwargs)
    131         return dist
    132 

/anaconda3/envs/pymc/lib/python3.9/site-packages/pymc3/distributions/continuous.py in __init__(self, mu, sigma, tau, sd, **kwargs)
    487 
    488         self.mean = self.median = self.mode = self.mu = mu = tt.as_tensor_variable(floatX(mu))
--> 489         self.variance = 1.0 / self.tau
    490 
    491         assert_negative_support(sigma, "sigma", "Normal")

/anaconda3/envs/pymc/lib/python3.9/site-packages/theano/tensor/var.py in __rtruediv__(self, other)
    174 
    175     def __rtruediv__(self, other):
--> 176         return theano.tensor.basic.true_div(other, self)
    177 
    178     def __rfloordiv__(self, other):

/anaconda3/envs/pymc/lib/python3.9/site-packages/theano/graph/op.py in __call__(self, *inputs, **kwargs)
    251 
    252         if config.compute_test_value != "off":
--> 253             compute_test_value(node)
    254 
    255         if self.default_output is not None:

/anaconda3/envs/pymc/lib/python3.9/site-packages/theano/graph/op.py in compute_test_value(node)
    124 
    125     # Create a thunk that performs the computation
--> 126     thunk = node.op.make_thunk(node, storage_map, compute_map, no_recycling=[])
    127     thunk.inputs = [storage_map[v] for v in node.inputs]
    128     thunk.outputs = [storage_map[v] for v in node.outputs]

/anaconda3/envs/pymc/lib/python3.9/site-packages/theano/graph/op.py in make_thunk(self, node, storage_map, compute_map, no_recycling, impl)
    632             )
    633             try:
--> 634                 return self.make_c_thunk(node, storage_map, compute_map, no_recycling)
    635             except (NotImplementedError, MethodNotDefined):
    636                 # We requested the c code, so don't catch the error.

/anaconda3/envs/pymc/lib/python3.9/site-packages/theano/graph/op.py in make_c_thunk(self, node, storage_map, compute_map, no_recycling)
    598                 print(f"Disabling C code for {self} due to unsupported float16")
    599                 raise NotImplementedError("float16")
--> 600         outputs = cl.make_thunk(
    601             input_storage=node_input_storage, output_storage=node_output_storage
    602         )

/anaconda3/envs/pymc/lib/python3.9/site-packages/theano/link/c/basic.py in make_thunk(self, input_storage, output_storage, storage_map)
   1201         """
   1202         init_tasks, tasks = self.get_init_tasks()
-> 1203         cthunk, module, in_storage, out_storage, error_storage = self.__compile__(
   1204             input_storage, output_storage, storage_map
   1205         )

/anaconda3/envs/pymc/lib/python3.9/site-packages/theano/link/c/basic.py in __compile__(self, input_storage, output_storage, storage_map)
   1136         input_storage = tuple(input_storage)
   1137         output_storage = tuple(output_storage)
-> 1138         thunk, module = self.cthunk_factory(
   1139             error_storage,
   1140             input_storage,

/anaconda3/envs/pymc/lib/python3.9/site-packages/theano/link/c/basic.py in cthunk_factory(self, error_storage, in_storage, out_storage, storage_map)
   1632             for node in self.node_order:
   1633                 node.op.prepare_node(node, storage_map, None, "c")
-> 1634             module = get_module_cache().module_from_key(key=key, lnk=self)
   1635 
   1636         vars = self.inputs + self.outputs + self.orphans

/anaconda3/envs/pymc/lib/python3.9/site-packages/theano/link/c/cmodule.py in module_from_key(self, key, lnk)
   1189             try:
   1190                 location = dlimport_workdir(self.dirname)
-> 1191                 module = lnk.compile_cmodule(location)
   1192                 name = module.__file__
   1193                 assert name.startswith(location)

/anaconda3/envs/pymc/lib/python3.9/site-packages/theano/link/c/basic.py in compile_cmodule(self, location)
   1541             try:
   1542                 _logger.debug(f"LOCATION {location}")
-> 1543                 module = c_compiler.compile_str(
   1544                     module_name=mod.code_hash,
   1545                     src_code=src_code,

/anaconda3/envs/pymc/lib/python3.9/site-packages/theano/link/c/cmodule.py in compile_str(module_name, src_code, location, include_dirs, lib_dirs, libs, preargs, py_module, hide_symbols)
   2544             # difficult to read.
   2545             compile_stderr = compile_stderr.replace("\n", ". ")
-> 2546             raise Exception(
   2547                 f"Compilation failed (return status={status}): {compile_stderr}"
   2548             )

Exception: ('Compilation failed (return status=1): ld: unknown option: -platform_version. clang-11: error: linker command failed with exit code 1 (use -v to see invocation). ', 'FunctionGraph(Elemwise{true_div,no_inplace}(TensorConstant{1.0}, TensorConstant{0.01}))')

Also, for info:

In [7]: import theano

In [8]: theano.__version__
Out[8]: '1.1.0'