No, I don’t think the Python exception handling could cause an illegal memory access and should keep the tensor alive without releasing it to the cache in the worst case.
To further isolate the issue, you could rerun your script via CUDA_LAUNCH_BLOCKING=1 as suggested in the error message.