snowzach / hassio-addons

Hass.IO Repository for snowzach's add-ons.
MIT License
32 stars 12 forks source link

coral pcie not recognized #19

Open eugemaf opened 2 years ago

eugemaf commented 2 years ago

First of all, thanks your work: this addon that can really help in integrating computer vision with home automation.

I'm using DOODS as addon in hassio with mobilenetSSDv2 models derived from google examples. I am facing some problem (with edgetpu quantized models and also tflite models) with my PCB that has installed a coral pcie, because it is not recognized while a coral usb.

The log reports: 2021-12-16T22:04:01.771Z ERROR detector/detector.go:74 Could not initialize detector default: could not initialize edgetpu /dev/apex_0 {"package": "detector"} 2021-12-16T22:04:01.771Z FATAL detector/detector.go:84 No detectors configured {"package": "detector"}

I wonder if there is some setting I can use for allowing the container to see the device. I've also tested the models with a coral USB and it works (very fast actually with the edgetpu model), even if it is necessary (very often) to restart the container (but I pretend to be able to manage it..)

Thanks for you help !

snowzach commented 2 years ago

Did you try passing device /dev/apex_0 into the docker container? I think it's the --devices flag on docker or this in docker compose. As well, most of the time it doesn't work on the first try, it seems to load some driver to the TPU the first time you try and the next time it will work. It only happens the first time you try it.

   devices:
      - /dev/apex_0
eugemaf commented 2 years ago

Thank you for your answer. Could you tell me how can I pass the --devices flag when launching the container as Home Assistant add-on? It is not so clear to me where I can add the flag. Should I uninstall doods from the add-ons and start itvia cli?

Thanks again

snowzach commented 2 years ago

I don't totally remember how to update those settings. It's been a long time since I've used that. If you can run it manually from the command line using the --devices flag and prove that it fixes it, we can see about how to update the repo. It might take editing the addon repo.

snowzach commented 2 years ago

I just looked at this again... You should not need the --devices flag. It's included in the Add-On configuration. When starting the container it should automatically pass through the USB device. FWIW, I just pushed an update to the hass-io repo. Reload the REPOs and then install DOODS2. It's a total re-write and works way better. It shoudl solve all your issues. Re-Open this issue if it persists.

swedishlars commented 8 months ago

Hi @snowzach, first off thank you for doods2! Hope I'm doing the right thing re-opening rather than creating a new ticket?

I'm currently running doods2 with a usb tpu on an old NUC with HA Core and your docker container. It works perfectly.

I'm now trying to migrate to a newer NUC11 running HaOS on bare metal. I'm having problems getting doods2 to recognise a M.2 tpu. I have tested both a M.2 Accelerator A+E key and a M.2 Accelerator with Dual Edge. Using DOODS2-amd64 add-on.

Both of them raise this error: doods.doods - ERROR - Could not create detector tflite/edgeTPU: Could not load EdgeTPU

Config:

- name: edgeTPU
  type: tflite
  modelFile: /share/models/efficientdet_lite3_512_ptq_edgetpu.tflite
  labelFile: /share/models/coco_labels_lite3.txt
  hwAccel: true

Both tpu's seem to be recognised in HAOS:

[core-ssh dev]$ ls /dev/apex_0 
/dev/apex_0
[core-ssh dev]$ lsmod | grep apex
apex                   20480  0 
gasket                110592  1 apex,[permanent]

I have not been able to verify tpu's with lspci cmd as HAOS does not allow it out of the box. Are /dev/apex_0 (M.2) devices truly supported by this HAOS add-on? Or is this a HA Core issue with wrong Apex/Gasket drivers? Or is it simply that my NUC does not support these M.2 E-key tpu's (but then I would not expect /dev/apex_0 to show up).

Any hints/help would be apprciated!

Regards, Lars

snowzach commented 8 months ago

Okay... I see the issue.. We need to pass the apex device through to DOODS... I made a change to the repo... You may need to remove and re-add the doods repo or hit refresh for it to work.

swedishlars commented 8 months ago

Apologies for the delay, travel is getting in the way. No luck I'm afraid. Addon will not start when I add my detector:

- name: edgeTPU
  type: tflite
  modelFile: /share/models/efficientdet_lite3_512_ptq_edgetpu.tflite
  labelFile: /share/models/coco_labels_lite3.txt
  hwAccel: true

Log is completely empty (debug). Sorry...

snowzach commented 5 months ago

Try it now...