prophet icon indicating copy to clipboard operation
prophet copied to clipboard

gcc exit status 4 on stan model build in Docker

Open sms1097 opened this issue 3 years ago • 4 comments

When I try to build the docker container I run into this issue with gcc. Looks to be similar to this issue from earlier that wasn't resolved. During build I use --memory-limit=10000m, but watching memory usage during build it never goes above 4GB.

 => ERROR [ 9/10] RUN python setup.py install                                                                                          19338.7s 
------                                                                                                                                          
 > [ 9/10] RUN python setup.py install:                                                                                                         
#13 0.581 running install                                                                                                                       
#13 0.635 running bdist_egg                                                                                                                     
#13 0.636 running egg_info                                                                                                                      
#13 0.636 creating prophet.egg-info                                                                                                             
#13 0.636 writing prophet.egg-info/PKG-INFO
#13 0.638 writing dependency_links to prophet.egg-info/dependency_links.txt
#13 0.638 writing requirements to prophet.egg-info/requires.txt
#13 0.638 writing top-level names to prophet.egg-info/top_level.txt
#13 0.638 writing manifest file 'prophet.egg-info/SOURCES.txt'
#13 0.679 reading manifest template 'MANIFEST.in'
#13 0.680 no previously-included directories found matching 'prophet/stan_model'
#13 0.680 adding license file 'LICENSE'
#13 0.681 writing manifest file 'prophet.egg-info/SOURCES.txt'
#13 0.682 installing library code to build/bdist.linux-x86_64/egg
#13 0.682 running install_lib
#13 0.682 running build_py
#13 0.682 creating build
#13 0.682 creating build/lib
#13 0.682 creating build/lib/prophet
#13 0.682 creating build/lib/prophet/stan_model
#13 1.948 Importing plotly failed. Interactive plots will not work.
#13 2.551 INFO:pystan:COMPILING THE C++ CODE FOR MODEL anon_model_dfdaf2b8ece8a02eb11f050ec701c0ec NOW.
#13 19330.5 error: command 'gcc' failed with exit status 4
------
executor failed running [/bin/sh -c python setup.py install]: exit code: 1

Running the simpler example from that ticket

import pystan
model_code = 'parameters {real y;} model {y ~ normal(0,1);}'
model = pystan.StanModel(model_code=model_code)  # this will take a minute
y = model.sampling(n_jobs=1).extract()['y']
y.mean()  # should be close to 0

produces the following error

 => ERROR [ 9/10] RUN python test.py                                                                                                    1287.4s
------                                                                                                                                          
 > [ 9/10] RUN python test.py:                                                                                                                  
#13 1.318 INFO:pystan:COMPILING THE C++ CODE FOR MODEL anon_model_5944b02c79788fa0db5b3a93728ca2bf NOW.                                         
#13 1282.4 Traceback (most recent call last):                                                                                                   
#13 1282.4   File "/usr/local/lib/python3.7/distutils/unixccompiler.py", line 118, in _compile                                                  
#13 1282.4     extra_postargs)                                                                                                                  
#13 1282.4   File "/usr/local/lib/python3.7/distutils/ccompiler.py", line 910, in spawn
#13 1282.4     spawn(cmd, dry_run=self.dry_run)
#13 1282.4   File "/usr/local/lib/python3.7/distutils/spawn.py", line 36, in spawn
#13 1282.4     _spawn_posix(cmd, search_path, dry_run=dry_run)
#13 1282.4   File "/usr/local/lib/python3.7/distutils/spawn.py", line 159, in _spawn_posix
#13 1282.4     % (cmd, exit_status))
#13 1282.4 distutils.errors.DistutilsExecError: command 'gcc' failed with exit status 4
#13 1282.4 
#13 1282.4 During handling of the above exception, another exception occurred:
#13 1282.4 
#13 1282.4 Traceback (most recent call last):
#13 1282.4   File "test.py", line 3, in <module>
#13 1282.4     model = pystan.StanModel(model_code=model_code)  # this will take a minute
#13 1282.4   File "/usr/local/lib/python3.7/site-packages/pystan/model.py", line 378, in __init__
#13 1282.4     build_extension.run()
#13 1282.4   File "/usr/local/lib/python3.7/distutils/command/build_ext.py", line 340, in run
#13 1282.4     self.build_extensions()
#13 1282.4   File "/usr/local/lib/python3.7/distutils/command/build_ext.py", line 449, in build_extensions
#13 1282.4     self._build_extensions_serial()
#13 1282.4   File "/usr/local/lib/python3.7/distutils/command/build_ext.py", line 474, in _build_extensions_serial
#13 1282.4     self.build_extension(ext)
#13 1282.4   File "/usr/local/lib/python3.7/distutils/command/build_ext.py", line 534, in build_extension
#13 1282.4     depends=ext.depends)
#13 1282.4   File "/usr/local/lib/python3.7/distutils/ccompiler.py", line 574, in compile
#13 1282.4     self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
#13 1282.4   File "/usr/local/lib/python3.7/distutils/unixccompiler.py", line 120, in _compile
#13 1282.4     raise CompileError(msg)
#13 1282.4 distutils.errors.CompileError: command 'gcc' failed with exit status 4

sms1097 avatar Aug 02 '21 14:08 sms1097

This issue might appears to you, as you have incompatible gcc for the installation, if you can share your Dockerfile and requirement.txt , other developers and me might help you with that. You might install gcc if you don't

RUN apt-get update && \
        apt-get -y install gcc

Thanks hisham.

HishamElamir avatar Aug 10 '21 13:08 HishamElamir

Thanks for responding @HishamElamir! Below is my Dockerfile and requirements.txt. Notice this is what's included in the repo with your added update and gcc install and I get the same error.

FROM python:3.7-stretch

RUN apt-get update && \
    apt-get -y install gcc && \
    apt-get -y install libc-dev

RUN pip install pip==19.1.1

COPY python/requirements.txt .
RUN pip install -r requirements.txt
RUN pip install ipython==7.5.0

COPY . .

WORKDIR python

# RUN python setup.py install
RUN python test.py

WORKDIR /
Cython>=0.22
cmdstanpy==0.9.68
pystan==2.19.1.1
numpy>=1.15.4
pandas>=1.0.4
matplotlib>=2.0.0
LunarCalendar>=0.0.9
convertdate>=2.1.2
holidays>=0.10.2
setuptools-git>=1.2
python-dateutil>=2.8.0
tqdm>=4.36.1

sms1097 avatar Aug 10 '21 22:08 sms1097

Hi @sms1097 , In my case, found that the gcc and python version had sort of compatibility issue that when we chose different versions, simply it works. Another two thing you need to consider:

  • It wasn't building on cloud, but I was able to build on my machine and I didn't knew why.
  • Some packages required g++ too, so you can try to add it.

Hope that I could helped you.

HishamElamir avatar Aug 23 '21 18:08 HishamElamir

This has been resolved in prophet 1.1. You can now pip install prophet directly from PyPI

akosfurton avatar Jun 27 '22 14:06 akosfurton

This has been resolved in prophet 1.1. You can now pip install prophet directly from PyPI

Right, any idea what's been causing this? Been experiencing it with pystan 2.19.1.1 too.