Fix the device='cuda' case.