Could you rerun the code with CUDA_LAUNCH_BLOCKING=1 python script.py args and post the stack trace here, please?
I cannot find any obvious error, so I hope the error might point to the line of code causing this issue.