我有RCPP一个非常奇怪的行为,连同libtorch。
我有2个函数的文件:
#include <torch/torch.h>
#include <Rcpp.h>
// [[Rcpp::export]]
void test_error () {
throw std::runtime_error("hi this is my error");
}
// [[Rcpp::export]]
void test_error2 () {
Rcpp::Rcout << torch::arange(1) << std::endl;
}
当我打电话test_error()
我得到一个segfault(G ++):
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Aborted (core dumped)
铛++错误是:
terminate called after throwing an instance of 'std::length_error'
what(): basic_string::_M_create
Aborted (core dumped)
test_error2
按预期工作。
仅发生在Ubuntu Xenial此错误。我与Ubuntu忠实的和MacOS和无段错误的测试。
如果我从文件中删除代码test_error2
,我没有任何错误,即使我不删除#include <torch/torch.h>
线。
也测试用铛++和g ++编译。同样的错误。
我创建了一个小型回购qazxsw POI与小例子,我可以做。
有没有人有什么,这可能是什么想法?
注意配置文件会下载并pytorch网站自动安装libtorch。所以,如果你不希望这样不安装该软件包。
原来,编译它与旧版本Rcpp::stop("hi this is my error");
工作的罚款。
我安装g++
:
g++-4.9
。
编辑使用sudo apt-get install g++-4.9
的.R/Makevars
:
g++-4.9
然后重新编译RCPP和包装。