-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OutOfMemory Exception in F64Matrix constructor - maximum array bounds exceeded #59
Comments
Hi @fstandhartinger, Thanks for your kind words and thanks for reporting the issue! There are a few other issues also related to the matrix implementation: The current implementation is something that will need to change in the future, partly because of issues like this, but also to support something more general like Tensors for neural networks and other machine learning algorithms. Regarding the specific issue, you should be able to create an array of size As the stackoverflow posts also mention, there is or at least was a default max size of 2 gigabytes for objects, but using 64 bit and the gcAllowVeryLargeObjects, this can be switched off. I think they might have changed this setting to be on by default for .net core applications, but at least if you are implementing a .net framework application, this might be useful. Hope this can help in both short term and long term Best regards |
Thanks @mdabros, good to know you are planning to switch to a more flexible approach to store observations and targets. Regarding backends: What do you think about adding XGBoost as a backend for gradient boosting at some point? I think it's a shame that today there is no proper way to use one of the leading machine learning libs out there with .NET (except an outdated .NET wrapper). I don't get why Microsoft isn't jumping on the train here and provides a propper interface to strengthen its .NET developer community, actually. Big plus of XGBoost would be GPU accelleration and quite optimized memory usage, IMHO. Best regards |
@fstandhartinger Adding a backend or interface to one of the leading gradient boost libraries is definitely something I want to do. My initial choice would be LightGBM from Microsoft, and I have opened an issue on this on their github page: microsoft/LightGBM#763. LightGBM also supports GPU, and should be very fast and memory efficient. As the issue describe, I was hoping Microsoft and the authors would create a simple .net wrapper and a nuget package I could use from SharpLearning. However, it does not seem to be a priority for them at the moment. Like you, I also don't understand why Microsoft isn't providing proper interfacing for machine learning in .NET. I hope that they will eventually jump on the train, and that it won't be too late when they do. Once the work on the neural net backend is completed, I will start to look at gradient boost again. I think gradient boost is still a very valid choice for many ML problems, even in this age of "deep learning". Best regards |
Hi Mads,
thanks for the quick reply!
You are right, LightGBM seems like an excellent choice for a Gradient Boost backend.
I added another comment to the LightGBM nuget issue.
I hope it's not too unsympathetic to rant like that about their .NET development support, but I have mild hopes that complaints have a positive effect on their priorization choices.
I am certainly far from your machine learning expertise but as far as I know gradient boosted trees still win a considerable amount of machine learning competitions, especially when it comes to structured / non cognitive data, so I believe its actually a quite important technique.
I'll keep you updated if I find a nice and solid solution for wrapping LightGBM into managed code!
Best regards
Florian
|
Hi Florian, I think it's find to apply some moderate pressure to Microsoft, in the end they did listen to the community regarding C# support for CNTK, so hopefully the same will happen with LightGBM. I completely agree with you regarding gradient boosted trees, it is still a very important and useful technique for many problem types. Looking forward to hearing some good news about the LightGBM C# wrapper :-) Best regards |
Hi Mads, I created a .NET Wrapper for LightGBM, based on the executables. => Here it is: LightGbmDotNet I tried to hide/encapsulate the fact that it is based on the LightGbm executable as good as I could, I think for most usecases it shouldn't be a problem for the end user. The exceutable will be started in an invisible way, all meta output from LightGBM will be handled (errors are thrown as exceptions, verbose info output represented as log text) and temp files will automatically be removed after use. There is no need to install or download or compile anything from LightGBM, because the native dlls and exes are embedded in the LightGbmDotNet library. Its still missing a Nuget package, a unit test and an example, but downloading the project and getting it to run should be pretty straight forward. Best regards Florian PS.: I designed the methods to take an
|
Thanks for contributing with the LightGbmDotNet wrapper. I will definitely try it out, and make some experiments using it. I could imagine using it in conjunction with some hyper parameter tuning for my next Kaggle competition on structured data. As I mention in microsoft/LightGBM#763, I would prefer a direct wrapping of the native dll using pinvoke or similar when LightGBM is to be included in SharpLearning. This would make for a more complete solution in my opinion. But I think it is a step in the right direction, and for many developers, I think the solution you have made with the executable will be a great help to access LightGBM from .net. Best regards |
Hi @mdabros, thank you! Yes, I totally agree, a pinvoke based wrapper would be a lot better. And I also agree that the issue at MS should be left open, I feel it would be the natural solution that they offer bindings for .NET. I consider upgrading the LightGbmDotNet project to directly call into dll functions at some point, maybe just changing the code in the back and leaving the interface stable - but for now the executable based version fulfills my need, so for now I'll leave it as it is. Actually I am using it for hyperparameter tuning using your super easy to use Optimizer classes.
Best reagrds Florian |
@fstandhartinger Just to let you know, I have added support for XGBoost via The implementation was possible using the package XGBoost.net, since this had relatively good bindings to the native xgboost lib. At some point I hope a similar package for LightGBM becomes available, then I will add support for that also. best regards |
Hey Mads, sorry for replying so late - I have been on holiday and have just returned. This is excellent news and looks like you have once again done a great job! I will check it out once I find time for it. If the bindings allow transferring data in memory this greatly should improve training/prediction performance, compared to my somewhat clumsy file based LightGbm wrapper. Regarding LightGbm: I haven't checked out the quality of the bindings here, but this project might be a good starting point for a LightGbm wrapper for SharpLearning: LightGBMSharp Also I am wondering how good catboost from Yandex performs in comparison to XGBoost and LightGBM, they claim to be the leading Gradient Boosted Decision Tree library out there but I haven't seen much third party sources that state the same. Best regards Florian |
Hi Florian, No worries, hope you had a good holiday :-) Thanks for linking to the implementation! There are defenitely still some things that could be improved, a few of them is listed in the future work section of the Using SharpLearning.XGBoost wiki page. I have also looked at the
Best regards |
Hi there!
First: Thanks for the great work, excellent design you have there!
I am experiencing an OutOfMemory Exception in the constructor of F64Matrix that does not really come from memory shortage but from the fact that F64Matrix internally uses a single one dimensional double array that can quite easily exceed .NETs internal boundaries of maximum array dimensions.
In my case I tried to create a F64Matrix with 10 mio rows and 55 columns.
My preferred suggestion would be to either abstract the matrix to an IF64Matrix interface that probably only consists of the At() method overloads. This would enable users to provide a custom implementation that is capable of handling larger amounts of data, if needed even by swapping data from and to disk.
Another solution could be to change the internal implementation of F64Matrix to use an array of double arrays, which I believe could also help.
Thanks for your help and keep up the excellent work!
Best regards
Florian
The text was updated successfully, but these errors were encountered: