私はlibtorchと一緒にRcppと非常に奇妙な動作をしています。
私は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)
clang ++エラーは次のとおりです。
terminate called after throwing an instance of 'std::length_error'
what(): basic_string::_M_create
Aborted (core dumped)
test_error2
は期待どおりに動作します。
このエラーは、Ubuntu Xenialでのみ発生します。私はUbuntu TrustyとMacOSでテストし、セグメントはありません。
ファイルからtest_error2
のコードを削除した場合、#include <torch/torch.h>
行を削除しなくてもエラーは発生しません。
また、clang ++とg ++でコンパイルをテストしました。同じエラー。
私はsmalllリポジトリを作成しました。ここでは、私が作ることができる最小限の例でを作成しました。
誰がこれが何であるか考えていますか?
configureファイルは、pytorchのウェブサイトから自動的にlibtorchをダウンロードしてインストールします。これを望まない場合は、パッケージをインストールしないでください。