我已经在这几个小时了。
我用以下代码编译了一个 stan 模型:
model <- stan(file = "model.stan", data = data, save_dso = FALSE, chains = 4, cores = 4, iter = 2000, warmup = 1000)
当我ls
进入当前目录时,我看到了model.rds
,而我以前没有看到它。到目前为止一切都很好。
随后,我通过以下方式使用新参数重新调整该模型:
fit <- stan(file = "model.stan", data = new.data, chains = 1, cores = 1, iter = 4000, warmup = 2000)
此代码在 Shiny 应用程序中运行。在本地,所有工作都按预期进行。
当我将此应用程序部署到 shinyapps.io 时,模型会尝试重新编译(导致 g++ 错误 - 可能是由于内存不足)。无论如何,我不希望这个模型首先重新编译:我希望它使用model.rds
我已经构建的对象。是的,我确实在上传到 shinyapps.io 服务器的文件中包含了这个对象。
我觉得我已经尝试了所有的东西——包括model.rds
显式加载loadRDS
并将其传递给stan(fit = model ...
调用。我错过了什么?
为了完整起见,以下是我在 shinyapps.io 端收到的错误。同样,我不希望这个模型首先重新编译。
Compilation ERROR, function(s)/method(s) not created! In file included from /usr/local/lib/R/site-library/BH/include/boost/config.hpp:39:0,
from /usr/local/lib/R/site-library/BH/include/boost/math/tools/config.hpp:13,
from /usr/local/lib/R/site-library/StanHeaders/include/stan/math/rev/core/var.hpp:7,
from /usr/local/lib/R/site-library/StanHeaders/include/stan/math/rev/core/gevv_vvv_vari.hpp:5,
from /usr/local/lib/R/site-library/StanHeaders/include/stan/math/rev/core.hpp:12,
from /usr/local/lib/R/site-library/StanHeaders/include/stan/math/rev/mat.hpp:4,
from /usr/local/lib/R/site-library/StanHeaders/include/stan/math.hpp:4,
from /usr/local/lib/R/site-library/StanHeaders/include/src/stan/model/model_header.hpp:4,
from file137729fa09.cpp:8:
/usr/local/lib/R/site-library/BH/include/boost/config/compiler/gcc.hpp:186:0: warning: "BOOST_NO_CXX11_RVALUE_REFERENCES" redefined [enabled by default]
# define BOOST_NO_CXX11_RVALUE_REFERENCES
^
<command-line>:0:0: note: this is the location of the previous definition
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make: *** [file137729fa09.o] Error 4