Skip to content

Commit 521e712

Browse files
committed
Merge development into master
2 parents 00d8c6f + 7e2d846 commit 521e712

File tree

93 files changed

+58648
-3204
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+58648
-3204
lines changed

.dockerignore

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Version control
2+
.git
3+
.github
4+
.gitignore
5+
6+
# Python caches
7+
__pycache__
8+
*/__pycache__
9+
*/*/__pycache__
10+
*.pyc
11+
*.pyo
12+
*.egg-info
13+
.pytest_cache
14+
.mypy_cache
15+
.coverage
16+
17+
# Virtual environments
18+
.venv
19+
venv
20+
*venv*
21+
22+
# IDE settings
23+
*.idea/
24+
*.vscode/
25+
*.swp
26+
*.swo
27+
28+
# Documentation and images (not needed at runtime)
29+
docs/
30+
notebooks/
31+
images/
32+
33+
# Build artifacts and model files
34+
*.h5
35+
*.keras
36+
*.err
37+
*.out
38+
*.svg
39+
*build*
40+
41+
# Zephyr/west workspace artifacts (downloaded at build time by embedded target)
42+
tflite/bootloader/
43+
tflite/modules/
44+
tflite/tools/
45+
tflite/zephyr/
46+
tflite/build*
47+
tflite/optional/
48+
tflite/log.log
49+
.west
50+
51+
# Large data directories (mount as volumes at runtime)
52+
datasets/data/
53+
datasets/downloads/
54+
Results/
55+
56+
# Miscellaneous (from .gitignore)
57+
nrf-command-line-tools*
58+
*.ipynb_checkpoints
59+
*power_*
60+
*airway*
61+
*EvoVis*
62+
baselines/private/
63+
baselines/cifar10/
64+
baselines/daliac/
65+
baselines/emg_airob/
66+
baselines/speech_commands/
67+
68+
# Self-referential
69+
Dockerfile
70+
.dockerignore
71+
install.sh
72+
73+
# Claude config
74+
.claude/

.gitignore

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ tflite/tools/
44
tflite/zephyr/
55
tflite/build*
66
tflite/log.log
7+
*.log
8+
results_profile/
79
tiny_ml/
810
*pycache*
911
Results/
1012
*utils/datasets.py
1113
*.cc
1214
#*.tflite
1315
*.h5
16+
*.pdf
1417
tests-resnet.ipynb
1518
tests-tflite.ipynb
1619
test-pyserial.ipynb
@@ -23,12 +26,14 @@ README.txt
2326
nrf-command-line-tools*
2427
*.ipynb_checkpoints
2528
get_ops.py
26-
*build*
29+
build/
30+
**/build-*/
2731
*power_*
2832
venv
2933
*airway*
3034
*venv*
3135
tflite/optional/*
36+
tmp/
3237

3338
datasets/data/*
3439
baselines/private/
@@ -49,4 +54,6 @@ baselines/speech_commands/
4954
*.idea/
5055
*.vscode/
5156
*.coverage
52-
*.west
57+
*.west
58+
59+
scripts/plot_surrogate_paper.py

Dockerfile

Lines changed: 92 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,68 @@
1-
# # Use an official lightweight Python image.
2-
FROM tensorflow/tensorflow:2.9.1-gpu
1+
# ===========================================================================
2+
# EdgeVolution Multi-Target Dockerfile
3+
#
4+
# Targets:
5+
# ml - TensorFlow 2.9.1 GPU + Python deps + project code (DEFAULT)
6+
# embedded - Extends ml with nRF tools, J-Link, Zephyr SDK, west workspace
7+
#
8+
# Usage:
9+
# docker build -t edgevolution . # builds ml
10+
# docker build --target embedded -t edgevolution-embedded . # builds embedded
11+
# ===========================================================================
12+
13+
# ===========================================================================
14+
# Stage 1: ML / NAS runtime (default target)
15+
# Base: tensorflow/tensorflow:2.9.1-gpu (Ubuntu 20.04, Python 3.8, CUDA 11.2)
16+
# ===========================================================================
17+
FROM tensorflow/tensorflow:2.9.1-gpu AS ml
318

4-
# # Prevent interactive dialogs during apt-get installs
519
ENV DEBIAN_FRONTEND=noninteractive
620

7-
# ---------------------------------------------------------------------------
8-
# System dependencies & basic setup
9-
# ---------------------------------------------------------------------------
21+
# The TF base image already provides python3, pip, wget, curl, etc.
22+
# Only install packages that are actually missing.
23+
# git - required by GitPython (used in utils/saver.py)
24+
# ffmpeg - required by librosa/pydub for audio processing
25+
# libsndfile1 - required by SoundFile for audio I/O
26+
# vim - convenience for interactive debugging
1027
RUN apt-get update && apt-get install -y --no-install-recommends \
11-
wget \
12-
dpkg \
1328
git \
29+
ffmpeg \
30+
libsndfile1 \
1431
vim \
15-
vim-common \
16-
ca-certificates \
17-
udev \
18-
libusb-1.0-0 \
19-
libxcb-render-util0 \
20-
libxcb-randr0 \
21-
libxcb-icccm4 \
22-
libxcb-keysyms1 \
23-
libxcb-image0 \
24-
libxkbcommon-x11-0 \
25-
sudo \
32+
&& rm -rf /var/lib/apt/lists/*
33+
34+
WORKDIR /EdgeVolution
35+
36+
# Copy requirements.txt FIRST for Docker layer caching.
37+
# pip install is only re-run when requirements.txt changes,
38+
# not on every source code change.
39+
COPY requirements.txt /EdgeVolution/requirements.txt
40+
RUN pip install --upgrade pip \
41+
&& pip install --no-cache-dir --timeout 600 -r requirements.txt
42+
43+
# Copy the rest of the project source code.
44+
# .dockerignore prevents copying .git, docs, notebooks, build artifacts, etc.
45+
COPY . /EdgeVolution
46+
RUN pip install --no-cache-dir -e .
47+
48+
CMD ["/bin/bash"]
49+
50+
51+
# ===========================================================================
52+
# Stage 2: Embedded toolchain (extends ml)
53+
# Adds: nRF CLI tools, Segger J-Link, CMake >= 3.20, Zephyr SDK, west workspace
54+
# ===========================================================================
55+
FROM ml AS embedded
56+
57+
ENV DEBIAN_FRONTEND=noninteractive
58+
59+
# System packages required by Zephyr, west, nRF tools, and the C/C++ build.
60+
RUN apt-get update && apt-get install -y --no-install-recommends \
2661
gnupg \
2762
lsb-release \
63+
udev \
64+
libusb-1.0-0 \
2865
build-essential \
29-
ffmpeg \
30-
python3 \
31-
python3-pip \
32-
python3-venv \
33-
python3-dev \
34-
git \
3566
ninja-build \
3667
gperf \
3768
ccache \
@@ -45,104 +76,66 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
4576
g++-multilib \
4677
libsdl2-dev \
4778
libmagic1 \
79+
wget \
4880
&& rm -rf /var/lib/apt/lists/*
4981

5082

5183
# ---------------------------------------------------------------------------
52-
# Install nRF Command Line Tools (including nrfjprog)
84+
# CMake 3.28 (compatible with Python 3.8; CMake 4.x requires Python 3.9+)
5385
# ---------------------------------------------------------------------------
54-
WORKDIR /tmp/nrf
55-
RUN wget "https://nsscprodmedia.blob.core.windows.net/prod/software-and-other-downloads/desktop-software/nrf-command-line-tools/sw/versions-10-x-x/10-21-0/nrf-command-line-tools-10.21.0_linux-amd64.tar.gz" \
56-
&& tar xvf nrf-command-line-tools-10.21.0_linux-amd64.tar.gz \
57-
&& sudo cp -a nrf-command-line-tools /opt/ \
58-
&& rm -rf nrf-command-line-tools-10.21.0_linux-amd64.tar.gz nrf-command-line-tools
59-
60-
ENV PATH="${PATH}:/opt/nrf-command-line-tools/bin"
86+
RUN wget -q https://github.com/Kitware/CMake/releases/download/v3.28.6/cmake-3.28.6-linux-x86_64.tar.gz \
87+
&& tar xf cmake-3.28.6-linux-x86_64.tar.gz --strip-components=1 -C /usr/local \
88+
&& rm cmake-3.28.6-linux-x86_64.tar.gz
6189

6290
# ---------------------------------------------------------------------------
63-
# Install Segger J-Link software
64-
# (You might want to update the version to the latest.)
91+
# nRF Command Line Tools (including nrfjprog)
6592
# ---------------------------------------------------------------------------
66-
RUN /lib/systemd/systemd-udevd --daemon
67-
RUN udevadm monitor &
68-
69-
RUN wget --post-data="accept_license_agreement=accepted&submit=Download+software" https://www.segger.com/downloads/jlink/JLink_Linux_V788n_x86_64.deb
70-
71-
# Took this small workaround from: https://forums.docker.com/t/udevadm-monitor-in-docker-file/125723
72-
RUN dpkg --unpack JLink_Linux_V788n_x86_64.deb
73-
RUN rm /var/lib/dpkg/info/jlink.postinst -f
74-
RUN dpkg --configure jlink
75-
RUN apt install -yf
93+
WORKDIR /tmp/nrf
94+
RUN wget -q "https://nsscprodmedia.blob.core.windows.net/prod/software-and-other-downloads/desktop-software/nrf-command-line-tools/sw/versions-10-x-x/10-21-0/nrf-command-line-tools-10.21.0_linux-amd64.tar.gz" \
95+
&& tar xf nrf-command-line-tools-10.21.0_linux-amd64.tar.gz \
96+
&& cp -a nrf-command-line-tools /opt/ \
97+
&& rm -rf /tmp/nrf
7698

77-
# ---------------------------------------------------------------------------
78-
# Install CMake (some distributions already have an older version).
79-
# ---------------------------------------------------------------------------
80-
RUN wget https://apt.kitware.com/kitware-archive.sh \
81-
&& sudo bash kitware-archive.sh \
82-
&& rm kitware-archive.sh \
83-
&& apt-get update && apt-get install -y cmake
99+
ENV PATH="${PATH}:/opt/nrf-command-line-tools/bin"
84100

85101
# ---------------------------------------------------------------------------
86-
# Install west (Zephyr's meta-tool) and dependencies
102+
# Segger J-Link
103+
# The J-Link .deb postinst script tries to start udev/systemd services
104+
# which don't exist in Docker. Workaround:
105+
# 1. dpkg --unpack (extract files without running postinst)
106+
# 2. Remove the postinst script
107+
# 3. dpkg --configure (mark package as configured)
108+
# 4. apt-get install -yf (resolve any missing dependencies)
87109
# ---------------------------------------------------------------------------
88-
RUN pip install west
110+
WORKDIR /tmp/jlink
111+
RUN wget -q --post-data="accept_license_agreement=accepted&submit=Download+software" \
112+
https://www.segger.com/downloads/jlink/JLink_Linux_V788n_x86_64.deb \
113+
&& dpkg --unpack JLink_Linux_V788n_x86_64.deb \
114+
&& rm -f /var/lib/dpkg/info/jlink.postinst \
115+
&& apt-get update && apt-get install -yf \
116+
&& rm -rf /var/lib/apt/lists/* /tmp/jlink
89117

90118
# ---------------------------------------------------------------------------
91-
# Install Zephyr SDK to /opt/zephyr-sdk-0.16.5-1
119+
# Zephyr SDK 0.16.5-1
92120
# ---------------------------------------------------------------------------
93121
WORKDIR /opt
94-
RUN wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.5-1/zephyr-sdk-0.16.5-1_linux-x86_64.tar.xz \
95-
&& wget -O - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.5-1/sha256.sum | shasum --check --ignore-missing \
96-
&& tar xvf zephyr-sdk-0.16.5-1_linux-x86_64.tar.xz \
122+
RUN wget -q https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.5-1/zephyr-sdk-0.16.5-1_linux-x86_64.tar.xz \
123+
&& wget -q -O - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.5-1/sha256.sum | shasum --check --ignore-missing \
124+
&& tar xf zephyr-sdk-0.16.5-1_linux-x86_64.tar.xz \
97125
&& rm zephyr-sdk-0.16.5-1_linux-x86_64.tar.xz
98126

99127
ENV ZEPHYR_SDK_INSTALL_DIR="/opt/zephyr-sdk-0.16.5-1"
100128

101129
# ---------------------------------------------------------------------------
102-
# Create a non-root user
130+
# Upgrade west to 1.0.0 (Zephyr 4.0.0 build.py requires west.commands.Verbosity,
131+
# which was removed in west 0.14.0 and re-added in west 1.0.0)
103132
# ---------------------------------------------------------------------------
104-
ARG USERNAME=edgedev
105-
ARG USER_UID=1000
106-
ARG USER_GID=$USER_UID
107-
108-
RUN groupadd --gid $USER_GID $USERNAME \
109-
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME -s /bin/bash \
110-
&& echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/$USERNAME \
111-
&& chmod 0440 /etc/sudoers.d/$USERNAME
112-
113-
# Add user to dialout group for serial port access
114-
RUN usermod -a -G dialout,plugdev $USERNAME
133+
RUN pip install --no-cache-dir west==1.0.0
115134

116135
# ---------------------------------------------------------------------------
117-
# Create a project directory and copy your files
118-
# (Assuming you have requirements.txt and a tflite/ folder, etc.)
136+
# Zephyr workspace is provided via volume mount from the host.
137+
# The host must have .west/, zephyr/, modules/, etc. in tflite/.
119138
# ---------------------------------------------------------------------------
120139
WORKDIR /EdgeVolution
121-
COPY . /EdgeVolution
122140

123-
# ---------------------------------------------------------------------------
124-
# Install Python dependencies (as root, but accessible to user)
125-
# ---------------------------------------------------------------------------
126-
RUN pip install --upgrade pip \
127-
&& pip install --no-cache-dir -r requirements.txt
128-
129-
RUN pip install --upgrade numba librosa
130-
131-
# ---------------------------------------------------------------------------
132-
# Zephyr project initialization (as root first)
133-
# ---------------------------------------------------------------------------
134-
WORKDIR /EdgeVolution/tflite
135-
RUN if [ ! -f .west/config ]; then west init .; else echo "West workspace already initialized"; fi && \
136-
west config manifest.group-filter -- +optional && \
137-
west zephyr-export
138-
139-
# ---------------------------------------------------------------------------
140-
# Change ownership of the project directory to the non-root user
141-
# ---------------------------------------------------------------------------
142-
RUN chown -R $USERNAME:$USERNAME /EdgeVolution
143-
144-
# Switch to non-root user
145-
USER $USERNAME
146-
147-
WORKDIR /EdgeVolution
148-
CMD ["/bin/bash"]
141+
CMD ["/bin/bash"]
File renamed without changes.

0 commit comments

Comments
 (0)