Hi there,
this is a newbie question (sorry…). I’m trying to speed-up my GPU training. The docs 98 recommend pin_memory(), which works with tensors, but not with variables (torch version 0.3.0):

import torch
from torch.autograd import Variable
dtype = torch.FloatTensor
my_tensor = torch.randn(10,10).type(dtype)
my_variable = Variable(torch.randn(10,10).type(dtype), requires_grad=False)
my_tensor.cuda() # -> works
my_tensor.pin_memory() # -> works
my_variable.cuda() # -> works
my_variable.pin_memory() # -> does not work

gives me the error

Traceback (most recent call last):
  File "check.py", line 14, in <module>
    my_variable.pin_memory() # -> does not work
  File "/usr/local/lib/python2.7/dist-packages/torch/autograd/variable.py", line 67, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'Variable' object has no attribute 'pin_memory'


I wonder why this is… As my_variable.cuda() allows me to send Variables to GPU (just like tensors), I would expect pin_memory() to work for Variables too.

Is my understanding fundamentally wrong here?
What’s the correct way of pinning memory (a) for all of a model’s variables/tensors, (b) when only pinning some of the variables? (A web search gives me only examples in combination with DataLoader(), which does not apply in my case).

Thanks a lot!