AI+D
tutorial |

Edge Impulse CLI in Docker: A Cross-Platform Guide

Edge Impulse CLI in Docker

Edge Impulse offers powerful tools for building machine learning models optimized for edge devices. Running the Edge Impulse CLI inside a Docker container can simplify setup and keep your host system clean. This guide explains how to configure and run the CLI on Windows and, if applicable, continue directly on Linux or Mac in Step 3.

Prerequisites

Ensure you have the following installed on your Windows machine:

  1. Docker Desktop - Install Docker from the official site: Docker Desktop.
  2. Windows Subsystem for Linux (WSL 2) - Required for Docker’s Linux containers. Follow the Microsoft guide to install WSL 2.
  3. Edge Impulse account - Sign up at Edge Impulse.

Step 1: Enable WSL 2 Backend in Docker

  1. Open Docker Desktop.
  2. Navigate to Settings > General.
  3. Check Use the WSL 2 based engine.
  4. Restart Docker Desktop for the change to take effect.

Step 2: Configure the COM Port for Docker in WSL (Windows Only)

To allow Docker in WSL to communicate with USB devices, install the USBIPD-WIN tool. Follow the official Microsoft guide here: Connecting USB devices in WSL.

Installing USBIPD-WIN

  1. Download and run the latest usbipd-win .msi installer from the usbipd-win releases page.
  2. Or install via Windows Package Manager:
    winget install --interactive --exact dorssel.usbipd-win
    

Sharing and Attaching Your USB Device

  1. Open PowerShell as an administrator and list connected USB devices:
    usbipd list
    
  2. Find your device’s busid and bind it:
    usbipd bind --busid <busid>
    
  3. In your WSL distribution, attach the device:
    usbip attach --busid=<busid>
    
  4. Confirm the device is attached:
    lsusb
    

Step 3: Run Docker and Install the Edge Impulse CLI

Using the Microsoft devcontainer, launching Docker is straightforward. Execute the following command on any platform:

docker run -t -i --device=/dev/ttyACM0 mcr.microsoft.com/devcontainers/javascript-node /bin/bash

Inside the container, update packages and install required utilities:

apt-get update && apt-get install -y udev
npm install -g edge-impulse-cli

Step 4: Use the Data Forwarder with Your Edge Impulse Account

Now, you can run the edge-impulse-data-forwarder to collect sensor data and upload it to your Edge Impulse account.


Following these steps, you can successfully run Edge Impulse CLI inside a Docker container while ensuring access to USB devices. Happy coding!