I’ve found that if you just don’t run the lines that set pytorch Variables to .cpu() (or make sure those lines are commented out) in the original pascal-multi nb, it should all run correctly on GPU. Specifically these 3 cells:
x,y = next(iter(md.val_dl)) # x,y = V(x).cpu(),V(y) x,y = V(x),V(y)
#for i,o in enumerate(y): y[i] = o.cpu() learn.model#.cpu()
#anchors = anchors.cpu(); grid_sizes = grid_sizes.cpu(); anchor_cnr = anchor_cnr.cpu()
I found it easiest to restart the original notebook kernel, check that these 3 lines are commented out, and run through to confirm that it works.
By default, I believe variables are placed on CUDA (GPU) when they’re first defined. What’s happening is when you run the lines above (the ones I’ve commented out), it’s placing those pytorch Variables on cpu while other Variables are not and this makes them inaccessible to each other later on when a function requiring both is called.