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

CompileError: command 'gcc' failed with exit status 1 #470

Open
elena-zamfir opened this Issue Jun 25, 2018 · 7 comments

Comments

Projects
None yet
3 participants
@elena-zamfir

elena-zamfir commented Jun 25, 2018

Summary:

I have just upgraded pystan, which was working fine, with pip install pystan --upgrade.
Now it's not compiling models any more. It gives an error about gcc.

Description:

I have just upgraded pystan to version 2.17.1.0
It no longer compiles modesl, I get the error message:
INFO:pystan:COMPILING THE C++ CODE FOR MODEL anon_model_cbe9cd2f1e5ab5d1c7cce1f23ca970b4 NOW.
Traceback (most recent call last):
File "/nfs/nhome/live/elena/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2881, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 27, in
sm = pystan.StanModel(model_code=schools_code)
File "/nfs/nhome/live/elena/anaconda/lib/python2.7/site-packages/pystan/model.py", line 313, in init
build_extension.run()
File "/nfs/nhome/live/elena/anaconda/lib/python2.7/distutils/command/build_ext.py", line 339, in run
self.build_extensions()
File "/nfs/nhome/live/elena/anaconda/lib/python2.7/distutils/command/build_ext.py", line 448, in build_extensions
self.build_extension(ext)
File "/nfs/nhome/live/elena/anaconda/lib/python2.7/distutils/command/build_ext.py", line 498, in build_extension
depends=ext.depends)
File "/nfs/nhome/live/elena/anaconda/lib/python2.7/distutils/ccompiler.py", line 574, in compile
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
File "/nfs/nhome/live/elena/anaconda/lib/python2.7/distutils/unixccompiler.py", line 124, in _compile
raise CompileError, msg
CompileError: command 'gcc' failed with exit status 1

Reproducible Steps:

schools_code = """
data {
int<lower=0> J; // number of schools
real y[J]; // estimated treatment effects
real<lower=0> sigma[J]; // s.e. of effect estimates
}
parameters {
real mu;
real<lower=0> tau;
real eta[J];
}
transformed parameters {
real theta[J];
for (j in 1:J)
theta[j] = mu + tau * eta[j];
}
model {
eta ~ normal(0, 1);
y ~ normal(theta, sigma);
}
"""

schools_dat = {'J': 8,
'y': [28, 8, -3, 7, -1, 1, 18, 12],
'sigma': [15, 10, 16, 11, 9, 11, 10, 18]}

sm = pystan.StanModel(model_code=schools_code)

Current Output:

INFO:pystan:COMPILING THE C++ CODE FOR MODEL anon_model_cbe9cd2f1e5ab5d1c7cce1f23ca970b4 NOW.
Traceback (most recent call last):
File "/nfs/nhome/live/elena/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2881, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 27, in
sm = pystan.StanModel(model_code=schools_code)
File "/nfs/nhome/live/elena/anaconda/lib/python2.7/site-packages/pystan/model.py", line 313, in init
build_extension.run()
File "/nfs/nhome/live/elena/anaconda/lib/python2.7/distutils/command/build_ext.py", line 339, in run
self.build_extensions()
File "/nfs/nhome/live/elena/anaconda/lib/python2.7/distutils/command/build_ext.py", line 448, in build_extensions
self.build_extension(ext)
File "/nfs/nhome/live/elena/anaconda/lib/python2.7/distutils/command/build_ext.py", line 498, in build_extension
depends=ext.depends)
File "/nfs/nhome/live/elena/anaconda/lib/python2.7/distutils/ccompiler.py", line 574, in compile
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
File "/nfs/nhome/live/elena/anaconda/lib/python2.7/distutils/unixccompiler.py", line 124, in _compile
raise CompileError, msg
CompileError: command 'gcc' failed with exit status 1

PyStan Version: 2.17.1.0

Python Version:2.7.12 |Anaconda 2.2.0 (64-bit)| (default, Jul 2 2016, 17:42:40)

[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]

Operating System: Ubuntu 16.04.3 LTS

@ahartikainen

This comment has been minimized.

Show comment
Hide comment
@ahartikainen

ahartikainen Jun 25, 2018

Collaborator

It might be some problem between gcc 4.x and gcc 5.y. Can you try to create a new conda-env and run your model in there

conda create -n stan python=2.7 numpy cython
source activate stan
pip install pystan

edit. bumpy --> numpy

Collaborator

ahartikainen commented Jun 25, 2018

It might be some problem between gcc 4.x and gcc 5.y. Can you try to create a new conda-env and run your model in there

conda create -n stan python=2.7 numpy cython
source activate stan
pip install pystan

edit. bumpy --> numpy

@elena-zamfir

This comment has been minimized.

Show comment
Hide comment
@elena-zamfir

elena-zamfir Jun 25, 2018

Thank you for your reply!
I've just tried this, now I get a g++ failed with exit status 1 error:
(I first copy pasted the command you sent, but I don't have bumpy, I assumed you meant numpy. )

(stan) elena@u236d:~$ python
Python 2.7.15 |Anaconda, Inc.| (default, May 1 2018, 23:32:55)
[GCC 7.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import pystan
schools_code = """
... data {
... int<lower=0> J; // number of schools
... real y[J]; // estimated treatment effects
... real<lower=0> sigma[J]; // s.e. of effect estimates
... }
... parameters {
... real mu;
... real<lower=0> tau;
... real eta[J];
... }
... transformed parameters {
... real theta[J];
... for (j in 1:J)
... theta[j] = mu + tau * eta[j];
... }
... model {
... eta ~ normal(0, 1);
... y ~ normal(theta, sigma);
... }
... """

schools_dat = {'J': 8,
... 'y': [28, 8, -3, 7, -1, 1, 18, 12],
... 'sigma': [15, 10, 16, 11, 9, 11, 10, 18]}

sm = pystan.StanModel(model_code=schools_code)
INFO:pystan:COMPILING THE C++ CODE FOR MODEL anon_model_cbe9cd2f1e5ab5d1c7cce1f23ca970b4 NOW.
Traceback (most recent call last):
File "", line 1, in
File "/nfs/nhome/live/elena/anaconda/envs/stan/lib/python2.7/site-packages/pystan/model.py", line 313, in init
build_extension.run()
File "/nfs/nhome/live/elena/anaconda/envs/stan/lib/python2.7/distutils/command/build_ext.py", line 340, in run
self.build_extensions()
File "/nfs/nhome/live/elena/anaconda/envs/stan/lib/python2.7/distutils/command/build_ext.py", line 449, in build_extensions
self.build_extension(ext)
File "/nfs/nhome/live/elena/anaconda/envs/stan/lib/python2.7/distutils/command/build_ext.py", line 531, in build_extension
target_lang=language)
File "/nfs/nhome/live/elena/anaconda/envs/stan/lib/python2.7/distutils/ccompiler.py", line 691, in link_shared_object
extra_preargs, extra_postargs, build_temp, target_lang)
File "/nfs/nhome/live/elena/anaconda/envs/stan/lib/python2.7/distutils/unixccompiler.py", line 203, in link
raise LinkError, msg
distutils.errors.LinkError: command 'g++' failed with exit status 1

elena-zamfir commented Jun 25, 2018

Thank you for your reply!
I've just tried this, now I get a g++ failed with exit status 1 error:
(I first copy pasted the command you sent, but I don't have bumpy, I assumed you meant numpy. )

(stan) elena@u236d:~$ python
Python 2.7.15 |Anaconda, Inc.| (default, May 1 2018, 23:32:55)
[GCC 7.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import pystan
schools_code = """
... data {
... int<lower=0> J; // number of schools
... real y[J]; // estimated treatment effects
... real<lower=0> sigma[J]; // s.e. of effect estimates
... }
... parameters {
... real mu;
... real<lower=0> tau;
... real eta[J];
... }
... transformed parameters {
... real theta[J];
... for (j in 1:J)
... theta[j] = mu + tau * eta[j];
... }
... model {
... eta ~ normal(0, 1);
... y ~ normal(theta, sigma);
... }
... """

schools_dat = {'J': 8,
... 'y': [28, 8, -3, 7, -1, 1, 18, 12],
... 'sigma': [15, 10, 16, 11, 9, 11, 10, 18]}

sm = pystan.StanModel(model_code=schools_code)
INFO:pystan:COMPILING THE C++ CODE FOR MODEL anon_model_cbe9cd2f1e5ab5d1c7cce1f23ca970b4 NOW.
Traceback (most recent call last):
File "", line 1, in
File "/nfs/nhome/live/elena/anaconda/envs/stan/lib/python2.7/site-packages/pystan/model.py", line 313, in init
build_extension.run()
File "/nfs/nhome/live/elena/anaconda/envs/stan/lib/python2.7/distutils/command/build_ext.py", line 340, in run
self.build_extensions()
File "/nfs/nhome/live/elena/anaconda/envs/stan/lib/python2.7/distutils/command/build_ext.py", line 449, in build_extensions
self.build_extension(ext)
File "/nfs/nhome/live/elena/anaconda/envs/stan/lib/python2.7/distutils/command/build_ext.py", line 531, in build_extension
target_lang=language)
File "/nfs/nhome/live/elena/anaconda/envs/stan/lib/python2.7/distutils/ccompiler.py", line 691, in link_shared_object
extra_preargs, extra_postargs, build_temp, target_lang)
File "/nfs/nhome/live/elena/anaconda/envs/stan/lib/python2.7/distutils/unixccompiler.py", line 203, in link
raise LinkError, msg
distutils.errors.LinkError: command 'g++' failed with exit status 1

@ahartikainen

This comment has been minimized.

Show comment
Hide comment
@ahartikainen

ahartikainen Jun 25, 2018

Collaborator

Hi, sorry,

I first read that your compiler was 4.7, but it is 4.4.7 which does not support c++11. So you should upgrade your gcc. Is there some special reason for that compiler version?

http://pystan.readthedocs.io/en/latest/whats_new.html

https://gcc.gnu.org/projects/cxx-status.html#cxx11

Collaborator

ahartikainen commented Jun 25, 2018

Hi, sorry,

I first read that your compiler was 4.7, but it is 4.4.7 which does not support c++11. So you should upgrade your gcc. Is there some special reason for that compiler version?

http://pystan.readthedocs.io/en/latest/whats_new.html

https://gcc.gnu.org/projects/cxx-status.html#cxx11

@elena-zamfir

This comment has been minimized.

Show comment
Hide comment
@elena-zamfir

elena-zamfir Jun 26, 2018

Thank you for your message.
I've just checked this.
In fact, the python version and the gcc version in the environment are different from the default ones outside the environment. (I don't understand why. I created the environment with conda create -n stan python=2.7 numpy cython)

Also, it seems that the gcc version that python is using is different from the one that I get with gcc --version in the command line.
The error message was about g++ now, but there isn't any g++ version installed, it seems.

In the environment, I have GCC 7.2.0:
(stan) elena@u236d:~$ python
Python 2.7.15 |Anaconda, Inc.| (default, May 1 2018, 23:32:55)
[GCC 7.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.

(stan) elena@u236d:$ gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1
16.04.9) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

(stan) elena@u236d:~$ g++ --version
The program 'g++' is currently not installed. To run 'g++' please ask your administrator to install the package 'g++'

elena-zamfir commented Jun 26, 2018

Thank you for your message.
I've just checked this.
In fact, the python version and the gcc version in the environment are different from the default ones outside the environment. (I don't understand why. I created the environment with conda create -n stan python=2.7 numpy cython)

Also, it seems that the gcc version that python is using is different from the one that I get with gcc --version in the command line.
The error message was about g++ now, but there isn't any g++ version installed, it seems.

In the environment, I have GCC 7.2.0:
(stan) elena@u236d:~$ python
Python 2.7.15 |Anaconda, Inc.| (default, May 1 2018, 23:32:55)
[GCC 7.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.

(stan) elena@u236d:$ gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1
16.04.9) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

(stan) elena@u236d:~$ g++ --version
The program 'g++' is currently not installed. To run 'g++' please ask your administrator to install the package 'g++'

@ahartikainen

This comment has been minimized.

Show comment
Hide comment
@ahartikainen

ahartikainen Jun 26, 2018

Collaborator

The GCC 7.2.0 is referring to the compiler toolset that was used to build python. It is not affecting your gcc usage.

The problem seems to be that you have GCC 5.4.0 on your system, but your anaconda is using GCC 4.4.7 which has ABI incompatibility with 5.4.0. Somewhere there is probably libstdc++ file that is linking to wrong compiler.

Can you install build-essential? Then your virtual environment should work.

sudo apt-get update
sudo apt-get install build-essential

For anaconda, can you update it or install latest version from anaconda.org? This probably will fix the problem with Anaconda environment.

conda update anaconda
Collaborator

ahartikainen commented Jun 26, 2018

The GCC 7.2.0 is referring to the compiler toolset that was used to build python. It is not affecting your gcc usage.

The problem seems to be that you have GCC 5.4.0 on your system, but your anaconda is using GCC 4.4.7 which has ABI incompatibility with 5.4.0. Somewhere there is probably libstdc++ file that is linking to wrong compiler.

Can you install build-essential? Then your virtual environment should work.

sudo apt-get update
sudo apt-get install build-essential

For anaconda, can you update it or install latest version from anaconda.org? This probably will fix the problem with Anaconda environment.

conda update anaconda
@elena-zamfir

This comment has been minimized.

Show comment
Hide comment
@elena-zamfir

elena-zamfir Jun 26, 2018

Thank you!
Now it works in the environment.
I'll try to fix the Anaconda environment as well.

elena-zamfir commented Jun 26, 2018

Thank you!
Now it works in the environment.
I'll try to fix the Anaconda environment as well.

@DKilkenny

This comment has been minimized.

Show comment
Hide comment
@DKilkenny

DKilkenny Aug 16, 2018

You have no idea how much you've helped me. Thank you so much!

DKilkenny commented Aug 16, 2018

You have no idea how much you've helped me. Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment