在 Docker 容器 (buster) 上安装 Prophet (pystan build)

Jos*_*der 5 debian build installation

我想在 Docker 容器中安装fbprophet 。我的 Dockerfile 如下所示:

FROM python:3.7

RUN pip install --upgrade pip
RUN pip install fbprophet
Run Code Online (Sandbox Code Playgroud)

使用以下堆栈跟踪在“pip install fbprophet”步骤中构建图像错误:

    Running setup.py install for fbprophet ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-7ei5jssc/fbprophet_9a3a667ec353402389a02258feccfe51/setup.py'"'"'; __file__='"'"'/tmp/pip-install-7ei5jssc/fbprophet_9a3a667ec353402389a02258feccfe51/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-741oj2zp/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.7m/fbprophet
         cwd: /tmp/pip-install-7ei5jssc/fbprophet_9a3a667ec353402389a02258feccfe51/
    Complete output (10 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib
    creating build/lib/fbprophet
    creating build/lib/fbprophet/stan_model
    Importing plotly failed. Interactive plots will not work.
    INFO:pystan:COMPILING THE C++ CODE FOR MODEL anon_model_dfdaf2b8ece8a02eb11f050ec701c0ec NOW.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-7ei5jssc/fbprophet_9a3a667ec353402389a02258feccfe51/setup.py'"'"'; __file__='"'"'/tmp/pip-install-7ei5jssc/fbprophet_9a3a667ec353402389a02258feccfe51/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-741oj2zp/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.7m/fbprophet Check the logs for full command output.
Run Code Online (Sandbox Code Playgroud)

我在网上找到了一些建议,但我尝试过但没有成功(此时我构建了没有容器fbprophet并运行它的容器,因此我可以实时尝试命令):

  1. 这里的问题是gcc/g++ 没有安装
  • 我尝试过apt install g++ gcc,仍然无法构建(它们已经安装了)
  1. pnmartinez 的评论表明缺少一些构建工具
  • 我做了apt-get install build-essential libncursesw5-dev libreadline-gplv2-dev libssl-dev libgdbm-dev libc6-dev libsqlite3-dev libbz2-dev libffi-dev zlib1g-dev(运行后apt-get upgrade,,),并重试,结果相同apt-get updateapt-get dist-upgrade
  1. 此 GH 问题建议降级到pystan==2.18.
  • 在 v0.6 中引入此提交之前 ,Prophet 将自身限制为 PyStan <=2.18.1,因此我尝试了 pip installprophet==0.5,但仍然失败。(我一直降到0.2,仍然失败。)然后我尝试了pip3 uninstall pystan && pip3 install pystan==2.18 && pip3 install fbprophet==0.5相同的结果。
  1. 从 conda-forge 安装
  • 我对此进行了研究,但是在 docker 容器中安装工作 conda env 似乎相当复杂
  1. 我还开始尝试在基于 Alpine 的容器上安装,而不是在 Debian 上安装。
  • 在 Prophet 阶段之前我就开始遇到问题,一般来说,我认为在非标准发行版上构建复杂的 C++ 项目不会更容易。

当 gcc 尝试构建 PyStan 模型时,似乎会出现该问题。我的猜测是,它只是内存不足(cc1plus进程top使用 2GB,大约 90% 的 RAM,有人声称这里最多可以使用 8GB)。然而,这是非常常见的软件,几个月前我成功地使用相同的 Dockerfile 安装了 fbprophet,所以我不确定为什么这会成为一个问题。(我尝试在 macOS (Big Sur) 和 Linux (Fedora 33) 上构建它,结果相同。)

Jos*_*der 4

弄清楚了——因为这是一个内存问题,我只需要为 Docker VM 分配更多内存即可。这个答案解释了如何使用 GUI 来做到这一点。浪费了很多时间...