1

我正在努力让 daal 在我的项目中工作,现在遇到了以下错误 - 我正在努力理解它,甚至不确定从哪里开始调试。

我正在尝试复制此网站的代码:https ://www.codeproject.com/Articles/1151606/Lightning-Fast-R-Machine-Learning-Algorithms但在 Windows 10 中,并拥有以下软件(完全按照网站):

  • 英特尔 DAAL 2017 Beta 更新 1
  • R 版本 3.3.1(头发中的虫子)
  • rcpp 包版本 0.12.5
  • 内联包版本 0.3.14
  • e1071 包版本 1.6-7

我做了以下事情:

以下是我遇到的错误 - 请在我苦苦挣扎时帮助我!

        file473877c213b9.cpp: In function 'SEXPREC* file473877c213b9(SEXP, SEXP)':
        file473877c213b9.cpp:37:49: error: incomplete universal character name \U
              std::string fname = Rcpp::as<std::string>(-"C:\Users\Documents\BAJAJ.csv");
                                                     ^
    file473877c213b9.cpp:37:49: warning: unknown escape sequence: '\D'
    file473877c213b9.cpp:37:49: warning: unknown escape sequence: '\B'
    file473877c213b9.cpp:37:49: error: wrong type argument to unary minus
    file473877c213b9.cpp:38:29: error: no matching function for call to 'as(int)'
          int k = Rcpp::as<int>(7);
---------------------------------------------------------------------------------

        make: *** [file473877c213b9.o] Error 1
    Warning message:
    running command 'make -f "C:/R/R-33~1.1/etc/x64/Makeconf" -f "C:/R/R-33~1.1/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="file473877c213b9.dll" WIN=64 TCLBIN=64 OBJECTS="file473877c213b9.o"' had status 2 
---------------------------------------------------------------------------------

    Error in compileCode(f, code, language = language, verbose = verbose) : 
      Compilation ERROR, function(s)/method(s) not created! In file included from file3f9022477144.cpp:3:0:
    C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.1.143\windows\daal\include\daal.h:25:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
     #pragma warning(disable:809)
     ^
    C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.1.143\windows\daal\include\daal.h:38:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
         #pragma comment(lib, "tbb.lib" )
     ^
    C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.1.143\windows\daal\include\daal.h:39:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
         #pragma comment(lib, "tbbmalloc.lib" )
     ^
    In file included from C:/R/R-33~1.1/include/data_management/data/data_dictionary.h:35:0,
                     from C:/R/R-33~1.1/include/data_management/data_source/data_source.h:33,
                     from C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.1.143\windows\daal\in
    In addition: Warning message:
    running command 'C:/R/R-33~1.1/bin/x64/R CMD SHLIB file3f9022477144.cpp 2> file3f9022477144.cpp.err.txt' had status 1 

非常感谢任何人都可以提供的任何帮助(我不是编码员,所以我很挣扎!)

凯尔


编辑 2018 年 7 月 21 日-摘录我的代码以提供更多详细信息

library(Rcpp)
library(inline)

# Create and register a Rcpp plugin
plug <- Rcpp:::Rcpp.plugin.maker(
     include.before = "#include <C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2017.1.143\\windows\\daal\\include\\daal.h> ",
     libs = paste("/Qdaal[-C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2017.1.143\\windows\\daal\\lib\\intel64_win\\daal_core.lib]",
         "/Qdaal[-C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2017.1.143\\windows\\daal\\lib\\intel64_win\\daal_thread.lib]", sep=""))
registerPlugin("daalNB", plug)


# load data
readCSV <- '
     using namespace daal;
     using namespace daal::data_management;

     // Inputs:
     // file - file name
     // ncols - number of columns in file
     std::string fname = Rcpp::as<std::string>("C://Users//Documents//BAJAJ.csv");
     int k = Rcpp::as<int>(7);......***rest of the code as per the website referenced above, ie same code for the readCSV, train and predict functions***

实际调用函数的函数:

# R function for loading data and labels
loadData <- cxxfunction(signature(file="character", ncols="integer"),readCSV, plugin="daalNB")

# R function for training a model
nbTrain <- cxxfunction(signature(X="raw", y="raw", nclasses="integer"),
                       train, plugin="daalNB")

# R function for scoring
nbPredict <- cxxfunction(signature(model="raw", X="raw", nclasses="integer"),
                         predict, plugin="daalNB")

我遇到的与 readCSV <- 函数有关的错误:

C:/Users/Documents/R/win-library/3.3/Rcpp/include/Rcpp/as.h:151:29: note:   template argument deduction/substitution failed:
file40e81ac24329.cpp:36:89: note:   cannot convert '"C://Users//Documents//BAJAJ.csv"' (type 'const char [40]') to type 'SEXP'
      std::string fname = Rcpp::as<std::string>("C://Users//Documents//BAJAJ.csv");
                                                                                         ^
file40e81ac24329.cpp:37:29: error: no matching function for call to 'as(int)'
      int k = Rcpp::as<int>(7);

make: *** [file40e81ac24329.o] Error 1
Warning message:
running command 'make -f "C:/R/R-33~1.1/etc/x64/Makeconf" -f "C:/R/R-33~1.1/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="file40e81ac24329.dll" WIN=64 TCLBIN=64 OBJECTS="file40e81ac24329.o"' had status 2 

ERROR(s) during compilation: source code errors or compiler configuration errors!

以下错误摘要在 R Studio 控制台中以红色显示:

Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! In file included from file40e81ac24329.cpp:3:0:
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.1.143\windows\daal\include\daal.h:25:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning(disable:809)
 ^
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.1.143\windows\daal\include\daal.h:38:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
     #pragma comment(lib, "tbb.lib" )
 ^
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.1.143\windows\daal\include\daal.h:39:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
     #pragma comment(lib, "tbbmalloc.lib" )
 ^
In file included from C:/R/R-33~1.1/include/data_management/data/data_dictionary.h:35:0,
                 from C:/R/R-33~1.1/include/data_management/data_source/data_source.h:33,
                 from C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.1.143\windows\daal\in
In addition: Warning message:
running command 'C:/R/R-33~1.1/bin/x64/R CMD SHLIB file40e81ac24329.cpp 2> file40e81ac24329.cpp.err.txt' had status 1

编辑 - 2018 年 7 月 23 日

我按照 Ralf 的建议对 csv 路径进行了更改,并在 Makevars.win 文件中插入了以下内容:

CXX=C:/IntelSWTools2018/compilers_and_libraries_2018.3.210/windows/bin/intel64/icl.exe

CXXFLAGS=-I"C:/IntelSWTools2018/compilers_and_libraries_2018.3.210/windows/daal/include" -I"C:/IntelSWTools2018/compilers_and_libraries_2018.3.210/windows/compiler/include" -I"C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/ucrt" -I"C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include

现在收到以下错误:

Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! Intel(R) C++ Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 18.0.3.210 Build 20180410
Copyright (C) 1985-2018 Intel Corporation.  All rights reserved.

icl: NOTE: The evaluation period for this product ends on 4-aug-2018 UTC.
compilation aborted for file35d0134c2a9d.cpp (code 2)
make: *** [file35d0134c2a9d.o] Error 2
Warning message:
running command 'make -f "C:/R/R-33~1.1/etc/x64/Makeconf" -f "C:/R/R-33~1.1/share/make/winshlib.mk" -f "C:/Users/Documents/.R/Makevars.win" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="file35d0134c2a9d.dll" WIN=64 TCLBIN=64 OBJECTS="file35d0134c2a9d.o"' had status 2 
In addition: Warning message:
running command 'C:/R/R-33~1.1/bin/x64/R CMD SHLIB file35d0134c2a9d.cpp 2> file35d0134c2a9d.cpp.err.txt' had status 1

我可以在代码中看到几行暗示了一些问题,但无法确定这些问题的开头或结尾:

C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include/xmmintrin.h(61): error #2277: invalid definition of __m128; use #include "xmmintrin.h" instead
C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include/xlocale(341): warning #583: C++ exception handler found but /EHsc option was not specified
C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include/xlocale(367): warning #583: C++ exception handler found but /EHsc option was not specified
C:/Users/Documents/R/win-library/3.3/Rcpp/include/Rcpp/internal/NAComparator.h(62): error: expected a ")"
C:/Users/Documents/R/win-library/3.3/Rcpp/include/Rcpp/r_cast.h(32): warning #583: C++ exception handler found but /EHsc option was not specified
C:/Users/Documents/R/win-library/3.3/Rcpp/include/Rcpp/module/Module_generated_CppFunction.h(53): warning #583: C++ exception handler found but /EHsc option was not specified
C:/Users/Documents/R/win-library/3.3/Rcpp/include/Rcpp/module/Module_generated_CppFunction.h(93): warning #583: C++ exception handler found but /EHsc option was not specified
C:/Users/Documents/R/win-library/3.3/Rcpp/include/Rcpp/api/meat/module/Module.h(40): warning #583: C++ exception handler found but /EHsc option was not specified
C:/Users/Documents/R/win-library/3.3/Rcpp/include/Rcpp/api/meat/module/Module.h(40): warning #583: C++ exception handler found but /EHsc option was not specified
C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include/xstring(2195): warning #583: C++ exception handler found but /EHsc option was not specified

编辑 2018 年 7 月 25 日

现在已经回到网站中提到的确切软件包 daal 版本(非常旧!),并根据 Ralf 的建议更改了 CSV 路径,并且收到以下编译错误:

    Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! file2ddc1463da6.o:file2ddc1463da6.cpp:(.text+0x2e6): undefined reference to `daal::data_management::interface1::SerializationIface::serialize(daal::data_management::interface1::InputDataArchive&)'
file2ddc1463da6.o:file2ddc1463da6.cpp:(.text+0x304): undefined reference to `daal::data_management::interface1::SerializationIface::serialize(daal::data_management::interface1::InputDataArchive&)'
file2ddc1463da6.o:file2ddc1463da6.cpp:(.text$_ZN4daal15data_management10interface118SerializationIfacenwEy[_ZN4daal15data_management10interface118SerializationIfacenwEy]+0x16): undefined reference to `daal::services::daal_malloc(unsigned long long, unsigned long long)'
file2ddc1463da6.o:file2ddc1463da6.cpp:(.text$_ZN4daal15data_management10interface118SerializationIfacenaEy[_ZN4daal15data_management10interface118SerializationIfacenaEy]+0x16): undefined reference to `daal::services::daal_malloc(unsigned long long, unsigned long long)'
fi

这些的来源是大量的行,例如:

file2ddc1463da6.o:file2ddc1463da6.cpp:(.text+0x2e6): undefined reference to `daal::data_management::interface1::SerializationIface::serialize(daal::data_management::interface1::InputDataArchive&)'
file2ddc1463da6.o:file2ddc1463da6.cpp:(.text+0x304): undefined reference to `daal::data_management::interface1::SerializationIface::serialize(daal::data_management::interface1::InputDataArchive&)'
file2ddc1463da6.o:file2ddc1463da6.cpp:(.text$_ZN4daal15data_management10interface118SerializationIfacenwEy[_ZN4daal15data_management10interface118SerializationIfacenwEy]+0x16): undefined reference to `daal::services::daal_malloc(unsigned long long, unsigned long long)'
file2ddc1463da6.o:file2ddc1463da6.cpp:(.text$_ZN4daal15data_management10interface118SerializationIfacenaEy[_ZN4daal15data_management10interface118SerializationIfacenaEy]+0x16): undefined reference to `daal::services::daal_malloc(unsigned long long, unsigned long long)'
file2ddc1463da6.o:file2ddc1463da6.cpp:(.text$_ZN4daal15data_management10interface118SerializationIfacedlEPvy[_ZN4daal15data_management10interface118SerializationIfacedlEPvy]+0x15): undefined reference to `daal::services::daal_free(void*)'
4

1 回答 1

1

您需要使用该Rcpp::as函数在 R 内部数据类型 ( SEXP) 和普通 C++ 数据类型 ( int, string, ...) 之间进行转换。当您将参数从 R 传递到 C++ 函数时,这是需要的。由于您在 C++ 代码中指定了参数,因此不需要此函数。以下应该在您的readCsv函数中起作用:

std::string fname = "C:/Users/Documents/BAJAJ.csv";
int k = 7;

或者,您可以坚持使用从 R 传入这些参数的教程中的版本。

顺便说一句,你不需要加倍/。仅\具有特殊含义,必须加倍才能指代字面版本。

于 2018-07-21T11:47:07.853 回答