ThilinaRajapakse / simpletransformers

Transformers for Information Retrieval, Text Classification, NER, QA, Language Modelling, Language Generation, T5, Multi-Modal, and Conversational AI
https://simpletransformers.ai/
Apache License 2.0
4.09k stars 728 forks source link

CUDA not actually being used on RepresentationModel #807

Closed rodrigogoulartsilva closed 3 years ago

rodrigogoulartsilva commented 3 years ago

Hi folks,

First of all, awesome job with the library. I have been looking into the RepresentationModel class and I noticed even though there is an init parameter to use CUDA, you assign the device to self.device but the model is never moved to CUDA and you never use it in the method encode_sentences, so it defaults to CPU.

I was able to fix it by simply changing these snippets:

self.model.to(self.device)

Feel free to make the changes if you find appropriate.

Thank you once again.

ThilinaRajapakse commented 3 years ago

Would you like to submit this as a PR so that you get added as a contributor?

I think the model should be moved to device when encode_sentences() is called (for consistency with other models and also so that GPU memory is not taken up if the model is not used).

rodrigogoulartsilva commented 3 years ago

Of course! It would be awesome to contribute to such a cool project! Pull request created as requested. Please let me know if you think it needs adjustments.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.