[Solved] Loss.data[0] Result cuda runtime error(59)

Hello I try to train my CNN in pytorch. Everything gone well except my code line running_loss += loss.data[0] . I have tried to trace it. Here is the size of input.

Produce by this code.

Here is full error.

Any one know how to fix this?
-Thank you-

This also happened when I am using jupyter notebook.


Due to how cuda works, some errors are reported on a different operation than the one that is responsible for the error.

You can force it to raise the error right away by launching your script with the CUDA_LAUNCH_BLOCKING environment variable as:

CUDA_LAUNCH_BLOCKING=1 python your_script.py

It is possible that it will run slightly slower than usual, it is normal.

Finally I got it for the first problem is because my data loader give some wrong value.
@albanD Thanks, I also have see that command before, however I am using jupyter notebook to train my model so I still don’t know how to do that.
For my previous reply is still bug and hopely fixed in the next update. Here the link.