PyTorch - How to Setup and Run PyTorch on Google Colab

in Education5 months ago

In this post, we are going to see How to setup and run PyTorch on Google Colab. Previously I covered a post on Pandas and Google Colab. It was meant for running for most of the data science projects where pandas library is being used.

Prior to that post, I also made an article on Google Colab Tutorial. I also covered the concepts of the Numpy and Google Colab. You should check these two posts out if you have not followed them. I also covered a lot of concepts along the way in both those posts.

Let's talk about Google Colab. So last few posts, my focus was on what are some of the most common used libraries in data science. And how I managed to get them to work on the Google Colab. I think this was a good lesson for me to work with those libraries and get myself to work on some of them to get my work done.

I have created a video to give you an overview on how to use the Google Colab and PyTorch Library for the data science work. You should give this one a try.

What is Pytorch

Let's talk about Pytorch. What is this library and what it can do for you? I'd recommend reading Learn Pytorch. It's one of those good places where you can get the idea of how the pytorch works and what are some of the things that you can use it with as well.

Now let's move onto the Google Colab. This is a good free alternative to using the Jupyter notebooks on cloud. Because otherwise you would have to download and setup the entire packages through the anaconda or the other individual packages through Python.

Once you sign in to the Google colab or use the notebook through Google Drive.

Once you start the jupyter notebook. You can install the pytorch package and you can then import the library into the notebook.

import torch

You can also create tensors and then get started working on some of the examples there itself.


Google notebook also allows you to use the CUDA or the other GPU for your notebooks. You can then power up your notebook for the work. I feel the machine learning and also the deep learning can benefit from the notebook being used in the cloud.

Now coming back to the video, you would learn a lot of small details like this. Like you would learn mostly about the Tensors. I feel making use of the tensors and also using it the right way for basic examples you can learn most of the foundational level machine learning from the Google Colab easily.

This is one of the free and open source machine learning framework. Its very easy to use but takes some time for the concepts to work. As mostly we are dealing with maths and also there are plenty of small concepts that you would have to think over as well. I'd recommend checking out above linked pytorch learn website where you get most of the concepts cleared.

I am going to moving my focus to the R language from next week onwards. So the next week, I'd be covering the RStudio and also the other R language items too. Some of the time it would be reasonable to cover libraries specific to the R language, So that's in my next focus soon. If you are interested do keep tab on my posts.

If you happen to like this content, do give me feedback over there and that would help me improve my efforts in near future.


@tipu curate