Coral USB AI accelerator add-on NPU chip on Librem5 tested

Short version: It’s possible to add via L5’s usb port an AI accelerator that seems to work pretty well. In theory Coral may add some calculation power for some DIY AI applications. Easy to set up but the rest is a bit of a mystery…


Looonger version…

Background: Once upon a time I had time and wondered idly about things, including way to push L5 - hence the camera (QX-10 / QX-100) and modem (Sim7600 / Sim8202g) tests. While checking out what kind of cards could be added, I started to look into various m.2 cards that might add other features, like NPUs (I use NPU here to mean any additional computing chips that support AI). There actually are a few that come very close to being alternatives to modem or wifi/bt cards. Unfortunately the final hurdle seems to be that L5 doesn’t have PCI protocol available, so that became a dead end (sidenote: For instance Hailo would have several times more powerful card that fits the slot and has appropriate keying but…). Then I looked at card adapters and didn’t come a cross a suitable combination until I found that Coral made a few years ago an external USB variant too. It took some time but I finally managed to track one down to test.

Pros and cons:
Based on the test example, performance on L5 is almost the same as with a more normal computer. It’s possibly the only way to give this kind of performance to L5 (Intel did make a couple of usb sticks for AI computing but they seem less capable and have worse form factors to connect to L5). It’s small, energy efficient (although that is relative and debatable with L5’s already limited battery) and has decent support/documentation.
There are a few caveats too, of which I’ll point out four five main ones.

  • First, it is external and takes up the only usb port, so you may need to set up a hub or a splitter to keep the phone powered, but it does offer un-tethered offline addition.
  • Secondly, it’s a low level hardware, so it’s not directly supported by anything - just getting it and setting it won’t do anything - and you need to tinker and have some special project where to get any benefit from it.
  • Thirdly, as has been discussed elsewhere, the more useful way to use AI is to set up a connection to a service or your own server and let that do the heavy lifting and power use - you can then get the results to the L5 (of course this requires being online and a good data connection).
  • Fourthly, there is that nagging Google connection, which however seems to be in name only with this product (no links to other products, no need to sign up/in to anything, no online requirement, code is open etc.) while admittedly not a fully open system (to be clear, I’m not sure what the definition for this should be). It’s Google adjacent but in L5 it’s… manageable… in this case. Your views may vary (but do continue this line of conversation in one of the other threads, which there are several on this forum)
  • Fifth, this has an EOL issue, as it came out around 2019 and some of the relevant code only works with Python 3.9. This is perfect for current Pure OS byzantium (!) which is out of the box in Python 3.9.2. Not so good if you want to use Crimson or have updated python otherwise. This seems to have a solution of setting a separate Python environment (pyenv) alongside that uses the old version, but I don’t know about that.

Uses:
The test cases are image and camera based, so that’s the obvious direction. I would be nice to be able to identify what the camera sees (why not have Orca or some other app let you know out loud too).
The limitations of the usb device to the models does mean that not all AI tasks are suited for it.
Some ideas were talked in: https://www.reddit.com/r/unRAID/comments/zr7eij/is_the_google_coral_tpu_useful_for_anything_else/

Info (see also data sheet from links):
Tech details

  • ML accelerator: Google Edge TPU coprocessor: 4 TOPS (int8); 2 TOPS per watt
  • Connector: USB 3.0 Type-C* (data/power)
  • Dimensions: 65 mm x 30 mm x 8mm
  • One white status led (on/off)

Requirements

  • A computer with one of the following operating systems:
    • Linux Debian 10, or a derivative thereof (such as Ubuntu 18.04), and a system architecture of either x86-64, Armv7 (32-bit), or Armv8 (64-bit) (includes support for Raspberry Pi 3 Model B+, Raspberry Pi 4, and Raspberry Pi Zero 2)
    • macOS 10.15 (Catalina) or 11 (Big Sur), with either MacPorts or Homebrew installed
    • Windows 10
  • One available USB port (for the best performance, use a USB 3.0 port)
  • Python 3.6 - 3.9

About models on it:

  • Not all models and operations can run on an Edge TPU.
  • Why not? Cause *the model should be compiled to run in an Edge TPU device
  • In order to compile it *the model should be utra-quantized
  • Floats are forbidden here

Setup notes:
If you have PureOS byzantium (debian 10), then you can just follow the guide on Get started with the USB Accelerator | Coral In addition to that, you’ll also need to install curl and do some extra steps in the end to add udev rules (see bug fix from: https://blog.stackademic.com/google-coral-usb-accelerator-on-linux-a3201e7936a8?gi=fab44b18380c)
If you’ve installed Crimson already, I don’t know what to tell you. I’m hoping someone is interested enough to do a how to on setting up a separate pyenv for this - I tried doing it using a couple of sites, but couldn’t get it to work with the stick.
Oh, and btw, if you use the cable that come with the stick, usb A-C, and need to use an adapter to make it C-to-C, don’t use OTG adapter. If longer cable is ok (like for this testing), the original L5 charging/data cable works too.

Other notes:
I said the usb accelerator from 2019 was EOL but the coral tech seems to be keeping current (no mention if another USB module ever comes - I doubt it). It’s mostly about those few Python libraries (which could be updated - who knows).

I’ve only done rudimentary testing so far and won’t be doing anything on it for some weeks, at least - you are welcome to do your own. This was a proof of concept (PoC) that it’s possible to use it on L5, nothing more. It will not magically add AI to everything and is not identified by anything out of the box. It’s a solution if you need in-device (offline) AI computations and L5’s specs alone aren’t enough (see for example Ollama tests).

The rudimentary tests showed that it works nicely offline and thus is un-tethered to the big bad G. The L5 as a hardware platform and linux as a software platform gives us control to do this kind of tests, but it’s another thing to take such “to production”, use them with your daily driver/phone. In those cases I suggest thinking about how to verify the controls/blocks, maybe set up some specific firewall rules or confine the code and apps in to a virtual environment etc. - just in case, as is good practice.

Coral can be found second hand, or even unused, quite well and prices are around 60-140 $/€. I don’t think the usb version was ever very popular and both built in and GPU power surpassed it and its usefulness quickly. Yet, it seems like made for L5 and for tinkering for your own special private projects - like anything image/video related (it would be nice to have it pluggable to camera software and have it identify things). Coral could be fitted and taped (or screwed) to the back of an L5. Just needs a suitably short usb C-to-C cable.

Bottom line is… this is for those that want to tinker and/or have a special need that this scratches. One more extra thing that Librem 5 is able (be forced) to do (safely).

Some links:

4 Likes

… which is for security reasons.

2 Likes