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.51k stars 155 forks source link

Viseron won't attempt to load Coral EdgeTPU PCIe if a Google phone is connected via USB #601

Closed bit-bat closed 12 months ago

bit-bat commented 1 year ago
************** Setting EdgeTPU permissions ***************
Coral Vendor IDs:
"1a6e"
"18d1"
Matching USB devices:
Bus 001 Device 007: ID 18d1:4ee1 motorola Nexus 6
!!!WARNING!!!
/dev/bus/usb/001/007 is missing. EdgeTPU will not work unless you make sure to add --device /dev/bus/usb to your docker run command.
!!!WARNING!!!
bit-bat commented 1 year ago

My original report might be misleading. I disconnected the phone, but Coral is still not working.

************** Setting EdgeTPU permissions ***************
Coral Vendor IDs:
"1a6e"
"18d1"
No EdgeTPU USB device was found
************************** Done **************************
[2023-05-12 03:57:56] [INFO    ] [viseron.components] - Setting up component edgetpu
[2023-05-12 03:57:56] [DEBUG   ] [viseron.components.edgetpu] - Available devices: [{'type': 'pci', 'path': '/dev/apex_0'}]
[2023-05-12 03:57:56] [INFO    ] [viseron.components] - Setup of component edgetpu took 0.0 seconds
[2023-05-12 03:57:59] [DEBUG   ] [viseron.components.edgetpu] - Loading interpreter with device pci, model /detectors/models/edgetpu/mobiledet_model.tflite
[2023-05-12 03:57:59] [DEBUG   ] [viseron.components.edgetpu] - Using labels from /detectors/models/edgetpu/labels.txt
[2023-05-12 03:57:59] [DEBUG   ] [viseron.components.data_stream] - Subscribing to data topic motion_detector/side_yard_cam/scan, <queue.Queue object at 0x7f0ce8a76580>
[2023-05-12 03:57:59] [ERROR   ] [viseron.components.edgetpu] - Error when trying to load EdgeTPU: Failed to load delegate from libedgetpu.so.1
roflcoopter commented 1 year ago

Hmm, whats the output of lsusb on your host?

And what does your docker run command look like?

bailboy91 commented 1 year ago

I have 2 m.2 pcie units set to be delivered at the end of the month / early next month. I'll report back my setup when they're in and if I have similar issues.

roflcoopter commented 1 year ago

Great, thanks!

bailboy91 commented 1 year ago

I JUST received them in the mail. I put one in my main computer. and I am seeing the same as OP here. It appears the m.2 cards have a different vendor ID than the USB accelerators. $ lspci -nn | grep 089a 04:00.0 System peripheral [0880]: Global Unichip Corp. Coral Edge TPU [1ac1:089a]

bailboy91 commented 1 year ago

Docker Compose File:

version: "3"

services:
  viseron:
    image: roflcoopter/viseron:latest
    container_name: viseron
    volumes:
      - /media/spcc-256/viseron/recordings:/recordings
      - /media/spcc-256/viseron:/config
      - /etc/localtime:/etc/localtime:ro
      - /dev/shm:/tmp
    privileged: true
    restart: unless-stopped
    devices:
      - /dev/apex_0:/dev/apex_0
    ports:
      - 8888:8888
    environment:
      - PUID=0
      - PGID=0
bailboy91 commented 1 year ago

After some digging through rootfs/etc/cont-init.d/30-edgetpu-permission in both the container and on the host machine the vendor id of 1ac1 is not present. The product ID remains the same though. Could the Productid of 089a be used instead?

bailboy91 commented 1 year ago

After a ton of testing i think I've been chasing nothing. While the message does state it didn't find a coraltpu device, I believe it is actually using the device so long as you passed the device correctly into the container. I'll test again tomorrow but i believe this is a non issue and maybe an opportunity to clarify in the documentation.

roflcoopter commented 1 year ago

Nice digging! So it seems that the issue is that the script /rootfs/etc/cont-init.d/30-edgetpu-permission is not picking up the pci card and thus falsely reports that it is not available?

bailboy91 commented 1 year ago

That is correct! After enabling debug logging I saw that it was recognizing the pci card and I saw motion / object detection.