我有以下图片:
FROM rocker/r-ver:4.1.2
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-utils \
ed \
libnlopt-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/
RUN apt-get update
RUN apt install software-properties-common -y
# https://github.com/stan-dev/rstan/wiki/Configuring-C-Toolchain-for-Linux
RUN add-apt-repository -y ppa:marutter/rrutter4.0
RUN add-apt-repository -y ppa:c2d4u.team/c2d4u4.0+
RUN apt-get update
RUN apt install -y r-cran-rstan
# https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started#installation-of-rstan
RUN Rscript -e 'Sys.setenv(DOWNLOAD_STATIC_LIBV8 = 1); install.packages("rstan", repos = "https://cloud.r-project.org/", dependencies = TRUE)'使用docker build -f Dockerfile -t docker_r_stan_test . (无错误输出)构建映像后,运行:example(stan_model, package = "rstan", run.dontrun = TRUE),我希望看到类似于at:https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started#verify-installation的内容
相反,我得到了输出:
Error in find.package(package, lib.loc, verbose = verbose) :
there is no package called ‘rstan’我在尝试使用library(rstan)时也有类似的错误
> library("rstan")
Error in library("rstan") : there is no package called ‘rstan’我不明白为什么在这个映像中没有正确地安装rstan,因为我似乎已经严格遵循了这些步骤
发布于 2022-01-23 18:13:09
使用Rocker映像安装rstan确实是个好主意,我在博客上(本质上)通过这个较旧的职位中的一个命令来验证它。
你最好的选择,真的,是依赖摇滚乐容器已经为c2d4u.team回购。正如奥利弗在对你的问题的评论中所指出的,这些不是那些(出于自身正当理由)遵循不同内部模式(这使得它们不太适合我们在这里使用的二进制文件)的r-ver图像。
第一个例子: rocker/r-ubuntu:20.04
这个“简单”依赖于这样一个事实,即rstan在这里以二进制包r-cran-rstan的形式存在--所以我们在更新apt索引之后将它安装在一个命令中。
edd@rob:~$ docker run --rm -ti rocker/r-ubuntu:20.04 bash
root@11e89aea64f6:/# apt update -qq
85 packages can be upgraded. Run 'apt list --upgradable' to see them.
root@11e89aea64f6:/# apt install r-cran-rstan
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libpng-tools libtbb2 pandoc pandoc-data r-cran-backports r-cran-bh r-cran-brio r-cran-callr
r-cran-checkmate r-cran-cli r-cran-colorspace r-cran-cpp11 r-cran-crayon r-cran-data.table
r-cran-desc r-cran-diffobj r-cran-digest r-cran-ellipsis r-cran-evaluate r-cran-fansi r-cran-farver
r-cran-fastmatch r-cran-ggplot2 r-cran-glue r-cran-gridextra r-cran-gtable r-cran-inline
r-cran-isoband r-cran-jsonlite r-cran-labeling r-cran-lifecycle r-cran-loo r-cran-magrittr
r-cran-matrixstats r-cran-munsell r-cran-pillar r-cran-pkgbuild r-cran-pkgconfig r-cran-pkgload
r-cran-praise r-cran-prettyunits r-cran-processx r-cran-ps r-cran-r6 r-cran-rcolorbrewer r-cran-rcpp
r-cran-rcppeigen r-cran-rcppparallel r-cran-rematch2 r-cran-rlang r-cran-rprojroot r-cran-rstudioapi
r-cran-scales r-cran-stanheaders r-cran-svglite r-cran-systemfonts r-cran-testthat r-cran-tibble
r-cran-utf8 r-cran-vctrs r-cran-viridislite r-cran-waldo r-cran-withr
Suggested packages:
texlive-latex-recommended texlive-xetex texlive-luatex pandoc-citeproc texlive-latex-extra context
wkhtmltopdf librsvg2-bin groff ghc nodejs php python ruby libjs-mathjax node-katex r-cran-devtools
r-cran-knitr r-cran-rmarkdown r-cran-tinytest r-cran-covr
The following NEW packages will be installed:
libpng-tools libtbb2 pandoc pandoc-data r-cran-backports r-cran-bh r-cran-brio r-cran-callr
r-cran-checkmate r-cran-cli r-cran-colorspace r-cran-cpp11 r-cran-crayon r-cran-data.table
r-cran-desc r-cran-diffobj r-cran-digest r-cran-ellipsis r-cran-evaluate r-cran-fansi r-cran-farver
r-cran-fastmatch r-cran-ggplot2 r-cran-glue r-cran-gridextra r-cran-gtable r-cran-inline
r-cran-isoband r-cran-jsonlite r-cran-labeling r-cran-lifecycle r-cran-loo r-cran-magrittr
r-cran-matrixstats r-cran-munsell r-cran-pillar r-cran-pkgbuild r-cran-pkgconfig r-cran-pkgload
r-cran-praise r-cran-prettyunits r-cran-processx r-cran-ps r-cran-r6 r-cran-rcolorbrewer r-cran-rcpp
r-cran-rcppeigen r-cran-rcppparallel r-cran-rematch2 r-cran-rlang r-cran-rprojroot r-cran-rstan
r-cran-rstudioapi r-cran-scales r-cran-stanheaders r-cran-svglite r-cran-systemfonts r-cran-testthat
r-cran-tibble r-cran-utf8 r-cran-vctrs r-cran-viridislite r-cran-waldo r-cran-withr
0 upgraded, 64 newly installed, 0 to remove and 85 not upgraded.
Need to get 60.7 MB of archives.
After this operation, 345 MB of additional disk space will be used.
Do you want to continue? [Y/n] 第二个例子: rocker/r-bspm:20.04
由于bspm及其集成(以及Inaki和我有一个关于这一点的arXiv文件),它变得更好了,因为我们可以通过_use install.packages() (通过脚本)为我们获取r-cran-rstan:
edd@rob:~$ docker run --rm -ti rocker/r-bspm:20.04 bash
root@ef07add5e9e7:/# apt update -qq
28 packages can be upgraded. Run 'apt list --upgradable' to see them.
root@ef07add5e9e7:/# install.r rstan
(loaded the methods namespace)
Loading required package: utils Tracing function "install.packages" in package "utils"
Install system packages as root...
Reading package lists... Done
Building dependency tree
Reading state information... Done
Hit http://archive.ubuntu.com/ubuntu focal InRelease
Hit http://security.ubuntu.com/ubuntu focal-security InRelease
Hit http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu focal InRelease
Hit http://archive.ubuntu.com/ubuntu focal-updates InRelease
Hit http://archive.ubuntu.com/ubuntu focal-backports InRelease
Hit http://ppa.launchpad.net/edd/r-4.0/ubuntu focal InRelease
Hit http://ppa.launchpad.net/marutter/rrutter4.0/ubuntu focal InRelease
Fetched 0 B in 0s (0 B/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
Get:1 http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu focal/main amd64 r-cran-backports amd64 1.4.1-
1cran1.2004.0 [94.9 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal/main amd64 libpng-tools amd64 1.6.37-2 [26.1 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal/universe amd64 pandoc-data all 2.5-3build2 [76.0 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal/universe amd64 pandoc amd64 2.5-3build2 [15.4 MB]
[... stuff omitted here for brevity ...]
Setting up r-cran-stanheaders (2.21.0-7-1cran1.2004.0) ...
Setting up r-cran-callr (3.7.0-1cran1.2004.0) ...
Setting up r-cran-tibble (3.1.6-1cran1.2004.0) ...
Setting up r-cran-pkgbuild (1.3.1-1cran1.2004.0) ...
Setting up r-cran-ggplot2 (3.3.5-1cran1.2004.0) ...
Setting up r-cran-rstan (2.21.3-1cran1.2004.0) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
root@d3045995c945:/# R
R version 4.1.2 (2021-11-01) -- "Bird Hippie"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
Loading required package: utils
Tracing function "install.packages" in package "utils"
> library(rstan)
Loading required package: StanHeaders
Loading required package: ggplot2
rstan (Version 2.21.3, GitRev: 2e1f913d3ca3)
For execution on a local, multicore CPU with excess RAM we recommend calling
options(mc.cores = parallel::detectCores()).
To avoid recompilation of unchanged Stan programs, we recommend calling
rstan_options(auto_write = TRUE)
> 注意,我们在这里使用install.r --来自利特勒的install.packages()的包装器--指向R包,但是我们得到了二进制文件。一切都取决于。一条条命令。我想我甚至发了一次动画给大家看.
然而,关键的洞见是,所有这些都不局限于码头工人。我在一台小型笔记本电脑上使用bspm方法,在这里我不想从源代码编译。它运行得完美无缺,而且已经运行了几个月。
如果您有问题,请在这里或r-sig-debian列表上通知我们。
编辑:我刚刚创建的动画gif太大了,无法在这里发布(2mb限制),但适合Twitter,所以这里是:https://twitter.com/eddelbuettel/status/1485318710818754567。
https://stackoverflow.com/questions/70824760
复制相似问题