Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do you convert a model trained on GPU to be used for inferencing on CPU? #957

Closed
TheArowanaDude opened this issue Aug 4, 2019 · 6 comments
Labels
question Further information is requested

Comments

@TheArowanaDude
Copy link

Hi, I am trying to use to a model I trained on a server that had cuda GPUs on CPU only; are there any library functions I can use to pull this off? Thanks in advance

@TheArowanaDude TheArowanaDude added the question Further information is requested label Aug 4, 2019
@krzynio
Copy link
Contributor

krzynio commented Aug 5, 2019

You don't need to convert it - it works out of the box.

@TheArowanaDude
Copy link
Author

You don't need to convert it - it works out of the box.

That's what I thought, however when I specified cpu using this command:
flair.device = torch.device('cpu')

I got this error: "RuntimeError: Expected object of backend CUDA but got backend CPU for argument #3 'index'"

@alanakbik
Copy link
Collaborator

Normally it should work out of the box, but there are some embedding types that we import for which this functionality does not work. Notably, that's the embeddings we get from the allennlp library, i.e. the ELMoEmbeddings. Is your model trained with these embeddings? Which embeddings are you using?

@TheArowanaDude
Copy link
Author

TheArowanaDude commented Aug 7, 2019

Normally it should work out of the box, but there are some embedding types that we import for which this functionality does not work. Notably, that's the embeddings we get from the allennlp library, i.e. the ELMoEmbeddings. Is your model trained with these embeddings? Which embeddings are you using?

Ahh, that makes sense, I am using elmo embeddings

@alanakbik
Copy link
Collaborator

Yeah unfortunately this is a known problem, see #635. Perhaps the fix in that thread will work for you? I hope we can fix this at some point.

@gaurav8707
Copy link

If the model is torch based you can convert the model to ONXX model , then you can further optimize it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants