Hi,
Yes the simplest way to do this would be to call .cuda() before the operation and .cpu() just after.
That being said, it is possible that this will be slower than running the whole thing on cpu, that will depend a lot on how much computation you have to perform on the gpu.