Fix setting model device for CUDA

#1
by salilsdesai - opened

Previously, trying to run the model when device is set to cuda:0 gave the following error:

RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument index in method wrapper_CUDA__index_select)

This was happening because device was only being used to set the input's device while the model's device was being left as CPU. The fix is to also set the model's device using device

Screenshots

Before Changes [CUDA] (broken):
image.png

After Changes [CUDA] (fixed):
image.png

After Changes [CPU] (still works):
image.png

Jayyydyyy changed pull request status to merged

Sign up or log in to comment