Generally whenever an assert statement is violated.
E.g. if you are using nn.NLLLoss as the criterion and pass a target with out of bounds values, this line of code 12 will raise this issue.
Note that CUDA operations are asynchronous, so whenever you encounter an error running with CUDA, I would suggest to make sure the code works fine using the CPU (as this might give you a better error message), and if that’s the case run the code with CUDA_LAUNCH_BLOCKING=1 python script.py args.