Unexpected error when testing Pymc3 installation on Windows 10 and Anaconda

Hi I’m using a Windows 10 64-bit machine with Anaconda (Anaconda3-2021.05-Windows-x86_64). I have admin rights on my laptop. I followed the installation instructions given here for Windows using the “environment.yml” files approach.
Installation Guide (Windows) · pymc-devs/pymc3 Wiki · GitHub

Then I began to test my installation of Pymc3 using the Getting Started Guide found here: Getting started with PyMC3 — PyMC3 3.10.0 documentation

I was able to successfully complete both the (1) Linear Regression and (2) Stock Market Return examples without any errors. When I ran the example (3) Coal Mine Disasters is when I got the following error (Note that I ran all examples in one go and I did not make any changes to my environment in any way between testing the examples):

Exception: ('Compilation failed (return status=1): C:\\Users\\SreeDatta\\AppData\\Local\\Temp\\ccEWCiGI.s: Assembler messages:\r. C:\\Users\\SreeDatta\\AppData\\Local\\Temp\\ccEWCiGI.s:367: Error: invalid register for .seh_savexmm\r. ', 'FunctionGraph(Elemwise{eq,no_inplace}(<TensorType(int64, vector)>, <TensorType(int8, (True,))>))')

This appears to be an error coming from Theano. I’m hoping one of can help with this error. I have a base installation of Anaconda and created a new environment using the “environment.yml” file. Here are all the packages in my “pm3env”

# packages in environment at C:\ProgramData\Anaconda3\envs\pm3env:
# Name                    Version                   Build  Channel
argon2-cffi               20.1.0           py37hcc03f2d_2    conda-forge
arviz                     0.11.1                   pypi_0    pypi
async_generator           1.10                       py_0    conda-forge
attrs                     21.2.0             pyhd8ed1ab_0    conda-forge
backcall                  0.2.0              pyh9f0ad1d_0    conda-forge
backports                 1.0                        py_2    conda-forge
backports.functools_lru_cache 1.6.4              pyhd8ed1ab_0    conda-forge
bambi                     0.5.0                    pypi_0    pypi
blas                      1.0                         mkl
bleach                    4.0.0              pyhd8ed1ab_0    conda-forge
ca-certificates           2021.5.30            h5b45459_0    conda-forge
cached-property           1.5.2                    pypi_0    pypi
cachetools                4.2.2                    pypi_0    pypi
cairo                     1.16.0            hb19e0ff_1008    conda-forge
certifi                   2021.5.30        py37h03978a9_0    conda-forge
cffi                      1.14.6           py37hd8e9650_0    conda-forge
cftime                    1.5.0                    pypi_0    pypi
colorama                  0.4.4              pyh9f0ad1d_0    conda-forge
cycler                    0.10.0                     py_2    conda-forge
decorator                 5.0.9              pyhd8ed1ab_0    conda-forge
defusedxml                0.7.1              pyhd8ed1ab_0    conda-forge
dill                      0.3.4                    pypi_0    pypi
entrypoints               0.3             pyhd8ed1ab_1003    conda-forge
et-xmlfile                1.1.0                    pypi_0    pypi
expat                     2.4.1                h39d44d4_0    conda-forge
fastprogress              1.0.0                    pypi_0    pypi
filelock                  3.0.12                   pypi_0    pypi
font-ttf-dejavu-sans-mono 2.37                 hab24e00_0    conda-forge
font-ttf-inconsolata      3.000                h77eed37_0    conda-forge
font-ttf-source-code-pro  2.038                h77eed37_0    conda-forge
font-ttf-ubuntu           0.83                 hab24e00_0    conda-forge
fontconfig                2.13.1            h1989441_1005    conda-forge
fonts-conda-ecosystem     1                             0    conda-forge
fonts-conda-forge         1                             0    conda-forge
formulae                  0.1.3                    pypi_0    pypi
freetype                  2.10.4               h546665d_1    conda-forge
fribidi                   1.0.10               h8d14728_0    conda-forge
getopt-win32              0.1                  h8ffe710_0    conda-forge
gettext                   h1a89ca6_1005    conda-forge
graphite2                 1.3.13                     1000    conda-forge
graphviz                  2.48.0               hefbd956_0    conda-forge
gts                       0.7.6                h7c369d9_2    conda-forge
h5py                      3.1.0                    pypi_0    pypi
harfbuzz                  2.8.2                hc601d6f_0    conda-forge
icc_rt                    2019.0.0             h0cc432a_1
icu                       68.1                 h0e60522_0    conda-forge
importlib-metadata        2.1.1                    pypi_0    pypi
intel-openmp              2021.3.0          h57928b3_3372    conda-forge
ipykernel                 5.5.5            py37h7813e69_0    conda-forge
ipython                   7.26.0           py37h4038f58_0    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
ipywidgets                7.6.3              pyhd3eb1b0_1
jbig                      2.1               h8d14728_2003    conda-forge
jedi                      0.18.0           py37h03978a9_2    conda-forge
jinja2                    3.0.1              pyhd8ed1ab_0    conda-forge
jpeg                      9d                   h8ffe710_0    conda-forge
jsonschema                3.2.0              pyhd8ed1ab_3    conda-forge
jupyter                   1.0.0                    py37_7
jupyter_client            6.1.12             pyhd8ed1ab_0    conda-forge
jupyter_console           6.4.0              pyhd8ed1ab_0    conda-forge
jupyter_core              4.7.1            py37h03978a9_0    conda-forge
jupyterlab_pygments       0.1.2              pyh9f0ad1d_0    conda-forge
jupyterlab_widgets        1.0.0              pyhd8ed1ab_1    conda-forge
kiwisolver                1.3.1            py37h8c56517_1    conda-forge
lcms2                     2.12                 h2a16943_0    conda-forge
lerc                      2.2.1                h0e60522_0    conda-forge
libclang                  11.1.0          default_h5c34c98_1    conda-forge
libdeflate                1.7                  h8ffe710_5    conda-forge
libffi                    3.3                  h0e60522_2    conda-forge
libgd                     2.3.2                h138e682_0    conda-forge
libglib                   2.68.3               h1e62bf3_0    conda-forge
libiconv                  1.16                 he774522_0    conda-forge
libpng                    1.6.37               h1d00b33_2    conda-forge
libpython                 2.1                      py37_0
libsodium                 1.0.18               h8d14728_1    conda-forge
libtiff                   4.3.0                h0c97f57_1    conda-forge
libwebp                   1.2.0                h57928b3_0    conda-forge
libwebp-base              1.2.0                h8ffe710_2    conda-forge
libxcb                    1.13              hcd874cb_1003    conda-forge
libxml2                   2.9.12               hf5bbc77_0    conda-forge
llvmlite                  0.36.0           py37habb0c8c_0    conda-forge
lz4-c                     1.9.3                h8ffe710_1    conda-forge
m2w64-gcc-libgfortran     5.3.0                         6    conda-forge
m2w64-gcc-libs            5.3.0                         7    conda-forge
m2w64-gcc-libs-core       5.3.0                         7    conda-forge
m2w64-gmp                 6.1.0                         2    conda-forge
m2w64-libwinpthread-git               2    conda-forge
markupsafe                2.0.1            py37hcc03f2d_0    conda-forge
matplotlib                3.3.2                haa95532_0
matplotlib-base           3.3.2            py37h3379fd5_1    conda-forge
matplotlib-inline         0.1.2              pyhd8ed1ab_2    conda-forge
mistune                   0.8.4           py37hcc03f2d_1004    conda-forge
mkl                       2020.4             hb70f87d_311    conda-forge
mkl-service               2.3.0            py37h196d8e1_0
mkl_fft                   1.3.0            py37hda49f71_1    conda-forge
mkl_random                1.2.0            py37h414f9d2_1    conda-forge
mpmath                    1.2.1              pyhd8ed1ab_0    conda-forge
msys2-conda-epoch         20160418                      1    conda-forge
nbclient                  0.5.3              pyhd8ed1ab_0    conda-forge
nbconvert                 6.1.0            py37h03978a9_0    conda-forge
nbformat                  5.1.3              pyhd8ed1ab_0    conda-forge
nest-asyncio              1.5.1              pyhd8ed1ab_0    conda-forge
netcdf4                   1.5.7                    pypi_0    pypi
notebook                  6.4.0              pyha770c72_0    conda-forge
numba                     0.53.1           py37h4e635f9_0    conda-forge
numpy                     1.19.2           py37hadc3359_0
numpy-base                1.19.2           py37ha3acd2a_0
olefile                   0.46               pyh9f0ad1d_1    conda-forge
openjpeg                  2.4.0                hb211442_1    conda-forge
openpyxl                  3.0.7                    pypi_0    pypi
openssl                   1.1.1k               h8ffe710_0    conda-forge
packaging                 21.0               pyhd8ed1ab_0    conda-forge
pandas                    1.2.1            py37hf11a4ad_0
pandoc                    2.14.1               h8ffe710_0    conda-forge
pandocfilters             1.4.2                      py_1    conda-forge
pango                     1.48.7               hd84fcdd_0    conda-forge
parso                     0.8.2              pyhd8ed1ab_0    conda-forge
patsy                     0.5.1                    pypi_0    pypi
pcre                      8.45                 h0e60522_0    conda-forge
pickleshare               0.7.5                   py_1003    conda-forge
pillow                    8.3.1            py37hd7d9ad0_0    conda-forge
pip                       20.3.3           py37haa95532_0
pixman                    0.40.0               h8ffe710_0    conda-forge
prometheus_client         0.11.0             pyhd8ed1ab_0    conda-forge
prompt-toolkit            3.0.19             pyha770c72_0    conda-forge
prompt_toolkit            3.0.19               hd8ed1ab_0    conda-forge
pthread-stubs             0.4               hcd874cb_1001    conda-forge
pycparser                 2.20               pyh9f0ad1d_2    conda-forge
pygments                  2.9.0              pyhd8ed1ab_0    conda-forge
pymc3                     3.11.2                   pypi_0    pypi
pyparsing                 2.4.7              pyh9f0ad1d_0    conda-forge
pyqt                      5.12.3           py37h03978a9_7    conda-forge
pyqt-impl                 5.12.3           py37hf2a7229_7    conda-forge
pyqt5-sip                 4.19.18          py37hf2a7229_7    conda-forge
pyqtchart                 5.12             py37hf2a7229_7    conda-forge
pyqtwebengine             5.12.1           py37hf2a7229_7    conda-forge
pyrsistent                0.17.3           py37hcc03f2d_2    conda-forge
python                    3.7.9                h60c2a47_0
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python-graphviz           0.16               pyh243d235_2    conda-forge
python_abi                3.7                     2_cp37m    conda-forge
pytz                      2021.1             pyhd8ed1ab_0    conda-forge
pywin32                   300              py37hcc03f2d_0    conda-forge
pywinpty                  1.1.3            py37h7f67f24_0    conda-forge
pyzmq                     22.2.0           py37hcce574b_0    conda-forge
qt                        5.12.9               h5909a2a_4    conda-forge
qtconsole                 5.1.1              pyhd8ed1ab_0    conda-forge
qtpy                      1.9.0                      py_0    conda-forge
scipy                     1.7.1                    pypi_0    pypi
semver                    2.13.0                   pypi_0    pypi
send2trash                1.7.1              pyhd8ed1ab_0    conda-forge
setuptools                49.6.0           py37h03978a9_3    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
sqlite                    3.36.0               h8ffe710_0    conda-forge
statsmodels               0.12.2                   pypi_0    pypi
sympy                     1.7.1            py37h03978a9_1    conda-forge
terminado                 0.10.1           py37h03978a9_0    conda-forge
testpath                  0.5.0              pyhd8ed1ab_0    conda-forge
theano-pymc               1.1.2                    pypi_0    pypi
tk                        8.6.10               h8ffe710_1    conda-forge
tornado                   6.1              py37hcc03f2d_1    conda-forge
traitlets                 5.0.5                      py_0    conda-forge
typing                            pypi_0    pypi
typing_extensions           pyha770c72_0    conda-forge
ucrt                      10.0.20348.0         h57928b3_0    conda-forge
vc                        14.2                 hb210afc_5    conda-forge
vs2015_runtime            14.29.30037          h902a5da_5    conda-forge
watermark                 2.2.0                    pypi_0    pypi
wcwidth                   0.2.5              pyh9f0ad1d_2    conda-forge
webencodings              0.5.1                      py_1    conda-forge
wheel                     0.36.2             pyhd3deb0d_0    conda-forge
widgetsnbextension        3.5.1            py37h03978a9_4    conda-forge
wincertstore              0.2             py37h03978a9_1006    conda-forge
winpty                    0.4.3                         4    conda-forge
xarray                    0.16.2                   pypi_0    pypi
xorg-kbproto              1.0.7             hcd874cb_1002    conda-forge
xorg-libice               1.0.10               hcd874cb_0    conda-forge
xorg-libsm                1.2.3             hcd874cb_1000    conda-forge
xorg-libx11               1.7.2                hcd874cb_0    conda-forge
xorg-libxau               1.0.9                hcd874cb_0    conda-forge
xorg-libxdmcp             1.1.3                hcd874cb_0    conda-forge
xorg-libxext              1.3.4                hcd874cb_1    conda-forge
xorg-libxpm               3.5.13               hcd874cb_0    conda-forge
xorg-libxt                1.2.1                hcd874cb_2    conda-forge
xorg-xextproto            7.3.0             hcd874cb_1002    conda-forge
xorg-xproto               7.0.31            hcd874cb_1007    conda-forge
xz                        5.2.5                h62dcd97_1    conda-forge
zeromq                    4.3.4                h0e60522_0    conda-forge
zipp                      3.5.0              pyhd8ed1ab_0    conda-forge
zlib                      1.2.11            h62dcd97_1010    conda-forge
zstd                      1.5.0                h6255e5f_0    conda-forge

Here is the code I tried to run:

with pm.Model() as disaster_model:

    switchpoint = pm.DiscreteUniform(
        "switchpoint", lower=years.min(), upper=years.max(), testval=1900

    # Priors for pre- and post-switch rates number of disasters
    early_rate = pm.Exponential("early_rate", 1.0)
    late_rate = pm.Exponential("late_rate", 1.0)

    # Allocate appropriate Poisson rates to years before and after current
    rate = pm.math.switch(switchpoint >= years, early_rate, late_rate)

    disasters = pm.Poisson("disasters", rate, observed=disaster_data)

Here is the complete traceback of the error I got:

You can find the C code in this temporary file: C:\Users\SreeDatta\AppData\Local\Temp\theano_compilation_error_f10nrpwx
Exception                                 Traceback (most recent call last)
<ipython-input-20-392de9deec43> in <module>
     12     rate = pm.math.switch(switchpoint >= years, early_rate, late_rate)
---> 14     disasters = pm.Poisson("disasters", rate, observed=disaster_data)

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\pymc3\distributions\distribution.py in __new__(cls, name, *args, **kwargs)
    120         else:
    121             dist = cls.dist(*args, **kwargs)
--> 122         return model.Var(name, dist, data, total_size, dims=dims)
    124     def __getnewargs__(self):

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\pymc3\model.py in Var(self, name, dist, data, total_size, dims)
   1180                     distribution=dist,
   1181                     total_size=total_size,
-> 1182                     model=self,
   1183                 )
   1184             self.observed_RVs.append(var)

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\pymc3\model.py in __init__(self, type, owner, index, name, data, distribution, total_size, model)
   1827             self.missing_values = data.missing_values
-> 1828             self.logp_elemwiset = distribution.logp(data)
   1829             # The logp might need scaling in minibatches.
   1830             # This is done in `Factor`.

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\pymc3\distributions\discrete.py in logp(self, value)
    704         """
    705         mu = self.mu
--> 706         log_prob = bound(logpow(mu, value) - factln(value) - mu, mu >= 0, value >= 0)
    707         # Return zero when mu and value are both zero
    708         return tt.switch(tt.eq(mu, 0) * tt.eq(value, 0), 0, log_prob)

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\pymc3\distributions\dist_math.py in logpow(x, m)
    106     """
    107     # return m * log(x)
--> 108     return tt.switch(tt.eq(x, 0), tt.switch(tt.eq(m, 0), 0.0, -np.inf), m * tt.log(x))

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\graph\op.py in __call__(self, *inputs, **kwargs)
    252         if config.compute_test_value != "off":
--> 253             compute_test_value(node)
    255         if self.default_output is not None:

C:\ProgramData\Anaconda3\envs\pm3env\lib\site-packages\theano\graph\op.py in compute_test_value(node)
    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]

C:\ProgramData\Anaconda3\envs\pm3env\lib\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.

C:\ProgramData\Anaconda3\envs\pm3env\lib\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

C:\ProgramData\Anaconda3\envs\pm3env\lib\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         )

C:\ProgramData\Anaconda3\envs\pm3env\lib\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 (

C:\ProgramData\Anaconda3\envs\pm3env\lib\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)
   1636         vars = self.inputs + self.outputs + self.orphans

C:\ProgramData\Anaconda3\envs\pm3env\lib\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)

C:\ProgramData\Anaconda3\envs\pm3env\lib\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:

C:\ProgramData\Anaconda3\envs\pm3env\lib\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): C:\\Users\\SreeDatta\\AppData\\Local\\Temp\\ccEWCiGI.s: Assembler messages:\r. C:\\Users\\SreeDattappData\\Local\\Temp\\ccEWCiGI.s:367: Error: invalid register for .seh_savexmm\r. ', 'FunctionGraph(Elemwise{eq,no_inplace}(<TensorType(int64, vector)>, <TensorType(int8, (True,))>))')

Thanks in advance for your help.

Look at this.

@rosgori thanks for the link. That was the first resource I had examined thoroughly to see how the errors can be corrected. I followed the specific installation instructions and that helped me run the Linear Regression and Stock Market examples provided in the “Pymc3 Getting Started” page. I was using the example code verbatim.
The error occurs again in the third example “Coal Mine Disasters” model. My code shows that Pymc3 is correctly assigning NUTS for Continuous variables and Metropolis for the Discrete (the Count of Coal mine accidents) but yet the error crops up. I have removed the environment and reinstalled per the specifications given in the link you shared. The error does not go away.

Could you try to replicate the Coal Mine disasters example given at this link and see if you are able to replicate the error I’m getting? See the link below

Thanks again for your help - Sree

1 Like

In my case, I don’t see those errors (I am not using Windows 10, I have Ubuntu 20.04), so I cannot help with that.

Thanks for confirming @rosgori at least on Ubuntu. I have tested that example (Coal Mine Disasters) now on two other machines with fresh Anaconda3 installs (Windows 8.1 with Anaconda3-64 bit & Ubuntu 20.04 with Anaconda3-64bit). I get the same error. Something is broken and I do not yet know what it is.


1 Like

I found out with help from @michaelosthege and @tomicapretto over the past few days that my Windows 10 machine may be having a clash of mingw compilers. I use both R and Anaconda for my Statistics and Data Science work.

The Bayesian models I work with in R uses the Stan packages that need C and C++ compilers (via RTools that uses the mingw C and C++ compilers through Msys2). In the System environment variables, RTools is first on the PATH.

@michaelosthege had posted his USER Path variables and that showed that my Python compilation was not using m2w64 tool chain in Anaconda, but was using the compilers from RTools.

So I changed the name of the RTools folder and ensured that the System PATH variable would not work and the these mingw compilers could not be found. Then when I ran a simple command import theano as tp it gave me an error Error: g++ cannot be found...

Next I set up my User PATH variables and pointed them to the correct location of the mingw compilers in the Base Anaconda3 installation. All of my Pymc3 models are being compiled correctly.

Thanks everyone for your time and your help - Sree