openvino: RuntimeError: Cannot get length of dynamic dimension

System information (version)
  • OpenVINO => 2022.1
  • Operating System / Platform => Raspberry aarch64
  • Compiler => python3.9
  • Problem classification: Compile model

Hey guys, I’m trying to build a speech-to-text model. I have a facebook/hubert-large-ls960-ft model. I’ve converted it to an onnx model and converted the onnx model to an IR model.

I’ve run this model and script on my windows machine and it works perfectly. However, when I run it on my raspberry I get the following error: RuntimeError: Cannot get length of dynamic dimension.

The code I use:

from openvino.runtime import Core
from transformers import Wav2Vec2Processor
import librosa
import torch #1.10.1
import openvino.runtime as ov
import numpy as np #1.21.0

print(torch.__version__)
print(np.__version__) 
print(np.__path__)

core = Core()

processor = Wav2Vec2Processor.from_pretrained("facebook/hubert-large-ls960-ft")
input_audio, _ = librosa.load("sound.wav", sr=16000)
input_values = processor(input_audio, return_tensors="pt", sampling_rate=16000).input_values

available_devices = core.available_devices
print(available_devices)
compiled_model = core.compile_model("hubert/hubert.xml", "MYRIAD")
infer_request = compiled_model.create_infer_request()

input_tensor = ov.Tensor(array=input_values.numpy(), shared_memory=True)
infer_request.set_input_tensor(input_tensor)

infer_request.infer()
output = infer_request.get_output_tensor()
output_buffer = output.data
predicted_ids = torch.argmax(torch.Tensor(output_buffer), dim=-1)
transcription = processor.decode(predicted_ids[0]).lower()

print(f"transcription: {transcription}")

it crashes on this line: compiled_model = core.compile_model("hubert/hubert.xml", "MYRIAD")

The stacktrace: Traceback (most recent call last): File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/lib/python3.9/runpy.py", line 87, in _run_code exec(code, run_globals) File "/home/pi/.vscode/extensions/ms-python.python-2022.2.1924087327/pythonFiles/lib/python/debugpy/__main__.py", line 45, in <module> cli.main() File "/home/pi/.vscode/extensions/ms-python.python-2022.2.1924087327/pythonFiles/lib/python/debugpy/../debugpy/server/cli.py", line 444, in main run() File "/home/pi/.vscode/extensions/ms-python.python-2022.2.1924087327/pythonFiles/lib/python/debugpy/../debugpy/server/cli.py", line 285, in run_file runpy.run_path(target_as_str, run_name=compat.force_str("__main__")) File "/usr/lib/python3.9/runpy.py", line 268, in run_path return _run_module_code(code, init_globals, run_name, File "/usr/lib/python3.9/runpy.py", line 97, in _run_module_code _run_code(code, mod_globals, init_globals, File "/usr/lib/python3.9/runpy.py", line 87, in _run_code exec(code, run_globals) File "/home/pi/Desktop/raspberry/voice-to-text/test.py", line 21, in <module> compiled_model = core.compile_model("hubert/hubert.xml", "MYRIAD") File "/opt/intel/openvino/python/python3.9/openvino/runtime/ie_api.py", line 266, in compile_model super().compile_model(model, device_name, {} if config is None else config) RuntimeError: Cannot get length of dynamic dimension

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

Hey @vollebreggie , you might want to check this document as well… https://docs.openvino.ai/latest/openvino_docs_OV_UG_NoDynamicShapes.html Curious if this helps or makes any better?