import torch.nn as nn
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
This gives me an error
Module 'torch' has no 'device' member i’m using version 1.6
It was working in Google Colab, also conda is available
if torch.cuda.is_available(): print(True)
If i do like this
net = net.to("cuda:0") i get no output at all and computer starts freezing
I encounter this problem only in visual studio code…
https://github.com/kanedaaaa/mnist-pytorch/blob/master/models/cnn.py here is the code, very simple cnn model
Opening a brand new colab notebook and adding
prints just fine.
Did you override some things in the torch library by any chance?
Uh, no, I’m working in vsc, vsc gives me that error.
It is working in jupyter. I mentioned colab because thought maybe torch.device was changed to something else in new update.
I dont think so that i messed up something, since jupyter is not giving me any errors and + its fresh new install
I don’t think any change happened no.
Can you give more info about your platform, python and how you installed pytorch?
Found a solution
device = 'cuda' if torch.cuda.is_available() else 'cpu'
My pc froze a bit but finally it gave my desired output.
idk what happened and why torch.device isnt working tho…