CUDA errors might be sometimes cryptic, so I generally recommend to debug the code on the CPU, if possible. If that’s not possible, I would try to execute the script via:
CUDA_LAUNCH_BLOCKING=1 python script.py args

to get the right line of code which raised the error in the stack trace.