stan-dev / stan

Stan development repository. The master branch contains the current release. The develop branch contains the latest stable development. See the Developer Process Wiki for details.
https://mc-stan.org
BSD 3-Clause "New" or "Revised" License
2.59k stars 370 forks source link

Compilation errors installing pystan using Python 3.9 on Ubuntu 18.04 #3122

Closed john-bodley closed 2 years ago

john-bodley commented 2 years ago

Summary:

Build error when trying to install pystan using Python 3.9 on Ubuntu 18.04.

Description:

I'm running into a very similar issue to this when trying to install pystan using Python 3.9 on Ubuntu 18.04 (non-supported). Note using the same build environment previously worked when using Python 3.8.

I initially thought the error (see below) might be because I wasn't using a C++14 compatible C++ compiler, though even after installing gcc-9—which is listed as a compatible compiler—the problem persisted and thus I'm somewhat at a loss as to how to resolve the issue.

Reproducible Steps:

add-apt-repository ppa:ubuntu-toolchain-r/test
apt-get update && apt-get install --yes \
    build-essentials \
    gcc-9

update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 0
update-alternatives --set gcc /usr/bin/gcc-9

python3.9 -m pip install pystan==2.19.1.1

Current Output:

>>> gcc --version
gcc (Ubuntu 9.4.0-1ubuntu1~18.04) 9.4.0
>>> python3.9 -m pip install pystan==2.19.1.1
...
Running setup.py install for pystan: started
Running setup.py install for pystan: still running...
Running setup.py install for pystan: finished with status 'error'
ERROR: Command errored out with exit status 1:
...
pystan/stan/src/stan/lang/generator/generate_indexed_expr.hpp: In instantiation of ‘void stan::lang::generate_indexed_expr(const string&, const std::vector<stan::lang::expression>&, stan::lang::bare_expr_type, bool, std::ostream&) [with bool isLHS = false; std::__cxx11::string = std::__cxx11::basic_string<char>; std::ostream = std::basic_ostream<char>]’:
pystan/stan/src/stan/lang/generator/expression_visgen.hpp:117:54:   required from here
pystan/stan/src/stan/lang/generator/generate_indexed_expr.hpp:44:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
           && base_type.num_dims() == indexes.size()) {
              ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
x86_64-linux-gnu-gcc: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
error: Command "x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv

Note I'm somewhat perplex why the URL mentions gcc-7 where clearly gcc-9 is the manually set default gcc compiler.

Expected Output:

The build of the stan library should complete successfully.

Additional Information:

N/A.

Current Version:

v2.29.2

WardBrian commented 2 years ago

The error mentions x86_64-linux-gnu-gcc, which sounds like something installed via conda or something other than apt. If you run x86_64-linux-gnu-gcc —version I suspect it will be 7.

I believe this is controlled by the CC environment variable, so you may have success with CC=gcc pip …

PyStan 2 is no longer in development, so I am closing this issue. If you need further assistance you can use the Stan forums or slack channel

andrjohns commented 2 years ago

You can also see errors like: internal compiler error: Killed (program cc1plus) when you have insufficient RAM available in the system. So keep an eye on the memory usage while installing and if it's hitting at/near 100%, then that might be your issue