-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Token classification inference on CPU #557
Comments
@lebionick I couldn't reproduce your error, could you share code with model and tokenizer initialization? `import nemo class Inference:
inf = Inference(False) |
@ekmb I started to do minimal working example and found the cause: I load BERT earlier in the code (jupyter cell) using this: bert_model = nemo_nlp.nm.trainables.huggingface.BERT(
config_filename="/data/mwe/checkpoints/bert-config.json"
) at this moment I had global |
Hello,
I've trained BERT for NER and want to inference it on CPU. I used code from here: https://github.com/NVIDIA/NeMo/blob/master/examples/nlp/token_classification/token_classification_infer.py and made this class:
where model is
nemo_nlp.nm.trainables.huggingface.BERT
, tokenizer isnemo_nlp.data.SentencePieceTokenizer
, in"/data/weights/ner"
I have checkpoints from training in.pt
format.When I run
forward
withuse_gpu=True
it works, but withuse_gpu=False
it crashes with error:RuntimeError: Expected object of device type cuda but got device type cpu for argument #1 'self' in call to _th_mm
in line:
---> 28 evaluated_tensors = self.nf.infer(tensors=[logits, subtokens_mask], checkpoint_dir="/data/weights/ner")
What I'm doing wrong and how to fix this? Does it come from loading checkpoint, which was made with CUDA tensors?
The text was updated successfully, but these errors were encountered: