You could use the loop and push all predictions to the default device (or the device, where label is stored).
Note that, the usage of .data is deprecated and might yield unwanted side effects, so you should call torch.max on the tensor directly.