File "/home/ubuntu/anaconda3/envs/pytorch_latest_p37/lib/python3.7/site-packages/haystack/reader/farm.py", line 103, in __init__
strict=False)
File "/home/ubuntu/anaconda3/envs/pytorch_latest_p37/lib/python3.7/site-packages/farm/infer.py", line 252, in load
model = BaseAdaptiveModel.load(load_dir=model_name_or_path, device=device, strict=strict)
File "/home/ubuntu/anaconda3/envs/pytorch_latest_p37/lib/python3.7/site-packages/farm/modeling/adaptive_model.py", line 51, in load
model = cls.subclasses["ONNXAdaptiveModel"].load(**kwargs)
File "/home/ubuntu/anaconda3/envs/pytorch_latest_p37/lib/python3.7/site-packages/farm/modeling/adaptive_model.py", line 670, in load
return cls(onnx_session, language_model_class, language, prediction_heads, device)
File "/home/ubuntu/anaconda3/envs/pytorch_latest_p37/lib/python3.7/site-packages/farm/modeling/adaptive_model.py", line 634, in __init__
if str(device) == "cuda" and onnxruntime.get_device() != "GPU":
NameError: name 'onnxruntime' is not defined
Looks like ONNXAdaptiveModel.__init__ is perhaps just missing a local import onnxruntime, as is done in ONNXAdaptiveModel.load.
When trying to load an ONNX model:
Looks like
ONNXAdaptiveModel.__init__
is perhaps just missing a localimport onnxruntime
, as is done inONNXAdaptiveModel.load
.https://github.com/deepset-ai/FARM/blob/77530ab088bf634b1e0943fb95fd9b7bb04edb4d/farm/modeling/adaptive_model.py#L638-L643
I've manually worked around it by adding the import, after which everything else seems to work fine. Can create a PR with this change if you like...