I am trying to run lear.predict() on the test set for the cdiscount Kaggle competition. But I am getting the following error when doing prediction:
y = learn.predict(is_test=True)
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-8-77a687d8e73e> in <module>()
----> 1 log_preds,y = learn.predict(is_test=True)
~/fast_ai_fellowship/fastai/courses/dl1/fastai/learner.py in predict(self, is_test)
231 self.load('tmp')
232
--> 233 def predict(self, is_test=False): return self.predict_with_targs(is_test)[0]
234
235 def predict_with_targs(self, is_test=False):
~/fast_ai_fellowship/fastai/courses/dl1/fastai/learner.py in predict_with_targs(self, is_test)
235 def predict_with_targs(self, is_test=False):
236 dl = self.data.test_dl if is_test else self.data.val_dl
--> 237 return predict_with_targs(self.model, dl)
238
239 def predict_dl(self, dl): return predict_with_targs(self.model, dl)[0]
~/fast_ai_fellowship/fastai/courses/dl1/fastai/model.py in predict_with_targs(m, dl)
116 if hasattr(m, 'reset'): m.reset()
117 res = []
--> 118 for *x,y in iter(dl): res.append([get_prediction(m(*VV(x))),y])
119 preda,targa = zip(*res)
120 return to_np(torch.cat(preda)), to_np(torch.cat(targa))
~/anaconda3/envs/fastai/lib/python3.6/site-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs)
222 for hook in self._forward_pre_hooks.values():
223 hook(self, input)
--> 224 result = self.forward(*input, **kwargs)
225 for hook in self._forward_hooks.values():
226 hook_result = hook(self, input, result)
~/anaconda3/envs/fastai/lib/python3.6/site-packages/torch/nn/modules/container.py in forward(self, input)
65 def forward(self, input):
66 for module in self._modules.values():
---> 67 input = module(input)
68 return input
69
~/anaconda3/envs/fastai/lib/python3.6/site-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs)
222 for hook in self._forward_pre_hooks.values():
223 hook(self, input)
--> 224 result = self.forward(*input, **kwargs)
225 for hook in self._forward_hooks.values():
226 hook_result = hook(self, input, result)
~/anaconda3/envs/fastai/lib/python3.6/site-packages/torch/nn/modules/activation.py in forward(self, input)
718
719 def forward(self, input):
--> 720 return F.log_softmax(input)
721
722 def __repr__(self):
~/anaconda3/envs/fastai/lib/python3.6/site-packages/torch/nn/functional.py in log_softmax(input)
535
536 def log_softmax(input):
--> 537 return _functions.thnn.LogSoftmax.apply(input)
538
539
~/anaconda3/envs/fastai/lib/python3.6/site-packages/torch/nn/_functions/thnn/auto.py in forward(ctx, input, *params)
172 del ctx.buffers
173
--> 174 getattr(ctx._backend, update_output.name)(ctx._backend.library_state, input, output, *args)
175 return output
176
RuntimeError: cuda runtime error (2) : out of memory at /opt/conda/conda-bld/pytorch_1503965122592/work/torch/lib/THC/generic/THCStorage.cu:66
I have the latest fastai code, and updated fastai environment. From the error, I think it is running out of memory while iterating over the test set(line number 118
). But assuming the dataloader is only loading minibatches, I don’t know why that should cause memory issues. Anyone else faced this problem?