with torch.no_grad():
retrieval_one_hot = torch.zeros(k, 10).cuda()
for batch_idx, (inputs, targets, indexes) in enumerate(testloader):
inputs, targets, indexes = inputs.to(device), targets.to(device), indexes.to(device)
net.to(device)
targets = targets.cuda()#async=True)
batchSize = inputs.size(0)
features = net(inputs)
zz = torch.zeros(batchSize * k, 10).cuda()
....
and it returns the error at the line zz = torch.zeros(batchSize * k, 10).cuda(), with the error message “RuntimeError: CUDA error: device-side assert triggered”, any suggestions?
The reason why you met this problem becasue your “target” labels include minus values such as “-1”.
I find this reason when i met this problem. hope useful!
Another issue that might raise this error is mismatch with the last layer of the network. Validate that the output of the network is the same as the number of labels.
import os
os.environ["CUDA_LAUNCH_BLOCKING"] = "1"
on top of your script and run the script to get a way better stack trace. in my case the cuda error told me to look at a completely different line which caused an hour of debugging