# PyMC3 fresh install yielding theano errors (linux)

**URL:** https://discourse.pymc.io/t/pymc3-fresh-install-yielding-theano-errors-linux/8304
**Category:** Questions
**Created:** [November 9, 2021, 2:13pm UTC](https://discourse.pymc.io/t/pymc3-fresh-install-yielding-theano-errors-linux/8304 "2021-11-09T14:13:22Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![luisroque](https://avatars.discourse-cdn.com/v4/letter/l/7c8e57/32.png) [@luisroque](https://discourse.pymc.io/u/luisroque)
#### Post date: [November 9, 2021, 2:13pm UTC](https://discourse.pymc.io/t/pymc3-fresh-install-yielding-theano-errors-linux/8304/1 "2021-11-09T14:13:22Z")

</div>

Hi,

I have Ubuntu 20.04.2 and I’ve freshly installed anaconda. Created a new env with python 3.9.7 and have installed pymc3 from conda-forge (version 3.11.2). Also, theano-pymc is of version 1.1.2.

By simply running:

```auto
import numpy as np
import pymc3 as pm
n = 2000 
ℓ_true = 1.0
η_true = 3.0
X = 10 * np.sort(np.random.rand(n))[:, None]
cov_func = η_true ** 2 * pm.gp.cov.Matern52(1, ℓ_true)
cov_func(X).eval()

```

I get the following errors from Theano:

> **Error Message**
>
> ```auto
> ERROR (theano.graph.opt): Optimization failure due to: constant_folding
> ERROR (theano.graph.opt): node: Elemwise{sqr,no_inplace}(TensorConstant{[0.0196731...9937537]})
> ERROR (theano.graph.opt): TRACEBACK:
> ERROR (theano.graph.opt): Traceback (most recent call last):
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/graph/opt.py", line 2017, in process_node
> replacements = lopt.transform(fgraph, node)
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/graph/opt.py", line 1209, in transform
> return self.fn(*args, **kwargs)
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/tensor/opt.py", line 7006, in constant_folding
> thunk = node.op.make_thunk(
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/graph/op.py", line 634, in make_thunk
> return self.make_c_thunk(node, storage_map, compute_map, no_recycling)
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/graph/op.py", line 600, in make_c_thunk
> outputs = cl.make_thunk(
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/link/c/basic.py", line 1203, in make_thunk
> cthunk, module, in_storage, out_storage, error_storage = self. __compile__ (
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/link/c/basic.py", line 1138, in __compile__
> thunk, module = self.cthunk_factory(
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/link/c/basic.py", line 1634, in cthunk_factory
> module = get_module_cache().module_from_key(key=key, lnk=self)
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/link/c/cmodule.py", line 1191, in module_from_key
> module = lnk.compile_cmodule(location)
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/link/c/basic.py", line 1543, in compile_cmodule
> module = c_compiler.compile_str(
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/link/c/cmodule.py", line 2546, in compile_str
> raise Exception(
> Exception: ('Compilation failed (return status=1): /home/mach1ne/.theano/compiledir_Linux-5.4--generic-x86_64-with-glibc2.31-x86_64-3.9.7-64/tmpt5oy_621/mod.cpp: In member function ‘int {anonymous}::__struct_compiled_op_m2854c5ace9f246bece6011cae4f888e7193a8c5d824856d0d9390f42e972c8f1::run()’:. /home/mach1ne/.theano/compiledir_Linux-5.4--generic-x86_64-with-glibc2.31-x86_64-3.9.7-64/tmpt5oy_621/mod.cpp:353:60: error: expected primary-expression before ‘{’ token. 353 | #pragma omp parallel for if(n>={int(config.openmp_elemwise_minsize)}). | ^. At global scope:. cc1plus: warning: unrecognized command line option ‘-Wno-c++11-narrowing’. ', 'FunctionGraph(Elemwise{sqr,no_inplace}(TensorConstant{[0.0196731...9937537]}))')
> 
> [...]
> 
> You can find the C code in this temporary file: /tmp/theano_compilation_error_146puztd
> 
> ERROR (theano.graph.opt): Optimization failure due to: constant_folding
> ERROR (theano.graph.opt): node: Elemwise{sqr,no_inplace}(TensorConstant{[0.0196731...9937537]})
> ERROR (theano.graph.opt): TRACEBACK:
> ERROR (theano.graph.opt): Traceback (most recent call last):
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/graph/opt.py", line 2017, in process_node
> replacements = lopt.transform(fgraph, node)
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/graph/opt.py", line 1209, in transform
> return self.fn(*args, **kwargs)
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/tensor/opt.py", line 7006, in constant_folding
> thunk = node.op.make_thunk(
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/graph/op.py", line 634, in make_thunk
> return self.make_c_thunk(node, storage_map, compute_map, no_recycling)
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/graph/op.py", line 600, in make_c_thunk
> outputs = cl.make_thunk(
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/link/c/basic.py", line 1203, in make_thunk
> cthunk, module, in_storage, out_storage, error_storage = self. __compile__ (
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/link/c/basic.py", line 1138, in __compile__
> thunk, module = self.cthunk_factory(
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/link/c/basic.py", line 1634, in cthunk_factory
> module = get_module_cache().module_from_key(key=key, lnk=self)
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/link/c/cmodule.py", line 1191, in module_from_key
> module = lnk.compile_cmodule(location)
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/link/c/basic.py", line 1543, in compile_cmodule
> module = c_compiler.compile_str(
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/link/c/cmodule.py", line 2546, in compile_str
> raise Exception(
> Exception: ('Compilation failed (return status=1): /home/mach1ne/.theano/compiledir_Linux-5.4--generic-x86_64-with-glibc2.31-x86_64-3.9.7-64/tmpny3ek6sy/mod.cpp: In member function ‘int {anonymous}::__struct_compiled_op_m2854c5ace9f246bece6011cae4f888e7193a8c5d824856d0d9390f42e972c8f1::run()’:. /home/mach1ne/.theano/compiledir_Linux-5.4--generic-x86_64-with-glibc2.31-x86_64-3.9.7-64/tmpny3ek6sy/mod.cpp:353:60: error: expected primary-expression before ‘{’ token. 353 | #pragma omp parallel for if(n>={int(config.openmp_elemwise_minsize)}). | ^. At global scope:. cc1plus: warning: unrecognized command line option ‘-Wno-c++11-narrowing’. ', 'FunctionGraph(Elemwise{sqr,no_inplace}(TensorConstant{[0.0196731...9937537]}))')
> 
> You can find the C code in this temporary file: /tmp/theano_compilation_error_8flpf3dj
> 
> ERROR (theano.graph.opt): Optimization failure due to: constant_folding
> ERROR (theano.graph.opt): node: Elemwise{mul,no_inplace}(TensorConstant{(1, 1) of -2.0}, TensorConstant{[[3.870321..1130e+01]]})
> ERROR (theano.graph.opt): TRACEBACK:
> ERROR (theano.graph.opt): Traceback (most recent call last):
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/graph/opt.py", line 2017, in process_node
> replacements = lopt.transform(fgraph, node)
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/graph/opt.py", line 1209, in transform
> return self.fn(*args, **kwargs)
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/tensor/opt.py", line 7006, in constant_folding
> thunk = node.op.make_thunk(
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/graph/op.py", line 634, in make_thunk
> return self.make_c_thunk(node, storage_map, compute_map, no_recycling)
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/graph/op.py", line 600, in make_c_thunk
> outputs = cl.make_thunk(
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/link/c/basic.py", line 1203, in make_thunk
> cthunk, module, in_storage, out_storage, error_storage = self. __compile__ (
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/link/c/basic.py", line 1138, in __compile__
> thunk, module = self.cthunk_factory(
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/link/c/basic.py", line 1634, in cthunk_factory
> module = get_module_cache().module_from_key(key=key, lnk=self)
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/link/c/cmodule.py", line 1191, in module_from_key
> module = lnk.compile_cmodule(location)
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/link/c/basic.py", line 1543, in compile_cmodule
> module = c_compiler.compile_str(
> File "/home/mach1ne/anaconda3/envs/phd/lib/python3.9/site-packages/theano/link/c/cmodule.py", line 2546, in compile_str
> raise Exception(
> Exception: ('Compilation failed (return status=1): /home/mach1ne/.theano/compiledir_Linux-5.4--generic-x86_64-with-glibc2.31-x86_64-3.9.7-64/tmp6bax0kke/mod.cpp: In member function ‘int {anonymous}::__struct_compiled_op_m0b97050e1b0a9df5ad1eb6be47c8a2534ca6731df99c8da5f51904550430ac7c::run()’:. /home/mach1ne/.theano/compiledir_Linux-5.4--generic-x86_64-with-glibc2.31-x86_64-3.9.7-64/tmp6bax0kke/mod.cpp:480:60: error: expected primary-expression before ‘{’ token. 480 | #pragma omp parallel for if(n>={int(config.openmp_elemwise_minsize)}). | ^. /home/mach1ne/.theano/compiledir_Linux-5.4--generic-x86_64-with-glibc2.31-x86_64-3.9.7-64/tmp6bax0kke/mod.cpp:511:27: warning: narrowing conversion of ‘V3_n0’ from ‘npy_intp’ {aka ‘long int’} to ‘int’ [-Wnarrowing]. 511 | int init_totals[2] = {V3_n0, V3_n1};. | ^~~~~. /home/mach1ne/.theano/compiledir_Linux-5.4--generic-x86_64-with-glibc2.31-x86_64-3.9.7-64/tmp6bax0kke/mod.cpp:511:34: warning: narrowing conversion of ‘V3_n1’ from ‘npy_intp’ {aka ‘long int’} to ‘int’ [-Wnarrowing]. 511 | int init_totals[2] = {V3_n0, V3_n1};. | ^~~~~. /home/mach1ne/.theano/compiledir_Linux-5.4--generic-x86_64-with-glibc2.31-x86_64-3.9.7-64/tmp6bax0kke/mod.cpp:524:1: warning: narrowing conversion of ‘V3_stride0’ from ‘ssize_t’ {aka ‘long int’} to ‘int’ [-Wnarrowing]. 524 | V3_stride0, V3_stride1,. | ^~~~~~~~~~. /home/mach1ne/.theano/compiledir_Linux-5.4--generic-x86_64-with-glibc2.31-x86_64-3.9.7-64/tmp6bax0kke/mod.cpp:524:13: warning: narrowing conversion of ‘V3_stride1’ from ‘ssize_t’ {aka ‘long int’} to ‘int’ [-Wnarrowing]. 524 | V3_stride0, V3_stride1,. | ^~~~~~~~~~. /home/mach1ne/.theano/compiledir_Linux-5.4--generic-x86_64-with-glibc2.31-x86_64-3.9.7-64/tmp6bax0kke/mod.cpp:525:1: warning: narrowing conversion of ‘V1_stride0’ from ‘ssize_t’ {aka ‘long int’} to ‘int’ [-Wnarrowing]. 525 | V1_stride0, V1_stride1. | ^~~~~~~~~~. /home/mach1ne/.theano/compiledir_Linux-5.4--generic-x86_64-with-glibc2.31-x86_64-3.9.7-64/tmp6bax0kke/mod.cpp:525:13: warning: narrowing conversion of ‘V1_stride1’ from ‘ssize_t’ {aka ‘long int’} to ‘int’ [-Wnarrowing]. 525 | V1_stride0, V1_stride1. | ^~~~~~~~~~. At global scope:. cc1plus: warning: unrecognized command line option ‘-Wno-c++11-narrowing’. ', 'FunctionGraph(Elemwise{mul,no_inplace}(TensorConstant{(1, 1) of -2.0}, TensorConstant{[[3.870321..1130e+01]]}))')
> 
> You can find the C code in this temporary file: /tmp/theano_compilation_error_at9x5y4c
> 
> You can find the C code in this temporary file: /tmp/theano_compilation_error_9mrmchk8
> 
> ---------------------------------------------------------------------------
> Exception Traceback (most recent call last)
> <ipython-input-7-6c3e5c54b408> in <module>
> 3 X = 10 * np.sort(np.random.rand(n))[:, None]
> 4 cov_func = η_true ** 2 * pm.gp.cov.Matern52(1, ℓ_true)
> ----> 5 cov_func(X).eval()
> 
> ~/anaconda3/envs/phd/lib/python3.9/site-packages/theano/graph/basic.py in eval(self, inputs_to_values)
> 552 inputs = tuple(sorted(inputs_to_values.keys(), key=id))
> 553 if inputs not in self._fn_cache:
> --> 554 self._fn_cache[inputs] = theano.function(inputs, self)
> 555 args = [inputs_to_values[param] for param in inputs]
> 556 
> 
> ~/anaconda3/envs/phd/lib/python3.9/site-packages/theano/compile/function/ __init__.py in function(inputs, outputs, mode, updates, givens, no_default_updates, accept_inplace, name, rebuild_strict, allow_input_downcast, profile, on_unused_input)
> 335 # note: pfunc will also call orig_function -- orig_function is
> 336 # a choke point that all compilation must pass through
> --> 337 fn = pfunc(
> 338 params=inputs,
> 339 outputs=outputs,
> 
> ~/anaconda3/envs/phd/lib/python3.9/site-packages/theano/compile/function/pfunc.py in pfunc(params, outputs, mode, updates, givens, no_default_updates, accept_inplace, name, rebuild_strict, allow_input_downcast, profile, on_unused_input, output_keys)
> 522 inputs.append(si)
> 523 
> --> 524 return orig_function(
> 525 inputs,
> 526 cloned_outputs,
> 
> ~/anaconda3/envs/phd/lib/python3.9/site-packages/theano/compile/function/types.py in orig_function(inputs, outputs, mode, accept_inplace, name, profile, on_unused_input, output_keys)
> 1979 )
> 1980 with config.change_flags(compute_test_value="off"):
> -> 1981 fn = m.create(defaults)
> 1982 finally:
> 1983 t2 = time.time()
> 
> ~/anaconda3/envs/phd/lib/python3.9/site-packages/theano/compile/function/types.py in create(self, input_storage, trustme, storage_map)
> 1834 
> 1835 with config.change_flags(traceback __limit=config.traceback__ compile_limit):
> -> 1836 _fn, _i, _o = self.linker.make_thunk(
> 1837 input_storage=input_storage_lists, storage_map=storage_map
> 1838 )
> 
> ~/anaconda3/envs/phd/lib/python3.9/site-packages/theano/link/basic.py in make_thunk(self, input_storage, output_storage, storage_map)
> 264 
> 265 def make_thunk(self, input_storage=None, output_storage=None, storage_map=None):
> --> 266 return self.make_all(
> 267 input_storage=input_storage,
> 268 output_storage=output_storage,
> 
> ~/anaconda3/envs/phd/lib/python3.9/site-packages/theano/link/vm.py in make_all(self, profiler, input_storage, output_storage, storage_map)
> 1129 # no_recycling here.
> 1130 thunks.append(
> -> 1131 node.op.make_thunk(node, storage_map, compute_map, [], impl=impl)
> 1132 )
> 1133 linker_make_thunk_time[node] = time.time() - thunk_start
> 
> ~/anaconda3/envs/phd/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/phd/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/phd/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/phd/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/phd/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/phd/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/phd/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/phd/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: ('The following error happened while compiling the node', Elemwise{sqr,no_inplace}(TensorConstant{[0.0196731...9937537]}), '\n', 'Compilation failed (return status=1): /home/mach1ne/.theano/compiledir_Linux-5.4--generic-x86_64-with-glibc2.31-x86_64-3.9.7-64/tmpcbyra4hv/mod.cpp: In member function ‘int {anonymous}::__struct_compiled_op_m2854c5ace9f246bece6011cae4f888e7193a8c5d824856d0d9390f42e972c8f1::run()’:. /home/mach1ne/.theano/compiledir_Linux-5.4--generic-x86_64-with-glibc2.31-x86_64-3.9.7-64/tmpcbyra4hv/mod.cpp:353:60: error: expected primary-expression before ‘{’ token. 353 | #pragma omp parallel for if(n>={int(config.openmp_elemwise_minsize)}). | ^. At global scope:. cc1plus: warning: unrecognized command line option ‘-Wno-c++11-narrowing’. ', 'FunctionGraph(Elemwise{sqr,no_inplace}(TensorConstant{[0.0196731...9937537]}))')
> 
> ```

Any idea what is going on?

Tks,  
Luis

---

<div class="post-metadata">

### Author: ![twiecki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/twiecki/32/6930_2.png) [@twiecki](https://discourse.pymc.io/u/twiecki)
#### Post date: [November 17, 2021, 6:29pm UTC](https://discourse.pymc.io/t/pymc3-fresh-install-yielding-theano-errors-linux/8304/2 "2021-11-17T18:29:00Z")

</div>

Did you install with `mkl-service`? You could try that.

---

<div class="post-metadata">

### Author: ![luisroque](https://avatars.discourse-cdn.com/v4/letter/l/7c8e57/32.png) [@luisroque](https://discourse.pymc.io/u/luisroque)
#### Post date: [November 17, 2021, 7:52pm UTC](https://discourse.pymc.io/t/pymc3-fresh-install-yielding-theano-errors-linux/8304/3 "2021-11-17T19:52:13Z")

</div>

Hi Thomas, yes I did install it. Still no luck. Are you able to run it with no problems?

---

<div class="post-metadata">

### Author: ![twiecki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/twiecki/32/6930_2.png) [@twiecki](https://discourse.pymc.io/u/twiecki)
#### Post date: [November 18, 2021, 12:11am UTC](https://discourse.pymc.io/t/pymc3-fresh-install-yielding-theano-errors-linux/8304/4 "2021-11-18T00:11:06Z")

</div>

Yes, you could try pymc 4 from the main branch and aesara, maybe that solves it.
