部署预编译的RStan模型并避免重新编译

时间:2017-02-02 22:04:17

标签: shiny rstan

我已经在这几个小时了。

我使用以下代码编译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

0 个答案:

没有答案