#VS2019 – ML.NET Model Builder GPU vs CPU test: 4 times faster !

Buy Me A Coffee

Hi !

Yesterday I wrote about the new options that we have to train models in ML.Net Model Builder. The main new is that we have the option to use our GPU to train models.

Quick recap, Model Builder supports 3 specific training environments

  • Local (CPU)
  • Local (GPU)
  • Azure

Yesterday I tested train a small image recognition model using CPU and GPU and the training time were very similar. The image training set was small, and I also haven’t configured my GPU & CUDA environment, so I decided to raise my own bet and test with something a little more challenging.

For this new test, I’ll use a set of images from a Kaggle challenge [State Farm Distracted Driver Detection] (see references). This is a 1GB image set, 22424images, with ten categories.

Of course, I used Model Builder to train an Image Classifier scenario, here is a preview of the configuration:

CPU Training

This training scenario was much more resource heavy than yesterday easy test. The total time was 39.2 minutes. Here is more detail

Total experiment time : 2353.6729442 Secs
------------------------------------------------------------------------------------------------------------------
|                                                     Summary                                                    |
------------------------------------------------------------------------------------------------------------------
|ML Task: image-classification                                                                                   |
|Dataset: C:\Users\bruno\AppData\Local\Temp\5e873581-2dab-4d46-911d-cfc0a0455eb1.tsv                             |
|Label : Label                                                                                                   |
|Total experiment time : 2353.6729442 Secs                                                                       |
|Total number of models explored: 1                                                                              |
------------------------------------------------------------------------------------------------------------------

GPU Train

Using the GPU, we have 1/4 time over CPU! 9.6 minutes.

Total experiment time : 581.1946062 Secs
------------------------------------------------------------------------------------------------------------------
|                                                     Summary                                                    |
------------------------------------------------------------------------------------------------------------------
|ML Task: image-classification                                                                                   |
|Dataset: C:\Users\bruno\AppData\Local\Temp\cccb2b3f-dbce-45e5-b17e-872b6cc3f116.tsv                             |
|Label : Label                                                                                                   |
|Total experiment time : 581.1946062 Secs                                                                        |
|Total number of models explored: 1                                                                              |
------------------------------------------------------------------------------------------------------------------

Conclusion

GPUs are great for deep learning because the type of calculations they were designed to process are the same as those encountered in deep learning. Images, videos, and other graphics are represented as matrices so that when you perform any operation, such as a zoom-in effect or a camera rotation, all you are doing is applying some mathematical transformation to a matrix.

Even if you have a non-powerful GPU (like me!), you may want to give it a try when you are training a model. ML.Net Model Builder documentation includes a series of steps to configure a CUDA 10.0 environment, which is good enough for most NVIDIA Graphic Cards.

Happy coding!

Greetings

El Bruno

References

5 thoughts on “#VS2019 – ML.NET Model Builder GPU vs CPU test: 4 times faster !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.