Hi,
The error is most likely not with the .to() op. It’s just that cuda is asynchronous and so errors will point to the wrong line. Run with CUDA_LAUNCH_BLOCKING=1 to make sure the error points to the right line.