How to return back to cpu from gpu?

Hi I have a text classifier in pytorch and I want to use GPUs to increase running speed.
I have used this part of code to check CUDA and use it:

    if torch.cuda.device_count() > 1:
        print("Let's use", torch.cuda.device_count(), "GPUs!")
        my_rnn_model = nn.DataParallel(my_rnn_model)

    if torch.cuda.is_available():

Now I want to return back to use cpu (instead of gpu). So I cleared this part of code. But it does’nt work and I receive this error:
RuntimeError: cuda runtime error (8) : invalid device function at /opt/conda/conda-bld/pytorch_1503963423183/work/torch/lib/THC/
Would you please guide me how can I return back to cpu running?

You can have a construct like this:

if torch.cuda.is_available():
  device = 'cuda'
  device = 'cpu'

To move between CPU and GPU, use the .to(device) function with the appropriate value for device


Thanks. I think I should migrate to Pytorch version 0.4 because my current version is 0.2.0-4.