Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation failed (return status=1) #4922

Closed
mick-phemex opened this issue Aug 13, 2021 · 7 comments
Closed

Compilation failed (return status=1) #4922

mick-phemex opened this issue Aug 13, 2021 · 7 comments
Labels
installation issues about dependencies or installation

Comments

@mick-phemex
Copy link

Description of your problem

To begin with, I have followed up the instruction of the installation guide and deploy the new virtual environment with the yml file presented over that page, but I still met with the same problem as I executed the following codes. I have tried out many ways to solve the problem, please assist me to solve the problem.

Please provide a minimal, self-contained, and reproducible example.

import pymc3 as pm
import numpy as np
import pandas as pd
import scipy.stats as stats
from datetime import datetime
import theano.tensor as T

early = 10
late = 12
y = np.r_[np.random.poisson(early, 25), np.random.poisson(late, 75)]
      
niter = 10000
t = range(len(y))
with pm.Model() as change_point:
    cp = pm.DiscreteUniform('change_point', lower=0, upper=len(y), testval=len(y)//2)
    mu0 = pm.Exponential('mu0', 1/y.mean())
    mu1 = pm.Exponential('mu1', 1/y.mean())
    mu = T.switch(t < cp, mu0, mu1)
    Y_obs = pm.Poisson('Y_obs', mu=mu, observed=y)
    trace = pm.sample(niter)
pm.traceplot(trace, varnames=['change_point', 'mu0', 'mu1'])

Please provide the full traceback.

Complete error traceback
[You can find the C code in this temporary file: C:\Users\Mick\AppData\Local\Temp\theano_compilation_error_xk8zcr1g
Traceback (most recent call last):

  File "C:\....py", line 48, in <module>
    mu = T.switch(t < cp, mu0, mu1)

  File "C:\...\lib\site-packages\theano\tensor\var.py", line 41, in __gt__
    rval = theano.tensor.basic.gt(self, other)

  File "C:\...\lib\site-packages\theano\graph\op.py", line 253, in __call__
    compute_test_value(node)

  File "C:\...\lib\site-packages\theano\graph\op.py", line 126, in compute_test_value
    thunk = node.op.make_thunk(node, storage_map, compute_map, no_recycling=[])

  File "C:\...\lib\site-packages\theano\graph\op.py", line 634, in make_thunk
    return self.make_c_thunk(node, storage_map, compute_map, no_recycling)

  File "C:\...\lib\site-packages\theano\graph\op.py", line 600, in make_c_thunk
    outputs = cl.make_thunk(

  File "C:\...\lib\site-packages\theano\link\c\basic.py", line 1203, in make_thunk
    cthunk, module, in_storage, out_storage, error_storage = self.__compile__(

  File "C:\...\lib\site-packages\theano\link\c\basic.py", line 1138, in __compile__
    thunk, module = self.cthunk_factory(

  File "C:\...\lib\site-packages\theano\link\c\basic.py", line 1634, in cthunk_factory
    module = get_module_cache().module_from_key(key=key, lnk=self)

  File "C:\...\lib\site-packages\theano\link\c\cmodule.py", line 1191, in module_from_key
    module = lnk.compile_cmodule(location)

  File "C:\...\lib\site-packages\theano\link\c\basic.py", line 1543, in compile_cmodule
    module = c_compiler.compile_str(

  File "C:\...\lib\site-packages\theano\link\c\cmodule.py", line 2546, in compile_str
    raise Exception(

Exception: ('Compilation failed (return status=1): C:\\...\\AppData\\Local\\Temp\\ccujaONv.s: Assembler messages:\r. C:\\...\\AppData\\Local\\Temp\\ccujaONv.s:89: Error: invalid register for .seh_savexmm\r. ', 'FunctionGraph(Elemwise{gt,no_inplace}(<TensorType(int64, (True,))>, TensorConstant{[ 0  1  2 .. 97 98 99]}))')]

Please provide any additional information below.

Versions and main components

  • PyMC3 Version: v3.11.2
  • Aesara/Theano Version: v1.1.2
  • Python Version: 3.8
  • Operating system: win10
  • How did you install PyMC3: conda (with yml file consistent to the setting from here
@mick-phemex mick-phemex changed the title Same problem with issues #4565 and #4749 Compilation failed (return status=1) Aug 13, 2021
@michaelosthege
Copy link
Member

Can you run a simpler model that doesn't involve theano.tensor.switch?

Some more info that might help:

  • Windows 10 64 bit I assume?
  • Are you working with Anaconda or miniconda?
  • What does your PATH environment variable contain?

@michaelosthege michaelosthege added the installation issues about dependencies or installation label Aug 15, 2021
@mick-phemex
Copy link
Author

The following example is another model that I tried, the same error still happened. I assumed that the error code is this one:

start = pm.find_MAP()

np.random.seed(123)
n = 11
_a = 6
_b = 2
x = np.linspace(0, 1, n)
y = _a*x + _b + np.random.randn(n)
niter = 10000
with pm.Model() as linreg:
    a = pm.Normal('a', mu=0, sd=100)
    b = pm.Normal('b', mu=0, sd=100)
    sigma = pm.HalfNormal('sigma', sd=1)

    y_est = a*x + b
    likelihood = pm.Normal('y', mu=y_est, sd=sigma, observed=y)

    start = pm.find_MAP()
    step = pm.NUTS(scaling=start)
    trace = pm.sample(niter, step, start, random_seed=123)
t = trace[niter//2:]
pm.traceplot(trace, varnames=['a', 'b'])

Additional info:

  • Yes, it is Windows 10 64 bit.
  • I am working with Anaconda.
  • May I ask specifically what you mean about PATH environment variable? user variables or system variables? I assume you meant system PATH environment variables, it contains the following pathes.

图片

Thank you for your response! @michaelosthege

@michaelosthege
Copy link
Member

I can't tell for sure (and I won't risk my installations trying to validate), but maybe the C:\MinGW\bin in your PATH is (part of) the problem.
Maybe it takes precedence over the MinGW from the environment?

For comparison this is my user PATH environment variable:
grafik

In an activated PyMC3 environment I end up with this:

>>> print(os.getenv("PATH").replace(";", "\n"))
C:\Users\osthege\AppData\Local\Continuum\miniconda3\envs\pm3v3
C:\Users\osthege\AppData\Local\Continuum\miniconda3\envs\pm3v3\Library\mingw-w64\bin
C:\Users\osthege\AppData\Local\Continuum\miniconda3\envs\pm3v3\Library\usr\bin
C:\Users\osthege\AppData\Local\Continuum\miniconda3\envs\pm3v3\Library\bin
C:\Users\osthege\AppData\Local\Continuum\miniconda3\envs\pm3v3\Scripts
C:\Users\osthege\AppData\Local\Continuum\miniconda3\envs\pm3v3\bin
C:\Users\osthege\AppData\Local\Continuum\miniconda3\condabin
C:\Program Files\AdoptOpenJDK\jre-8.0.292.10-hotspot\bin
C:\Program Files\Microsoft MPI\Bin
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\Wbem
C:\WINDOWS\System32\WindowsPowerShell\v1.0
C:\Program Files\dotnet
C:\Program Files\Microsoft SQL Server\130\Tools\Binn
C:\WINDOWS\System32\OpenSSH
C:\Program Files (x86)\MySQL\MySQL Utilities 1.6
C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn
C:\Program Files\Git\cmd
C:\Program Files\PuTTY
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common
C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR
C:\Program Files\Docker\Docker\resources\bin
C:\ProgramData\DockerDesktop\version-bin
C:\Users\osthege\AppData\Local\Continuum\miniconda3
C:\Users\osthege\AppData\Local\Continuum\miniconda3\Library\mingw-w64\bin
C:\Users\osthege\AppData\Local\Continuum\miniconda3\Library\usr\bin
C:\Users\osthege\AppData\Local\Continuum\miniconda3\Library\bin
C:\Users\osthege\AppData\Local\Continuum\miniconda3\Scripts
C:\Users\osthege\AppData\Local\Microsoft\WindowsApps
C:\Users\osthege\AppData\Local\GitHubDesktop\bin
C:\Users\osthege\.dotnet\tools
C:\Users\osthege\AppData\Local\Programs\Microsoft VS Code\bin
C:\Users\osthege\AppData\Local\Microsoft\WindowsApps

@sreedat
Copy link

sreedat commented Aug 16, 2021

@michaelosthege thanks for posting this configuration of your User variables. As soon as I set up mine correctly, all my problems have been resolved. To test if the RTools set up was conflicting with my Anaconda / Pymc3 compilation, I removed RTools completely and when I ran import theano as tp, it gave me a cannot find g++ error. With m2w64 tool chain installed this error should not have occurred.
So I set up my User variables per your post, and disabled by RTools installation by changing my RTools folder name. Now all of my Pymc3 and Bambi models are compiling correctly.

@michaelosthege
Copy link
Member

@sreedat thanks for that confirmation! I guess we should add corresponding troubleshooting instructions to the install guide..

@sreedat
Copy link

sreedat commented Aug 16, 2021

@michaelosthege As a token of my appreciation I would like to create this troubleshooting guide and help developers such as you focus on the developmental aspects of these packages. During the past week, I went through installation of Pymc3 and testing it on Ubuntu 20.04 LTS, Windows 8.1 and Windows 10. So I can provide these instructions from a comparison perspective too if needed. I have never done any thing like this before. So if you can point me to a guide on how to do this, I would love to help. You helped slow down my balding without a doubt, so a double thank you!

@michaelosthege
Copy link
Member

@michaelosthege As a token of my appreciation I would like to create this troubleshooting guide and help developers such as you focus on the developmental aspects of these packages. During the past week, I went through installation of Pymc3 and testing it on Ubuntu 20.04 LTS, Windows 8.1 and Windows 10. So I can provide these instructions from a comparison perspective too if needed. I have never done any thing like this before. So if you can point me to a guide on how to do this, I would love to help. You helped slow down my balding with a doubt, so a double thank you!

Having been through this in the past I can understand your pain 😅
As always contributions are welcome!
We have the guide in a Wiki page because this way project members can quickly update it without going through the pull requests.
The downside is that it's not as straightforward to take outside contributions.

I see two ways how you could contribute to the wiki page:

  • Create a New Issue, copy the wiki page content and edit the markdown over in the new issue. Then we'll copy it to the wiki manually.
  • According to this stackoverflow post it is possible to edit the Wiki with a git workflow, but it doesn't look very straightforward. Wouldn't recommend unless you feel confident with git.

To focus the reader attention we could also just link from a troubleshooting section to Github issues where we can have more information and discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
installation issues about dependencies or installation
Projects
None yet
Development

No branches or pull requests

4 participants