If you are familiar a little bit with deep learning, you probably know how computationally expensive it is. And training a model in your computer, or I should say “in your CPU” with a lot of parameters is very time consuming. And you might also know, in order to train a complex model like that, you need a graphics card, or you can say a GPU. Specially Nvidia’s GPU as they are more compatible (and relatively faster) than other GPU’s with most of the programming languages. Frankly speaking with python.
So is it necessary for you to buy these thousand dollar machines to accomplish your task ? Well no. In this article I will tell you how you can train these complex deep learning models without physically having a GPU by using some services (which indeed use GPU, remember its impossible to train deep learning models without it).
Before diving in, lets see the differences between GPU and CPU
GPU vs CPU
|It breaks a job into different parts(threads) and process each simultaneously. This is called parallel computing||Is unable to do such thing|
|It has more cores (computing unit) than CPU||Has lesser cores.|
|Requires less memory||Requires a lot of memory to compute something|
|Requires some additional program or software to be used by a computer||Is the default computing unit of a computer|
|Used for computationally expensive tasks. Ex – Gaming, training Complex deep learning models, designing, 3d rendering etc.||Is suitable for less computationally expensive tasks.|
Using Kaggle for deep learning
Now many of you might have heard of Kaggle as an ‘online programming competition hub’ or something. That it is, but it also provides you a way of using GPU’s online.
I will not be diving deep into Kaggle. But I will try to tell you how you can train a model in Kaggle and import it in your computer for further use.
It really simple. You just need to sign up in Kaggle, customize your account and create a python project. And you are done. While you are in your project, in the settings tab, you will see an ‘accelerator’ option. It will have 3 options. One of them will be GPU. Click on it and now you can use in your project !
It would be something like this
Kaggle uses NVIDIA TESLA P100 GPUs.
So after we have finally trained our deep learning model in Kaggle how will we import this finished model in our computer ? Well we can simply store the model in Kaggle’s output data using our PyTorch commands. (Assuming you are familiar with using PyTorch for machine learning). And then download the data in your computer.
Here’s how I did it
And now we can use this model, by importing it in python.
One other tool like Kaggle you can use instead is Google Colab. Although, its not very recommended as its very complicated to work with it.
But the problem here is, there would be some time limitations too. You would be provided with a specific quota when you turn on the GPU accelerator.
Using Cloud services
Cloud services are services which provide you powerful I.T resources like database, storage, networking etc. through the internet (cloud). Basically they let you control another computer.
They also let you use some of the most power processing units, like latest AMD, Intel CPUs and GPUs. And of course many provide Nvidia’s GPUs too.
Here’s a list of cloud services you can use for nvidia GPUs.
But of course they don’t let you use them for free. You gotta pay. But of course this could be a better way of using GPU rather than buying as it is cheaper.
These alternative ways of training complex deep learning models could be very helpful for those who are unable to afford a GPU to do so. It is how I used to do for a long time. But of course there are many, many reasons why having an Nvidia GPU of your own is better than these methods. Using these methods could be a lot time consuming and hectic for you. And they are definitely not suitable for some production purposes.
More over, they won’t be enough flexible for you. If you are having a GPU physically with you, you can use it anytime, even without the internet. Not just for deep learning, you might use them for other related purposes too. It could be some sophisticated 3d design for some model etc.