I'm trying to execute the NER model (https://s3-us-west-2.amazonaws.com/allennlp/models/ner-model-2018.04.26.tar.gz) in GPU, but it's not using GPU(rather normal CPU) in Azure NV6.
what's the exact command you're running?
I sometimes have to add CUDA_VISIBLE_DEVICES=0 at the beginning of the bash command (and replace 0 with whichever GPU you want to use). I don't know if it can help....
from allennlp.predictors import Predictor
model_url = "https://s3-us-west-2.amazonaws.com/allennlp/models/ner-model-2018.04.26.tar.gz"
predictor = Predictor.from_path(model_path)
result = predictor.predict(sentence=some_text)
What changes should I do (in python)?
as a fairly hacky solution, you can use:
model_url = "s3-us-west-2.amazonaws.com/allennlp/models/ner-model-2018.04.26.tar.gz"
predictor = Predictor.from_path(model_path)
predictor._model = predictor._model.cuda()
result = predictor.predict(sentence=some_text)
Predictor.from_path should really take a cuda_device parameter, I'll open an issue for that.
In the meantime, just do
archive = load_archive(model_path, cuda_device=0)
predictor = Predictor.from_archive(archive)
(or use Nelson's hack)
Thanx for the help.
Most helpful comment
as a fairly hacky solution, you can use: