OSError: [Errno 5] EIO on Portenta

Hi,
I, very rarely, get this error when I run my image classification application on Portenta LoRa Vision Shield, but whenever I do it causes trouble in field application:

Traceback (most recent call last):
  File "<stdin>", line 131, in <module>
  File "<stdin>", line 129, in invoke_model
  File "ml/model.py", line 36, in __init__
OSError: [Errno 5] EIO

My application uses several modules like RTC and a motor driver, but I think this error is independent of those. Rudimentarily, I can deduce that the issue is in the __init__ of ml/model.py. My model is invoked in the following way, which is pretty standard:

def invoke_model():
    return ml.Model("model/trained.tflite", load_to_fb=uos.stat('model/trained.tflite')[6] > (gc.mem_free() - (64*1024)))

net = invoke_model()

Based on other posts on this forum, I believe the EIO error refers to failure in communicating with an I2C/SPI device(??). Could this be the camera in my case? I’m keen to look at the model.py script, but not sure if I can trace the lines to what’s available in this folder. Am I looking at the right file here?

Is there any measure I can take to minimise this error’s occurrence?

PC

Hi, you should avoid creating a Model object dynamically. Generally, it should be made just once.

The EIO error is related to disk access. For some reason, it fails. You could try again on this error if it’s just transient by using a try-except.

1 Like

Thanks for the advice on this! I’ll try-except for now and hopefully this won’t lead to failure in operations on field

PC