Did you get any outputs from the print statement?
Based on the stack trace it seems that a previous CUDA operation was failing already and the stack trace might point to the wrong line of code.
Could you rerun the code via CUDA_LAUNCH_BLOCKING=1 python script.py args and post the stack trace here?
Also, if you are using an older PyTorch version, could you update to the latest stable release or the nightly binary?