RStan 卡在“哈希不匹配所以重新编译”确保 Stan 代码以空行结尾
Posted
技术标签:
【中文标题】RStan 卡在“哈希不匹配所以重新编译”确保 Stan 代码以空行结尾【英文标题】:RStan stuck at 'hash mismatch so recompiling' make sure Stan code ends with a blank line 【发布时间】:2018-04-24 13:07:17 【问题描述】:我按照https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started 的说明构建了 rtools 3.4 和 rstan 2.17.3。
我已在下面保存了文件“8schools.stan”:
data
int<lower=0> J; // number of schools
real y[J]; // estimated treatment effects
real<lower=0> sigma[J]; // s.e. of effect estimates
parameters
real mu;
real<lower=0> tau;
real eta[J];
transformed parameters
real theta[J];
for (j in 1:J)
theta[j] = mu + tau * eta[j];
model
target += normal_lpdf(eta | 0, 1);
target += normal_lpdf(y | theta, sigma);
但是当我调用代码时:
library(rstan)
rstan_options(auto_write = TRUE)
options(mc.cores = parallel::detectCores())
schools_dat <- list(J = 8,
y = c(28, 8, -3, 7, -1, 1, 18, 12),
sigma = c(15, 10, 16, 11, 9, 11, 10, 18))
fit <- stan(file = '8schools.stan', data = schools_dat,
iter = 3, chains = 4)
我收到此错误:
hash mismatch so recompiling; make sure Stan code ends with a blank line
In file included from C:/Users/ubashir/Documents/R/win-library/3.4/BH/include/boost/config.hpp:39:0,
from C:/Users/ubashir/Documents/R/win-library/3.4/BH/include/boost/math/tools/config.hpp:13,
from C:/Users/ubashir/Documents/R/win-library/3.4/StanHeaders/include/stan/math/rev/core/var.hpp:7,
from C:/Users/ubashir/Documents/R/win-library/3.4/StanHeaders/include/stan/math/rev/core/gevv_vvv_vari.hpp:5,
from C:/Users/ubashir/Documents/R/win-library/3.4/StanHeaders/include/stan/math/rev/core.hpp:12,
from C:/Users/ubashir/Documents/R/win-library/3.4/StanHeaders/include/stan/math/rev/mat.hpp:4,
from C:/Users/ubashir/Documents/R/win-library/3.4/StanHeaders/include/stan/math.hpp:4,
from C:/Users/ubashir/Documents/R/win-library/3.4/StanHeaders/include/src/stan/model/model_header.hpp:4,
from file1b0858a92ea1.cpp:8:
C:/Users/ubashir/Documents/R/win-library/3.4/BH/include/boost/config/compiler/gcc.hpp:186:0: warning: "BOOST_NO_CXX11_RVALUE_REFERENCES" redefined
# define BOOST_NO_CXX11_RVALUE_REFERENCES
^
<command-line>:0:0: note: this is the location of the previous definition
Error in checkForRemoteErrors(val) :
4 nodes produced errors; first error: unable to load shared object 'C:/Users/ubashir/AppData/Local/Temp/RtmpgJlrXy/file163456d0a16.dll':
LoadLibrary failure: Access is denied.
请帮忙!
==================== 更新=========================== ==================
所以我在 Rtools 3.5 和 rstan 之后重新安装了 R 版本 3.5.1(通过 install.packages())
现在 rstan 因多核支持而失败,如下所示:
library(rstan)
rstan_options(auto_write = TRUE)
options(mc.cores = 8)
fit <- stan(file = '8schools.stan', data = schools_dat,
iter = 3, chains = 4)
有错误:
Loading required namespace: rstudioapi
Error in checkForRemoteErrors(val) :
4 nodes produced errors; first error: unable to load shared object 'C:/Users/ubashir/AppData/Local/Temp/RtmpAtefGs/file241c40952587.dll':
LoadLibrary failure: Access is denied.
但是,如果我将线路更改为单核,我至少可以让代码工作
【问题讨论】:
【参考方案1】:只需在 '8schools.stan' 的末尾添加一个换行符
【讨论】:
我怀疑这是特定于在 RStudio 中运行 rstan,但尚未确认。 @Maelstorm 你好,Maelstorm。我刚刚安装了 Rstan 并收到了与您相同的消息。你有解决方案吗?以上是关于RStan 卡在“哈希不匹配所以重新编译”确保 Stan 代码以空行结尾的主要内容,如果未能解决你的问题,请参考以下文章
无法在 Windows 10 的 Rstudio 中编译 rstan 或 Rcpp 代码