roflcoopter / viseron

Self-hosted, local only NVR and AI Computer Vision software. With features such as object detection, motion detection, face recognition and more, it gives you the power to keep an eye on your home, office or any other place you want to monitor.
MIT License
1.66k stars 171 forks source link

Google Coral M.2 EdgeTPU #551

Closed Dvalin21 closed 1 year ago

Dvalin21 commented 1 year ago

When trying to use the Coral, I noticed that when the system starts it searches only for the USB version, but it never looks for the M.2 version which is what I have. It should show up as Coral Edge TPU [1ac1:089a]

When abled I get this.

Turning on the debug logs it sees the path/available device for the M.2 [2023-04-21 20:34:12] [DEBUG ] [viseron.components.edgetpu] - Available devices: [{'type': 'pci', 'path': '/dev/apex_0'}] [2023-04-21 21:15:29] [INFO ] [viseron.components] - Setting up domain object_detector for component edgetpu with identifier camera_3, attempt 4 [2023-04-21 21:15:29] [DEBUG ] [viseron.components.edgetpu] - Loading interpreter with device :0, model /detectors/models/edgetpu/mobiledet_model.tflite [2023-04-21 21:15:29] [DEBUG ] [viseron.components.edgetpu] - Using labels from /detectors/models/edgetpu/labels.txt [2023-04-21 21:15:29] [ERROR ] [viseron.components.edgetpu] - Error when trying to load EdgeTPU: Failed to load delegate from libedgetpu.so.1 [2023-04-21 21:15:29] [ERROR ] [viseron.components] - Domain object_detector for component edgetpu is not ready. Retrying in 40 seconds. Error: [2023-04-21 21:15:29] [INFO ] [viseron.components] - Setting up domain object_detector for component edgetpu with identifier camera_1, attempt 4 [2023-04-21 21:15:29] [DEBUG ] [viseron.components.edgetpu] - Loading interpreter with device :0, model /detectors/models/edgetpu/mobiledet_model.tflite [2023-04-21 21:15:29] [DEBUG ] [viseron.components.edgetpu] - Using labels from /detectors/models/edgetpu/labels.txt [2023-04-21 21:15:29] [ERROR ] [viseron.components.edgetpu] - Error when trying to load EdgeTPU: Failed to load delegate from libedgetpu.so.1 [2023-04-21 21:15:29] [ERROR ] [viseron.components] - Domain object_detector for component edgetpu is not ready. Retrying in 40 seconds. Error:

This is even after making sure the Apex is in the right usergroup and root permissions given, reboot the computer also.

I my other docker containers are able to see and use the device (yes I made sure the other container was off before trying to use it).

Thanks in advance!

roflcoopter commented 1 year ago

Strange, it should work.

Can you restart and send the logs from the start? There should be a message like this before Viseron starts: ************** Setting EdgeTPU permissions ***************

roflcoopter commented 1 year ago

One thiing that came to mind, have you mounted the correct device into the container? --device /dev/apex_0:/dev/apex_0

Dvalin21 commented 1 year ago

One thiing that came to mind, have you mounted the correct device into the container? --device /dev/apex_0:/dev/apex_0

Yes I did. And Ill send you those logs

Dvalin21 commented 1 year ago

@roflcoopter as requested

[cont-init.d] 10-adduser: exited 0. [cont-init.d] 20-gid-video-device: executing... [cont-init.d] 20-gid-video-device: exited 0. [cont-init.d] 30-edgetpu-permission: executing... ** Setting EdgeTPU permissions * Coral Vendor IDs: "1a6e" "18d1" No EdgeTPU USB device was found ** Done ** [cont-init.d] 30-edgetpu-permission: exited 0. [cont-init.d] 40-set-env-vars: executing... ** Checking for hardware acceleration platforms ** OpenCL cannot be used VA-API is available! CUDA cannot be used ***** Done *** [cont-init.d] 40-set-env-vars: exited 0. [cont-init.d] 50-check-if-rpi: executing... ** Checking if we are running on an RPi ** Not running on any supported RPi * Done *** [cont-init.d] 50-check-if-rpi: exited 0. [cont-init.d] 55-check-if-jetson: executing... ** Checking if we are running on a Jetson Board ** Not running on any supported Jetson board * Done *** [cont-init.d] 55-check-if-jetson: exited 0. [cont-init.d] 60-ffmpeg-path: executing... ** Getting FFmpeg path * FFmpeg path: /home/abc/bin/ffmpeg * Done *** [cont-init.d] 60-ffmpeg-path: exited 0. [cont-init.d] 70-gstreamer-path: executing... Getting GStreamer path GStreamer path: /usr/bin/gst-launch-1.0 * Done *** [cont-init.d] 70-gstreamer-path: exited 0. [cont-init.d] done. [services.d] starting services [services.d] done.

Dvalin21 commented 1 year ago

@roflcoopter So after the update, I'm not getting the delegate error anymore. However, when I set the path for the models I get this.

[2023-04-24 08:26:42] [ERROR ] [viseron.components] - Error validating config for component edgetpu: extra keys not allowed @ data['edgetpu']['object_detector']['cameras']['camera_1']['model_path']. Got '/detectors/models/edgetpu/' Traceback (most recent call last): File "/src/viseron/components/init.py", line 114, in validate_component_config return component_module.CONFIG_SCHEMA(self._config) # type: ignore File "/usr/local/lib/python3.8/dist-packages/voluptuous/schema_builder.py", line 272, in call return self._compiled([], data) File "/usr/local/lib/python3.8/dist-packages/voluptuous/schema_builder.py", line 594, in validate_dict return base_validate(path, iteritems(data), out) File "/usr/local/lib/python3.8/dist-packages/voluptuous/schema_builder.py", line 432, in validate_mapping raise er.MultipleInvalid(errors) voluptuous.error.MultipleInvalid: extra keys not allowed @ data['edgetpu']['object_detector']['cameras']['camera_1']['model_path'] [2023-04-24 08:26:42] [ERROR ] [viseron.components] - Setup of component edgetpu failed [2023-04-24 08:26:42] [ERROR ] [viseron.components] - Failed setup of component edgetpu

When I don't set the path for the models, it completely freaks out and causes the software to come to a complete halt and gives me this error (in the documentation setting the path is optional)

F port/default/port_from_tf/statusor.cc:38] Attempting to fetch value instead of handling error Failed precondition: Could not map pages : 38 (Device or resource busy) [viseron-finish] Viseron exit code 256 [viseron-finish] Viseron received signal 6 [cont-finish.d] executing container finish scripts... [cont-finish.d] done. [s6-finish] waiting for services. [s6-finish] sending all processes the TERM signal. [s6-finish] sending all processes the KILL signal and exiting.

When I switch the device to "cpu" and still keep the model_path mapped, it gives me the config error that this is not suppose to be there. When I comment it out, edgetpu is setup with cpu setting.

Dvalin21 commented 1 year ago

So let me make sure I'm understanding the documentation. Should I declare a device under "object detection" and image clarification? Update: Answer is yes. I missed placed it the last time. Not touching again!