Repository: blakeblackshear/frigate

Issue:
[Support]: Frigate crashes on ARM64 after upgrade to beta 8
### Describe the problem you are having

On ARM64 machine, frigate crashes while trying to start go2rtc.
Looking for the "ELF load command alignment not page-aligned" error, I found this: https://github.com/numpy/numpy/issues/16677

I assume the problem is related to ARM64 and the 64K page size of the "Red Hat Enterprise Linux release 8.7 (Ootpa)" operating system.

```
$ python3 -c 'import os; print(os.sysconf("SC_PAGESIZE"))'
65536
```

### Version

0.12.0 Beta 8

### Frigate config file

```yaml
mqtt:
  host: mqtt

cameras:
  entrance:
    ffmpeg:
      inputs:
        - path: rtsp://**REDACTED**
          roles:
            - detect
            - rtmp
            - record
    detect:
      width: 2688
      height: 1520
      fps: 5
    mqtt:
      timestamp: False
      bounding_box: False
      crop: True
      quality: 100
      height: 1520

record:
  enabled: True
  events:
    retain:
      default: 5
```


### Relevant log output

```shell
[INFO] Starting go2rtc...
2023-02-15 14:19:19.142580863  14:19:19.142 INF go2rtc version 1.1.2 linux/arm64
2023-02-15 14:19:19.142706423  14:19:19.142 INF [api] listen addr=:1984
2023-02-15 14:19:19.142896941  14:19:19.142 INF [rtsp] listen addr=:8554
2023-02-15 14:19:19.143039420  14:19:19.143 INF [srtp] listen addr=:8443
2023-02-15 14:19:19.143322578  14:19:19.143 INF [webrtc] listen addr=:8555
2023-02-15 14:19:19.555985825  Traceback (most recent call last):
2023-02-15 14:19:19.556016824    File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
2023-02-15 14:19:19.556044824      return _run_code(code, main_globals, None,
2023-02-15 14:19:19.556045944    File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
2023-02-15 14:19:19.556083464      exec(code, run_globals)
2023-02-15 14:19:19.556084664    File "/opt/frigate/frigate/__main__.py", line 9, in <module>
2023-02-15 14:19:19.556140984      from frigate.app import FrigateApp
2023-02-15 14:19:19.556142424    File "/opt/frigate/frigate/app.py", line 17, in <module>
2023-02-15 14:19:19.556202983      from frigate.comms.dispatcher import Communicator, Dispatcher
2023-02-15 14:19:19.556205023    File "/opt/frigate/frigate/comms/dispatcher.py", line 9, in <module>
2023-02-15 14:19:19.556227943      from frigate.config import FrigateConfig
2023-02-15 14:19:19.556268703    File "/opt/frigate/frigate/config.py", line 36, in <module>
2023-02-15 14:19:19.556269863      from frigate.detectors import (
2023-02-15 14:19:19.556270783    File "/opt/frigate/frigate/detectors/__init__.py", line 9, in <module>
2023-02-15 14:19:19.556287783      from .detector_types import DetectorTypeEnum, api_types, DetectorConfig
2023-02-15 14:19:19.556289223    File "/opt/frigate/frigate/detectors/detector_types.py", line 16, in <module>
2023-02-15 14:19:19.556353022      plugin_modules = [
2023-02-15 14:19:19.556354502    File "/opt/frigate/frigate/detectors/detector_types.py", line 17, in <listcomp>
2023-02-15 14:19:19.556355142      importlib.import_module(name)
2023-02-15 14:19:19.556356102    File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
2023-02-15 14:19:19.556364622      return _bootstrap._gcd_import(name[level:], package, level)
2023-02-15 14:19:19.556368702    File "/opt/frigate/frigate/detectors/plugins/openvino.py", line 3, in <module>
2023-02-15 14:19:19.556395182      import openvino.runtime as ov
2023-02-15 14:19:19.556396862    File "/usr/local/lib/python3.9/dist-packages/openvino/runtime/__init__.py", line 20, in <module>
2023-02-15 14:19:19.556431222      from openvino.pyopenvino import Dimension
2023-02-15 14:19:19.556440942  ImportError: /usr/local/lib/python3.9/dist-packages/openvino/pyopenvino.cpython-39-aarch64-linux-gnu.so: ELF load command alignment not page-aligned
Service Frigate exited with code 1 (by signal 0)
```


### FFprobe output from your camera

```shell
N/A
```


### Frigate stats

_No response_

### Operating system

Other Linux

### Install method

Docker Compose

### Coral version

CPU (no coral)

### Network connection

Wired

### Camera make and model

Hikvision

### Any other information that may be helpful

_No response_


Discussion:
What OS are you running? Beta 8 has 136 arm64 pulls and this is the first it was reported so seems it will likely be something more specific than just being arm64
cc @NateMeyer 
@NickM-27 RHEL 8.7
Are you using Openvino for detection?

The OpenVino wheel is built from my repo at https://github.com/NateMeyer/openvino-wheels. I'll take a closer look through the build this week to see if I need to adjust the page size.
@NateMeyer, no, I'm not using Openvino currently.
I've updated my comment on this issue with my Frigate configuration (it was running with v0.11.1).

Resolving patch:
diff --git a/frigate/detectors/detector_types.py b/frigate/detectors/detector_types.py
--- a/frigate/detectors/detector_types.py
+++ b/frigate/detectors/detector_types.py
@@ -13,12 +13,19 @@
 
 logger = logging.getLogger(__name__)
 
-plugin_modules = [
-    importlib.import_module(name)
-    for finder, name, ispkg in pkgutil.iter_modules(
-        plugins.__path__, plugins.__name__ + "."
-    )
-]
+
+_included_modules = pkgutil.iter_modules(plugins.__path__, plugins.__name__ + ".")
+
+plugin_modules = []
+
+for _, name, _ in _included_modules:
+    try:
+        # currently openvino may fail when importing
+        # on an arm device with 64 KiB page size.
+        plugin_modules.append(importlib.import_module(name))
+    except ImportError as e:
+        logger.error(f"Error importing detector runtime: {e}")
+
 
 api_types = {det.type_key: det for det in DetectionApi.__subclasses__()}
 


Test patch: