Hello, I’m trying to load the densenet169 model from torchvision.models, and I want to run it on GPU. The program is running fine on CPU, but I wanted to do it on GPU.
Changes I made were:
Added the line device = torch.device(“cuda:0”) at top
after loading the densenet model, i did model_ft.to(device)
I did the same for images,labels = images.to(device),labels.to(device) in training loop.
But I’m getting the error as RuntimeError: Expected object of backend CPU but got backend CUDA for argument #4 ‘mat1’ which lead me to this link model.cuda doesn’t automatically detect layers in list 2.
I’m a newbie to Pytorch so how do I solve this error? I can’t share a lot of code as its my hw and turntin might say I copied from here. Please help!
Thanks!