Hi guys, I have this issue where to("cuda")
does nothing to some of my tensors. Does not throw an erro but when I check afterwards, the tensor still throws tensor.is_cuda >>> False
Only when I am using .cuda()
The loss calculation can be performed. I cannot find a minimal working example that reproduces the error, I assume it has something to do with the data preparation. Below is an lose example of what I am talking about. Maybe someone has experienced a similar problem, and knows what my mistake is.
device = "cuda"
model.to(device)
clf_targets.to(device)
input.to(device)
output = model(input)
loss = criterion(output, clf_targets)
does not work as clf_targets
remains on the cpu.
device = "cuda"
model.to(device)
clf_targets.to(device)
input.to(device)
output = model(input)
loss = criterion(output, clf_targets.cuda())
does work.