Files
sunnypilot/openpilot/tools/wgpu/README.md
T
royjr c6991ead50 the
2026-07-25 05:12:47 -04:00

77 lines
2.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Wireless modeld proof of concept
This runs driving `modeld` on a laptop and returns its cereal outputs to a comma
device over the existing Wi-Fi network. It reuses the existing HEVC camera
stream, VisionIPC decoder, and cereal ZMQ bridge.
This is for offroad/bench testing only. Wi-Fi has no deterministic latency or
availability guarantee. The device restores local `modeld` when the device-side
helper exits, but that is not a seamless onroad failover.
## Build
Use the same commit on the laptop and comma device. Build the cereal bridge on
the device:
```sh
scons -u openpilot/cereal/messaging/bridge
```
Build and test the normal model on the laptop first:
```sh
PATH="$PWD/.venv/bin:$PATH" scons -u
```
To compile the big external-GPU model for the laptop's local tinygrad backend:
```sh
PATH="$PWD/.venv/bin:$PATH" WGPU=1 scons -u \
openpilot/selfdrive/modeld/models/big_driving_tinygrad.pkl.chunkmanifest
```
On macOS, the build selects tinygrad's Metal backend when it is available.
On an 8-GPU-core M5 MacBook Air, the small model's compiled policy pass measured
about 611 ms, while the big model measured about 7981 ms. The latter already
misses the 50 ms model cadence before network and codec latency, so start with
the small model on that class of laptop.
## Run
Find the laptop's LAN IP address that the comma device can reach. While the
device is offroad, run:
```sh
cd /data/openpilot
python3 -m openpilot.tools.wgpu.device LAPTOP_IP
```
Keep that terminal open. On the laptop, run:
```sh
cd /path/to/openpilot
python3 -m openpilot.tools.wgpu.host COMMA_IP
```
Add `--big-model` after `COMMA_IP` to use the locally compiled big model.
The first remote `carParams` packet can take up to 50 seconds. Stop either side
with Ctrl+C. Stop the device helper before changing branches or rebooting.
For stationary bench testing only, model lag can be changed from a blocking
event to a live warning showing model age and dropped frames. After ignition is
on and manager is running, enable the temporary override on the device:
```sh
cd /data/openpilot
python3 -c 'from openpilot.common.params import Params; Params().put_bool("WgpuBenchMode", True)'
```
The override requires `WgpuEnabled` and clears on manager restart or the next
ignition-on transition. Disable it immediately with:
```sh
cd /data/openpilot
python3 -c 'from openpilot.common.params import Params; Params().remove("WgpuBenchMode")'
```