timoschick / pet

This repository contains the code for "Exploiting Cloze Questions for Few-Shot Text Classification and Natural Language Inference"
https://arxiv.org/abs/2001.07676
Apache License 2.0
1.62k stars 282 forks source link

RuntimeError on eval method #86

Closed xruifan closed 2 years ago

xruifan commented 2 years ago

Hi,

I tried to use my final classifier to predict the class of a new instance, using the method eval as described here. After I assigned the device 'cuda', I got an error saying RuntimeError: Expected object of device type cuda but got device type cpu for argument #1 'self' in call to _th_index_select.

Fan

timoschick commented 2 years ago

Did you move the model to GPU (in the example you linked, that would be model.model.to('cuda')) before running the evaluation?

xruifan commented 2 years ago

No, I didn't. The code worked perfectly after I added the line, thank you so much!