(Lesson 1)Google Colab is taking much time to fit the model. Is it normal?


It took nearly 2 and half hours to fit my model using Google Colab. Is it normal?
I am doing v-3 lesson 1 currently.

1 Like

Depending on the size of your dataset, it could take a long time. Without knowing what you’re putting into it, I couldn’t say.
Are you running this on a GPU? I can’t tell from your screenshot.

I am using free GPU access provided by Google Colab itself.

They don’t provide what GPU are you using to run you code? (generally it has a tab where it says what are the specs).

are you sure that you are using a GPU?

This used to happen to me before but I was using keras and I used the multi gpu model to help speed things up.

I am doing my lessons directly on google colab without any setup. In notebook settings I chose GPU as my hardware accelerator.

@Prabin did you find a solution for that problem? I am facing the same issue and can’t solve it.

Hello @moustafa-7, Welcome to the community.
Can you make sure you have the GPU enabled? More specifically, when you open a new notebook, go to Runtime -> Change Euntime type -> Under Hardware accelerator select GPU
If it still doesn’t work I’m not sure what the issue is but you can always use Kaggle as an alternative. It has fastai libraries preinstalled and the GPU works well.
Regards

2 Likes

Hello @dipam7,
Thanks for the reply.
Yes, the GPU was enabled and everything was setup correctly.
I solved the problem by doing this:
I uninstalled torch using !pip uninstall torch then used the that line
!curl -s https://course.fast.ai/setup/colab | bash
and after I ran this torch.cuda.is_available()
it returns true

1 Like

@moustafa-7 @dipam7
So, what is the reason for the slow GPU even after setting
Under Hardware accelerator select GPU.
I have the same case of slow response but with CNN using Keras. I have 1400 training images, 700 testing images, the number of epochs 50 with one convolution-max pooling-flatten-one fully connected layer took around 2 hours for only 20 epochs. I thought to check accuracy between resnet 50 and keras architecture.
Thanks.

@posi2 I think it has something with pytorch setup. I just uninstalled it then reinstalled it.
I think you have to do the same thing with Keras + check if Keras is detecting a GPU or not. If not, you can:
1- uninstall Keras then reinstall it.
2- check if there is some code that enables GPU computing in Keras

Hey @posi2, I haven’t used colab or keras much so I’m not sure. But in PyTorch, we put the model (weight matrices) on the GPU with something like model = Mnist_Logistic().cuda() You can find out if something similar is required in keras. Another thing you can do is, try to run the fastai library on your model (since it takes care of loading the models on the GPU) and compare the 2 training times. You can also run your code on Kaggle, since its GPU works really well to see if it is an issue with colab.

Let me know if you are able to solve it.

@moustafa-7 @dipam7
I have reinstall keras and also checked search about using GPU backend (tensorflow)
here what I got.I don’t understand this showing GPU:0

approx 0.5 sec for 1 image (total 1400) i.e. 10 min per epochs here the code

@dipam7 as mentioned I get my hand dirty with Kaggle kernel and it is working faster than colab but take some time (the kernel does not show any output) between epochs.

Is it necessary to connect the internet with google colab or kaggle kernel during training?
why Colab get automatically disconnected?
image

Thank you so much Now, It is working Faster.