Oh, that’s not the solution for the issue.
The command blocks each CUDA call, which is originally called asynchronously, so it’s just useful for debugging.
Could you give me the shapes of train_data and train_labels so that I could run the code on my machine?
Also, which setup are you using (PyTorch version, CUDA, cudnn, how did you install PyTorch)?