dotnet / machinelearning

ML.NET is an open source and cross-platform machine learning framework for .NET.
https://dot.net/ml
MIT License
8.92k stars 1.86k forks source link

How much faster could this GPU be on AutoML "BinaryClassificationExperiment" than this CPU #6956

Closed jackpotcityco closed 5 months ago

jackpotcityco commented 5 months ago

Hello!

I have a question about if GPU is supported for AutoML "BinaryClassificationExperiment" as seen in my code below.

If so, I wonder in general to get a rough idéa how much faster for example below GPU would be. Notice that I would run the experiment on a dataset with more than 200,000 rows and 100 columns as Training Data. So it is long training times like 20 minutes or longer. (I just took this GPU as an example. If there is better GPUs to use, where I also are interested to use many GPUs as a cluster. Please advice me on that. I would be more than happy)

Memory Type: GDDR6X Chipset/GPU Model: NVIDIA GeForce RTX 3090 Memory Size: 24 GB

Compared to if the experiment would run on my current CPU which is:

i7 - 12800h Total Cores 14 Performance-cores 6 Efficient-cores 8 Total Threads 20 Max Turbo Frequency 4.80 GHz Intel® Turbo Boost Max Technology 3.0 Frequency ‡ 4.80 GHz Performance-core Max Turbo Frequency 4.80 GHz Efficient-core Max Turbo Frequency 3.70 GHz Cache 24 MB Intel® Smart Cache

I use: 32 GB RAM

var experiment = mlContext.Auto().CreateBinaryClassificationExperiment(new BinaryExperimentSettings
                {
                    MaxExperimentTimeInSeconds = 1000,
                    CacheBeforeTrainer = CacheBeforeTrainer.On,
                    MaximumMemoryUsageInMegaByte = 8192, 
                    OptimizingMetric = BinaryClassificationMetric.PositivePrecision
                });
torronen commented 5 months ago

Just a user here. I dont think there is any algorithm able to use GPU out of the box yet (unless something changed recently).

However you can enable GPU support for LightGBM by doing minor code change, compiling the package and updating the lightgbm.dll. The instructions to compile the GPU version is here: https://lightgbm.readthedocs.io/en/stable/GPU-Tutorial.html

There is likely a need to do minor update in Microsoft.ML and recompile, but I have not checked where to update in LightGBM 3.0 For the old version of LightGBM I was able to run it with just this simple change https://github.com/dotnet/machinelearning/issues/6666 but C# wrapper of LightGBM has now probably changed a bit.

I do not think it will be much faster in your case because LightGBM is just one of many algorithms. LightGBM also only uses GPU for one of the 2 phases, if I remember correct. The difference become larger with bigger dataset, and almost no noticeable difference in small datasets. There was also a disadvatnage that I have not been able to run the GPU version with high number of buckets so some parameter combination may fail during training.

michaelgsharp commented 5 months ago

Thanks for answering @torronen. @jackpotcityco I would try what @torronen suggested, but there is no real way to know how much the speedup will be without actually testing it out. Classical machine learning doesn't benefit as much from a GPU as Deep Learning does, so your mileage will vary.