Shark-ML / Shark

The Shark Machine Leaning Library. See more:
http://shark-ml.github.io/Shark/
GNU Lesser General Public License v3.0
493 stars 130 forks source link

v4.0.0 compilation errors with Visual Studio 2015 #253

Closed John1911603424 closed 5 years ago

John1911603424 commented 5 years ago

严重性 代码 说明 项目 文件 行 禁止显示状态 错误 C2664 “void shark::Ensemble<shark::LinearClassifier ,shark::RealVector>::addModel(const shark::LinearClassifier &,double)”: 无法将参数 1 从“shark::LinearClassifier ”转换为“const shark::LinearClassifier &” Models_Ensemble D:\VS2015\Shark\Shark-4.0.0\Test\Models\Ensemble.cpp 53
错误 C2664 “void shark::Ensemble<shark::LinearModel<shark::RealVector,shark::LinearNeuron> ,void>::addModel(const shark::LinearModel<shark::RealVector,shark::LinearNeuron> &,double)”: 无法将参数 1 从“shark::LinearModel<shark::RealVector,shark::LinearNeuron> ”转换为“const shark::LinearModel<shark::RealVector,shark::LinearNeuron> &” Models_Ensemble D:\VS2015\Shark\Shark-4.0.0\Test\Models\Ensemble.cpp 46
错误(活动) 不存在从 "shark::LinearClassifier " 转换到 "shark::LinearClassifier" 的适当构造函数 Models_Ensemble d:\VS2015\Shark\Shark-4.0.0\Test\Models\Ensemble.cpp 53
错误(活动) 不存在从 "shark::LinearModel<shark::RealVector, shark::LinearNeuron>
" 转换到 "shark::LinearModel<shark::RealVector, shark::LinearNeuron>" 的适当构造函数 Models_Ensemble d:\VS2015\Shark\Shark-4.0.0\Test\Models\Ensemble.cpp 46

Ulfgard commented 5 years ago

We fixed most of the issues in development. i will try to backport later today. For a quick fix, try to replace Ensemble.h with

https://github.com/Shark-ML/Shark/blob/0b1c5a34d9ae63202274595397982f5373641b27/include/shark/Models/Ensemble.h

I am not sure whether there is more breaking, i only compiled with VS2017 yet.

John1911603424 commented 5 years ago

The master version also also have this problem.

Ulfgard commented 5 years ago

its on a development branch:

https://github.com/Shark-ML/Shark/tree/4.1

John1911603424 commented 5 years ago

The CMake's configuration is failed when using v4.1. This version is different from other versions, it seems to need other libraries.

Ulfgard commented 5 years ago

That is why i suggested to replace the Ensemble.h file in 4.0. I would not advise using 4.1 yet, especially as the documentation is not yet updated. In 4.1 there should also be native support for vcpkg which should make the whole process on windows easier.

So just copy https://github.com/Shark-ML/Shark/blob/0b1c5a34d9ae63202274595397982f5373641b27/include/shark/Models/Ensemble.h into your 4.0 include/shark/Models/ and you should be fine there.

Could you nevertheless show me the exact output of CMake? you should be able to copy& paste it here

John1911603424 commented 5 years ago

When I replace the Ensemble.h file in 4.0,I get new errors:

Severity Code Description Project File Line Suppression State Error C2259 'shark::detail::EnsembleImpl<BaseModelType,remora::vector<double,remora::cpu_tag>>': cannot instantiate abstract class RFTutorial D:\VS2015\Shark\Shark-4.0.0\include\shark\Models\Classifier.h 183 Error C2259 'shark::detail::EnsembleImpl<BaseModelType,remora::vector<double,remora::cpu_tag>>': cannot instantiate abstract class Models_Ensemble D:\VS2015\Shark\Shark-4.0.0\include\shark\Models\Classifier.h 183 Error C2259 'shark::detail::EnsembleImpl<BaseModelType,remora::vector<double,remora::cpu_tag>>': cannot instantiate abstract class Models_Ensemble D:\VS2015\Shark\Shark-4.0.0\include\shark\Models\Classifier.h 183 Error C2259 'shark::detail::EnsembleImpl<BaseModelType,remora::vector<double,remora::cpu_tag>>': cannot instantiate abstract class Models_RFClassifier D:\VS2015\Shark\Shark-4.0.0\include\shark\Models\Classifier.h 183 Error C2259 'shark::detail::EnsembleImpl<ModelType,OutputType>': cannot instantiate abstract class Models_Ensemble D:\VS2015\Shark\Shark-4.0.0\include\shark\Models\Classifier.h 183 Error C2259 'shark::Ensemble<shark::LinearClassifier ,shark::RealVector>': cannot instantiate abstract class Models_Ensemble D:\VS2015\Shark\Shark-4.0.0\Test\Models\Ensemble.cpp 27
Error C2259 'shark::Ensemble<shark::LinearModel<shark::RealVector,shark::LinearNeuron>
,void>': cannot instantiate abstract class Models_Ensemble D:\VS2015\Shark\Shark-4.0.0\Test\Models\Ensemble.cpp 23
Error C2259 'shark::Ensemble<shark::LinearModel<shark::RealVector,shark::LinearNeuron>,void>': cannot instantiate abstract class Models_Ensemble D:\VS2015\Shark\Shark-4.0.0\Test\Models\Ensemble.cpp 22
Error C2259 'shark::Ensemble<shark::LinearModel<shark::RealVector,shark::LinearNeuron>,void>': cannot instantiate abstract class Models_Ensemble D:\VS2015\Shark\Shark-4.0.0\Test\Models\Ensemble.cpp 122 Error C2259 'shark::Ensemble<shark::LinearModel<shark::RealVector,shark::LinearNeuron>,void>': cannot instantiate abstract class Models_Ensemble D:\VS2015\Shark\Shark-4.0.0\Test\Models\Ensemble.cpp 159 Error C2039 'type': is not a member of 'global namespace'' RFTutorial D:\VS2015\Shark\Shark-4.0.0\include\shark\Models\Ensemble.h 145 Error C2039 'type': is not a member of 'global namespace'' Models_Ensemble D:\VS2015\Shark\Shark-4.0.0\include\shark\Models\Ensemble.h 145 Error C2039 'type': is not a member of '`global namespace'' Models_RFClassifier D:\VS2015\Shark\Shark-4.0.0\include\shark\Models\Ensemble.h 145 Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int RFTutorial D:\VS2015\Shark\Shark-4.0.0\include\shark\Models\Ensemble.h 145 Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int Models_Ensemble D:\VS2015\Shark\Shark-4.0.0\include\shark\Models\Ensemble.h 145 Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int Models_RFClassifier D:\VS2015\Shark\Shark-4.0.0\include\shark\Models\Ensemble.h 145 Error C2143 syntax error: missing ';' before '<' RFTutorial D:\VS2015\Shark\Shark-4.0.0\include\shark\Models\Ensemble.h 145 Error C2143 syntax error: missing ';' before '<' Models_Ensemble D:\VS2015\Shark\Shark-4.0.0\include\shark\Models\Ensemble.h 145 Error C2143 syntax error: missing ';' before '<' Models_RFClassifier D:\VS2015\Shark\Shark-4.0.0\include\shark\Models\Ensemble.h 145 Error C2334 unexpected token(s) preceding '{'; skipping apparent function body RFTutorial D:\VS2015\Shark\Shark-4.0.0\include\shark\Models\Ensemble.h 145 Error C2334 unexpected token(s) preceding '{'; skipping apparent function body Models_Ensemble D:\VS2015\Shark\Shark-4.0.0\include\shark\Models\Ensemble.h 145 Error C2334 unexpected token(s) preceding '{'; skipping apparent function body Models_RFClassifier D:\VS2015\Shark\Shark-4.0.0\include\shark\Models\Ensemble.h 145

Ulfgard commented 5 years ago

This is not the whole error log. the whole context of the error message is missing, i can not see what is wrong.

Ulfgard commented 5 years ago

i will see to it tomorrow morning!

Ulfgard commented 5 years ago

I have a bit of trouble getting my visual studio 15 compiler to run. I can confirm it works with MSVC 19.15, i just commited the changes.

John1911603424 commented 5 years ago

Have you solved this problem? I don't know how to fix it.

Severity Code Description Project File Line Suppression State Error C2664 'void shark::Ensemble<shark::LinearClassifier ,shark::RealVector>::addModel(const shark::LinearClassifier &,double)': cannot convert argument 1 from 'shark::LinearClassifier ' to 'const shark::LinearClassifier &' Models_Ensemble D:\VS2015\Shark\Shark-4.0.0\Test\Models\Ensemble.cpp 53
Error C2664 'void shark::Ensemble<shark::LinearModel<shark::RealVector,shark::LinearNeuron> ,void>::addModel(const shark::LinearModel<shark::RealVector,shark::LinearNeuron> &,double)': cannot convert argument 1 from 'shark::LinearModel<shark::RealVector,shark::LinearNeuron> ' to 'const shark::LinearModel<shark::RealVector,shark::LinearNeuron> &' Models_Ensemble D:\VS2015\Shark\Shark-4.0.0\Test\Models\Ensemble.cpp 46
Error (active) no suitable constructor exists to convert from "shark::LinearClassifier " to "shark::LinearClassifier" Models_Ensemble d:\VS2015\Shark\Shark-4.0.0\Test\Models\Ensemble.cpp 53
Error (active) no suitable constructor exists to convert from "shark::LinearModel<shark::RealVector, shark::LinearNeuron>
" to "shark::LinearModel<shark::RealVector, shark::LinearNeuron>" Models_Ensemble d:\VS2015\Shark\Shark-4.0.0\Test\Models\Ensemble.cpp 46

Ulfgard commented 5 years ago

you can try our 4.0 branch:

https://github.com/Shark-ML/Shark/tree/4.0

I am still working on it, but i think i fixed the errors you mentioned.

John1911603424 commented 5 years ago

This problem appeared in v4.0.0.

Ulfgard commented 5 years ago

I know. therefore i am commiting changes to 4.0 just now. This will be a new release 4.0.1 once we get this to work on windows.

John1911603424 commented 5 years ago

I get it. I will try v4.0.1. Thank you!

Ulfgard commented 5 years ago

https://github.com/Shark-ML/Shark/releases/tag/v4.0.1

there you go!

John1911603424 commented 5 years ago

The v4.0.1 get new error when using CMake configure it. Selecting Windows SDK version to target Windows 10.0.10240. Will build: Release CMake Warning at D:/VS2015/cmake/share/cmake-3.11/Modules/FindBoost.cmake:798 (message): New Boost version may have incorrect or missing dependencies and imported targets Call Stack (most recent call first): D:/VS2015/cmake/share/cmake-3.11/Modules/FindBoost.cmake:903 (_Boost_COMPONENT_DEPENDENCIES) D:/VS2015/cmake/share/cmake-3.11/Modules/FindBoost.cmake:1571 (_Boost_MISSING_DEPENDENCIES) CMakeLists.txt:147 (find_package)

CMake Warning at D:/VS2015/cmake/share/cmake-3.11/Modules/FindBoost.cmake:798 (message): New Boost version may have incorrect or missing dependencies and imported targets Call Stack (most recent call first): D:/VS2015/cmake/share/cmake-3.11/Modules/FindBoost.cmake:903 (_Boost_COMPONENT_DEPENDENCIES) D:/VS2015/cmake/share/cmake-3.11/Modules/FindBoost.cmake:1571 (_Boost_MISSING_DEPENDENCIES) CMakeLists.txt:147 (find_package)

CMake Warning at D:/VS2015/cmake/share/cmake-3.11/Modules/FindBoost.cmake:798 (message): New Boost version may have incorrect or missing dependencies and imported targets Call Stack (most recent call first): D:/VS2015/cmake/share/cmake-3.11/Modules/FindBoost.cmake:903 (_Boost_COMPONENT_DEPENDENCIES) D:/VS2015/cmake/share/cmake-3.11/Modules/FindBoost.cmake:1571 (_Boost_MISSING_DEPENDENCIES) CMakeLists.txt:147 (find_package)

Boost version: 1.67.0 Found the following Boost libraries: serialization filesystem system Using boost from OpenMP found HDF5 not found, skip No usable CBLAS Library found. No fast linear Algebra used. CMake Error at CMakeLists.txt:333 (find_package): By not providing "FindCLBlast.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "CLBlast", but CMake did not find one.

Could not find a package configuration file provided by "CLBlast" with any of the following names:

CLBlastConfig.cmake
clblast-config.cmake

Add the installation prefix of "CLBlast" to CMAKE_PREFIX_PATH or set "CLBlast_DIR" to a directory containing one of the above files. If "CLBlast" provides a separate development package or SDK, be sure it has been installed.

Configuring incomplete, errors occurred! See also "D:/VS2015/Shark/Shark-4.0.1 Build/CMakeFiles/CMakeOutput.log".

But I compiled successfully in new v4.0. The memory and CPU usage of v4.0 are both reduced in the random forest approach, but it still takes half an hour to train 500,000 samples

John1911603424 commented 5 years ago

The sklearn just takes 1 minutes to train 500000 samples. So how should I speed it up?

Ulfgard commented 5 years ago

i think you have an ENABLE_CLBLAST=ON somewhere, because by default the line that fails in your code is not executed.

Have you made sure that you compiled in release mode? In Debug, everything is slow.

Ulfgard commented 5 years ago

I have just benchmarked on covtype with 400k data points.

without computing OOBerror and feature importance after training, the program takes 15 seconds on 12 cores. with OOB error and features importance it is roughly 3.5 minutes(mostly single threaded). So there is still some optimization that can be done.

John1911603424 commented 5 years ago

Yes, you are right. It is my fault. Thank you for your help!