"Compilation failed" on OS X Mojave

Hi all,

Thanks so much for your contributions to this package. I’m trying to get an up-to-date set of PyMC3+dependencies and hitting a snag. I’ve got:

theano == 1.1.2
pymc3 == 3.11.2

When I run a simple example trying to create a distribution, I get:

In [9]: with pm.Model() as m:
   ...:     x = pm.Uniform('x', lower=1, upper=2)
   ...:

You can find the C code in this temporary file: /var/folders/48/n6t36qp16gs3hhlpjwrwx5r80000gn/T/theano_compilation_error_j3wculte
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-9-6a33902fbf19> in <module>
      1 with pm.Model() as m:
----> 2     x = pm.Uniform('x', lower=1, upper=2)
      3

//anaconda3/lib/python3.7/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/lib/python3.7/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/lib/python3.7/site-packages/pymc3/distributions/continuous.py in __init__(self, lower, upper, *args, **kwargs)
    226         self.lower = lower = tt.as_tensor_variable(floatX(lower))
    227         self.upper = upper = tt.as_tensor_variable(floatX(upper))
--> 228         self.mean = (upper + lower) / 2.0
    229         self.median = self.mean
    230

//anaconda3/lib/python3.7/site-packages/theano/tensor/var.py in __add__(self, other)
     99     def __add__(self, other):
    100         try:
--> 101             return theano.tensor.basic.add(self, other)
    102         # We should catch the minimum number of exception here.
    103         # Otherwise this will convert error when Theano flags

//anaconda3/lib/python3.7/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/lib/python3.7/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/lib/python3.7/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/lib/python3.7/site-packages/theano/graph/op.py in make_c_thunk(self, node, storage_map, compute_map, no_recycling)
    599                 raise NotImplementedError("float16")
    600         outputs = cl.make_thunk(
--> 601             input_storage=node_input_storage, output_storage=node_output_storage
    602         )
    603         thunk, node_input_filters, node_output_filters = outputs

//anaconda3/lib/python3.7/site-packages/theano/link/c/basic.py in make_thunk(self, input_storage, output_storage, storage_map)
   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         )
   1206

//anaconda3/lib/python3.7/site-packages/theano/link/c/basic.py in __compile__(self, input_storage, output_storage, storage_map)
   1140             input_storage,
   1141             output_storage,
-> 1142             storage_map,
   1143         )
   1144         return (

//anaconda3/lib/python3.7/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/lib/python3.7/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/lib/python3.7/site-packages/theano/link/c/basic.py in compile_cmodule(self, location)
   1548                     lib_dirs=self.lib_dirs(),
   1549                     libs=libs,
-> 1550                     preargs=preargs,
   1551                 )
   1552             except Exception as e:

//anaconda3/lib/python3.7/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)
   2545             compile_stderr = compile_stderr.replace("\n", ". ")
   2546             raise Exception(
-> 2547                 f"Compilation failed (return status={status}): {compile_stderr}"
   2548             )
   2549         elif config.cmodule__compilation_warning and compile_stderr:

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{add,no_inplace}(TensorConstant{2.0}, TensorConstant{1.0}))')

Any tips? I’ve tried uninstalling and reinstalling pymc3 and theano a few times to no avail.

Thanks!

Do you have theano or theano-pymc? I’s recommend taking a look at Installation Guide (MacOS) · pymc-devs/pymc3 Wiki · GitHub

I’ve followed the instructions at this link by removing theano and theano-pymc and reinstalling them via conda forge, but I get the same error.

I was receiving the same error and reinstalled clang from my Anaconda environment to get it to work.