CUDAerror: device-side assert triggered

I got this error while running a simple line of code. Most of the time when I get this error I just switch off my gpu and run it on cpu , and always I get what is wrong with my code. I did the same with this but It ran fine with cpu.

Could you rerun the code with CUDA_LAUNCH_BLOCKING=1 python script.py args and post the complete stack trace here, please?

Actually I was running this on google colab. So How can I run this command there?

Anyway I switched off my gpu and restarted it after 1 day and was not getting any error…but then too I want to know the reason

You could try to set this environment argument via os.environ['CUDA_LAUNCH_BLOCKING'] = "1".
This would have to be added before any other imports in your script to work properly.

1 Like