With this i can see the devices in the incus container.
# lsusb
Bus 004 Device 004: ID 1a6e:089a Global Unichip Corp.
# ls -la /dev/bus/usb/004/002
crw-rw-rw- 1 root plugdev 189, 385 Nov 5 10:15 /dev/bus/usb/004/002
Next thing i tried to use this device inside a docker container (running inside incus) using the instructions here. Unfortunately, the device is not usable inside the container.
#docker run -ti --rm --entrypoint=/bin/bash --privileged --mount type=bind,source=/dev,target=/dev ghcr.io/blakeblackshear/frigate:stable
#cd ~ && apt-get -y update && apt-get -y install curl && mkdir test_data && cd test_data && curl -LO https://coral.ai/static/docs/images/parrot.jpg && curl -LO https://raw.githubusercontent.com/google-coral/test_data/master/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite && curl -LO https://raw.githubusercontent.com/google-coral/test_data/master/inat_bird_labels.txt && cd .. && curl -LO https://raw.githubusercontent.com/google-coral/pycoral/master/examples/classify_image.py && python3 classify_image.py --model test_data/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite --labels test_data/inat_bird_labels.txt --input test_data/parrot.jpg
Traceback (most recent call last):
File "/root/classify_image.py", line 121, in <module>
main()
File "/root/classify_image.py", line 71, in main
interpreter = make_interpreter(*args.model.split('@'))
File "/usr/lib/python3/dist-packages/pycoral/utils/edgetpu.py", line 87, in make_interpreter
delegates = [load_edgetpu_delegate({'device': device} if device else {})]
File "/usr/lib/python3/dist-packages/pycoral/utils/edgetpu.py", line 52, in load_edgetpu_delegate
return tflite.load_delegate(_EDGETPU_SHARED_LIB, options or {})
File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 162, in load_delegate
raise ValueError('Failed to load delegate from {}\n{}'.format(
ValueError: Failed to load delegate from libedgetpu.so.1
This used to work with LXD, but i am not able to make it work now. Any idea why this doesnt work?
This seems to be happening because Google TPU changes its id on first use. So the device does not get picked up by incus. Is it possible to pass in the whole /dev/bus/usb to incus container rather than a particular USB device?
What is happening, is that your host is configured to load that Coral firmware through a systemd service.
The command is the following, which means that you need to set it up on your host, test it, then make it a systemd service.
you have setup your container with the correct final IDs for the device. You stop the container if it is running.
you then connect the device on the host. The device has the wrong, pre-init, IDs.
you run the above command, and verify that the IDs have changed to the ones configured in the container.
you can now start the container and verify that through this manual process, the container works.
Once it works manually, you can perform the subsequent steps to automate the process.
The systemd script is configured in such a way so that
the device is always connected to your host.
when the Incus service is started on bootup, systemd will run that firmware-loading command to configure the device.
you are ready to use the device in the container.
Personally I would opt for a udev solution (autoload the firmware upon connecting the device to the host). But do first the above steps so that you get a baseline setup.