Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I enable pytorch GPU support in Google Colab?

How can I enable pytorch to work on GPU?

I've installed pytorch successfully in google colab notebook: enter image description here Tensorflow reports GPU to be in place:

enter image description here

But torch.device function fails somehow:

enter image description here

How can I fix this?

like image 529
Stepan Yakovenko Avatar asked Oct 14 '25 07:10

Stepan Yakovenko


1 Answers

You can enable GPU by clicking on "Change Runtime Type" under the "Runtime" menu. There is also "TPU" support available in these days.

Runtime Menu

Runtime options

You can define define device using torch.device:

import torch

DEVICE = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
like image 73
abdullahselek Avatar answered Oct 17 '25 06:10

abdullahselek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!