本文介绍了RcppArmadillo + bigmemory使Windows RStudio崩溃(但没有其他GUI + OS.type)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究R包, bigKRLS . bigKRLS 在Windows RGui上有效,但在Windows RStudio上遇到致命错误.一些细节...

I'm working on an R package, bigKRLS. bigKRLS works on Windows RGui but encounters a fatal error on Windows RStudio. Some details...

Windows RGui可以运行,但是Windows RStudio遇到致命错误;在使用R 3.3.0、3.3.1、3.3.3的四台不同机器上确认;遵循无涂层教授推荐的最佳实践的RTools 3.3和3.4 ; RStudio 1.0.136; Windows 7和8.目前, bigKRLS 可以在Mac OS X Yosemite和Ubuntu 14.04的RStudio上使用问题.

Windows RGui works but Windows RStudio encounters a fatal error; confirmed on four different machines using R 3.3.0, 3.3.1, 3.3.3; RTools 3.3 and 3.4 following the best practices recommended by the Coatless Professor; RStudio 1.0.136; Windows 7 and 8. Presently, bigKRLS works on RStudio for Mac OS X Yosemite and Ubuntu 14.04 without issue.

bigKRLS 取决于 bigmemory Rcpp RcppArmadillo snow (但问题早于最近添加的 snow ,可以通过设置bigKRLS(..., Ncores = 1)将其禁用以进行测试.

bigKRLS depends on bigmemory, Rcpp, RcppArmadillo, and snow (but the problem pre-dates the recent addition of snow, which can be disabled for testing purposes by setting bigKRLS(..., Ncores = 1)).

devtools::install_github('rdrr1990/bigKRLS')
library(bigKRLS)
vignette("bigKRLS_basics")

set.seed(2017)
X <- matrix(runif(60), ncol=3)
y <- X %*% 3:1 + rnorm(20)
out <- bigKRLS(y, X)
summary(out)

上面的代码产生的模型估计以R2 = 0.663开头(我们当然估计了其他平台上的许多更复杂的模型).

The code above yields model estimates started with R2 = 0.663 (we've of course estimated lots more complicated models on other platforms).

Windows RStudio加载library(bigKRLS)时不会发出警告; bigKRLS()输出表明已成功清除了数据.除其他外,这意味着 y X 现在为big.matrix objects.然后是第一个真实"步骤:bigKRLS()调用bGaussKernel(),这是会话在两分钟左右后中止的位置.但是bGaussKernel()似乎没有什么错.如果在不到一秒钟的时间内从命令行调用bGaussKernel(),它将运行得很好.实际上,如果初始化bigKRLS()所需的每个变量,则可以在Windows RStudio中运行其所有代码.

Windows RStudio loads library(bigKRLS) without warning; bigKRLS() outputs that it's cleaned the data successfully. Among other things, that means y and X are now big.matrix objects. Then the first "real" step: bigKRLS() calls bGaussKernel(), which is where the session aborts after two minutes or so. But there doesn't seem to be anything wrong with bGaussKernel(). bGaussKernel() runs just fine if called from the command line in under a second. In fact, if you initialize each variable that bigKRLS() requires, you can run all of its code in Windows RStudio.

当前,程序包检测到Windows RStudio的时间被使用并安全退出该功能,而是将用户引导至RGui.任何有关更好的解决方法的建议将不胜感激!

Currently, the package detects when Windows RStudio is being used and safely exits the function, directing users instead to RGui. Any suggestions as to a better a workaround would be greatly appreciated!

推荐答案

首先,Windows上的问题与编译器无关.如果您设法正确地安装了RTools,那么使用 RGUI 的一切都会顺利进行.相反,您遇到的问题似乎是RStudio在其应用程序中使用Boost时意外污染了boost名称空间的调用rsession进程中的= BH"rel =" nofollow noreferrer> BH 程序包. RStudio(@kevinushey更是如此)最近通过创建自定义版本的Boost for RStudio(位于rstudio_boost中)解决了此问题.有关该错误的详细信息和解决方案,请参见 https://github.com/rstudio/rstudio/pull/1061 .

First, the problem on Windows is not related to the compiler. If you managed to install RTools correctly, then everything is going well for using RGUI. Instead, the problem that you are having seems to be with RStudio's use of Boost for their application that accidentally polluted calls to the boost namespace provided by the BH package in the rsession process. RStudio, more so @kevinushey, recently addressed this issue by creating a custom build of Boost for RStudio that lives within rstudio_boost. The details and solution of this error can be found in more depth at https://github.com/rstudio/rstudio/pull/1061.

长话短说,如果确实如此,只需检查RStudio版本是否为>=1.1.129就足够了.为此,您首先需要获取 RStudio每日版本.有了这个,我们就可以引用@DirkEddelbuettel为他神话般的随时得出的解决方案.遇到此问题的软件包.具体来说,为了克服这个问题,他添加了一个简短的isRStudio()函数关于包加载调用每次在将数据交给C ++之前都会使用该函数..

Long story short, if this is indeed the case, simply check if the RStudio version is >=1.1.129 will suffice. To do so, you will first need to get an RStudio daily version. With this in hand, we can reference the solution that @DirkEddelbuettel derived for his fabulous anytime package that was running into this issue. Specifically, to overcome this, he has added a short isRStudio() function on package load and calls the function each time before handing data off into C++.

isRStudio()函数 @DirkEddelbuettel的使用方式为:

The isRStudio() function @DirkEddelbuettel uses is given as:

isRStudio <- if (Sys.getenv("RSTUDIO", unset="0") == "1" &&
                     exists("RStudio.Version") &&
                     ## the following is evil but keeps R CMD check off our back
                     eval(parse(text=paste("RStudio.Version()$Version",
                                           ">=", "\"1.1.129\"")))) TRUE else FALSE

注意:eval(parse(text=...))的使用是为了避免遇到程序包检查问题,例如...

Note: The use of eval(parse(text=...)) is to avoid running into package check issues such as...

.onLoad: no visible global function definition for ‘RStudio.Version’
Undefined global functions or variables:
    RStudio.Version

这篇关于RcppArmadillo + bigmemory使Windows RStudio崩溃(但没有其他GUI + OS.type)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 00:57