When i use cpu and my labels are (1, 2, 3, 4, 5), it occured: 'Assertion `cur_target >= 0 && cur_target < n_classes’ failed.',

when i use cpu and my labels are (1, 2, 3, 4, 5), it occured: ‘Assertion cur_target >= 0 && cur_target < n_classes’ failed.', i know pytorch limit us use lable (0 to n) that if we want to classify n + 1 categories,so it run error with cpu :'Assertioncur_target >= 0 && cur_target < n_classes’ failed.’, but when i use gpu to run it, it just like this limitation disappeared?, my labels are (1, 2, 3, 4, 5), and it works!, how werid, anybody can tell me why? i’m appretiate u…

The labels should be 0 <= label < n_classes for CUDA, too.
What happens is that CUDA doesn’t report errors quite as diligently due to its asynchronous nature.

Best regards

Thomas

thanks! i get it, thank u very much!