legacy.nn.Linear raising error "RuntimeError: calling resize_ on a tensor that has non-resizable storage. Clone it first or create a new tensor instead"


#1

I’m using a sequence of legacy modules because I have loaded a model by means of torch.utils.serialization.load_lua(), and that is what it gave me.

I have sundry modules inside of a torch.legacy.nn.Sequential. I’m performing inference on a number of images; the first image runs through the Sequential fine, but if I try to pass a second image through, the following error is thrown:

RuntimeError: calling resize_ on a tensor that has non-resizable storage. Clone it first or create a new tensor instead

This occurs in the first torch.legacy.nn.Linear module in the Sequential, at torch/legacy/nn/Linear.py line 47:

self.output.resize_(nframe, self.weight.size(0))

I’m at a loss. (All of the images are the same size, in case that matters.) Can anyone advise me? Why does this error arise? What can I do to avoid it?


#2

I’m not sure, but that error doesn’t exist any more on master. What version of pytorch are you using? If you’re using 0.4.0, a build from source might make the problem go away.


#3

Thanks. I am using version 0.3.1