In the code, there is the use of .to() and to this function, we pass the cuda value you give during initialization. So, I believe, your variables and model are moving to cuda.
You can print the model parameters’s device value, eg:
model = torchvision.models.resnet18()
for name in next(model.parameters()):
print(name.device)