I would recommend to run the code on the CPU first to get a better error message.
If the code only raises the error using the GPU, run the script via:
CUDA_LAUNCH_BLOCKING=1 python script.py args

and post the stack trace here, please.