【问题标题】:Building a Docker Image with rstan on rocker/verse在 Rocker/verse 上使用 rstan 构建 Docker 映像
【发布时间】:2017-03-07 20:36:31
【问题描述】:

我计划在 Digital Ocean 的 Docker 17.03.0-ce on 16.04 上预装 tidyversermarkdownrstan 运行一个定制的 Rstudio。

在 Docker Hub 上,已经有一个预构建的映像:Rocker/verse,它具有 tidyversermarkdown 功能。所以我的计划是简单地获取最新版本的Rocker/verse 并添加一个新的rstan 层。我使用jonzelner/rstanjrnold/rstan的dockerfile并更新如下:

FROM rocker/verse:latest

# Install essentials
RUN apt-get update \ 
    && apt-get install -y --no-install-recommends \
                   clang-3.6

# Global site-wide config
RUN mkdir -p $HOME/.R/ \
    && echo "\nCXX=clang++ -ftemplate-depth-256\n" >> $HOME/.R/Makevars \
    && echo "CC=clang\n" >> $HOME/.R/Makevars

# Install rstan
RUN install2.r --error \
    inline \
    RcppEigen \
    StanHeaders \
    rstan \
    KernSmooth

# Config for rstudio user
RUN mkdir -p /home/rstudio/.R/ \
    && echo "\nCXX=clang++ -ftemplate-depth-256\n" >> /home/rstudio/.R/Makevars \
    && echo "CC=clang\n" >> /home/rstudio/.R/Makevars \
    && echo "CXXFLAGS=-O3\n" >> /home/rstudio/.R/Makevars \
    && echo "\nrstan::rstan_options(auto_write = TRUE)" >> /home/rstudio/.Rprofile \
    && echo "options(mc.cores = parallel::detectCores())" >> /home/rstudio/.Rprofile

# Install loo
RUN install2.r --error \
    matrixStats \
    loo 

但是,我构建此映像 (docker build -t image_name .) 的尝试以错误告终。结果如下:

Sending build context to Docker daemon  2.56 kB
Step 1/6 : FROM rocker/verse:latest
 ---> 7ad7d994bffd
Step 2/6 : RUN apt-get update   && apt-get install -y --no-install-recommends                    clang-3.6
 ---> Using cache
 ---> 77473c759438
Step 3/6 : RUN mkdir -p $HOME/.R/     && echo "\nCXX=clang++ -ftemplate-depth-256\n" >> $HOME/.R/Makevars     && echo "CC=clang\n" >> $HOME/.R/Makevars
 ---> Using cache
 ---> a5b06d28b9fe
Step 4/6 : RUN install2.r --error     inline     RcppEigen     StanHeaders     rstan     KernSmooth
 ---> Running in 86b52d5a76f3
trying URL 'https://cran.rstudio.com/src/contrib/inline_0.3.14.tar.gz'
Content type 'unknown' length 18002 bytes (17 KB)
==================================================
downloaded 17 KB

* installing *source* package ‘inline’ ...
** package ‘inline’ successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (inline)

The downloaded source packages are in
    ‘/tmp/downloaded_packages’
trying URL 'https://cran.rstudio.com/src/contrib/RcppEigen_0.3.2.9.0.tar.gz'
Content type 'unknown' length 1209128 bytes (1.2 MB)
==================================================
downloaded 1.2 MB

* installing *source* package ‘RcppEigen’ ...
** package ‘RcppEigen’ successfully unpacked and MD5 sums checked
** libs
clang++ -ftemplate-depth-256 -I/usr/local/lib/R/include -DNDEBUG  -I/usr/local/include -I"/usr/local/lib/R/site-library/Rcpp/include"  -I../inst/include -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c RcppEigen.cpp -o RcppEigen.o
/bin/bash: clang++: command not found
/usr/local/lib/R/etc/Makeconf:141: recipe for target 'RcppEigen.o' failed
make: *** [RcppEigen.o] Error 127
ERROR: compilation failed for package ‘RcppEigen’
* removing ‘/usr/local/lib/R/site-library/RcppEigen’
Error in install.packages(pkgs = f, lib = lib, repos = if (isMatchingFile(f)) NULL else rep,  :
  installation of package ‘RcppEigen’ had non-zero exit status
The command '/bin/sh -c install2.r --error     inline     RcppEigen     StanHeaders     rstan     KernSmooth' returned a non-zero code: 1

关于具有non-zero exit status 的包的一些类似问题与内存有关,因此我尝试增加本地计算机上的 Docker 内存,但仍然没有运气。我可以做些什么来成功构建此映像吗?

【问题讨论】:

    标签: docker clang rstudio rstan


    【解决方案1】:

    如你在错误输出中看到的,安装过程找不到编译器:

    /bin/bash: clang++: command not found
    

    请注意,这是尝试在 rocker/verse 容器中安装 clang-3.6 的输出:

    root@8ea0d98e67c3:/# apt-get install -y --no-install-recommends clang-3.6
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    Note, selecting 'python-clang-3.6' for regex 'clang-3.6'
    0 upgraded, 0 newly installed, 0 to remove and 15 not upgraded.
    

    该图像的存储库中似乎没有 Clang 3.6。而这个名字却指向python-clang-3.6; Python 编程语言的 Clang 绑定。

    除非你绝对想要 3.6,否则我会安装指向 3.5 的普通 clang 包,然后重新运行 Docker 构建过程。

    apt-get install clang
    

    【讨论】:

      猜你喜欢
      • 2021-08-02
      • 1970-01-01
      • 2020-10-16
      • 1970-01-01
      • 2019-03-25
      • 2019-07-05
      • 2020-07-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多