From 2382f1cab0cd992941dcbacda5b2533559506667 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Mon, 24 Mar 2025 15:54:42 -0700 Subject: [PATCH] Run DM model twice, prep for bigger models (#34894) * twice * swap * adjust --- selfdrive/modeld/dmonitoringmodeld.py | 5 ++++- selfdrive/test/test_onroad.py | 8 ++++++-- system/hardware/tici/tests/test_power_draw.py | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/selfdrive/modeld/dmonitoringmodeld.py b/selfdrive/modeld/dmonitoringmodeld.py index 9ebdea4c75..94e117bc6a 100755 --- a/selfdrive/modeld/dmonitoringmodeld.py +++ b/selfdrive/modeld/dmonitoringmodeld.py @@ -134,7 +134,7 @@ def get_driverstate_packet(model_output: np.ndarray, frame_id: int, location_ts: def main(): setproctitle(PROCESS_NAME) - config_realtime_process([0, 1, 2, 3], 5) + config_realtime_process(7, 5) sentry.set_tag("daemon", PROCESS_NAME) cloudlog.bind(daemon=PROCESS_NAME) @@ -173,6 +173,9 @@ def main(): model_output, gpu_execution_time = model.run(buf, calib, model_transform) t2 = time.perf_counter() + # run one more time, just for the load + model.run(buf, calib, model_transform) + pm.send("driverStateV2", get_driverstate_packet(model_output, vipc_client.frame_id, vipc_client.timestamp_sof, t2 - t1, gpu_execution_time)) diff --git a/selfdrive/test/test_onroad.py b/selfdrive/test/test_onroad.py index 0f8fbce050..de329d85f2 100644 --- a/selfdrive/test/test_onroad.py +++ b/selfdrive/test/test_onroad.py @@ -391,8 +391,12 @@ class TestOnroad: result += "----------------- Model Timing -----------------\n" result += "------------------------------------------------\n" cfgs = [ - ("modelV2", 0.045, 0.040), # TODO: this should be stricter but it's hard to measure exactly - ("driverStateV2", 0.045, 0.035), + # since multiple processes use the GPU and can preempt each other, + # these numbers are not fully self-contained. + ("modelV2", 0.06, 0.040), + + # can miss cycles here and there, just important the avg frequency is 20Hz + ("driverStateV2", 0.2, 0.05), ] for (s, instant_max, avg_max) in cfgs: ts = [getattr(m, s).modelExecutionTime for m in self.msgs[s]] diff --git a/system/hardware/tici/tests/test_power_draw.py b/system/hardware/tici/tests/test_power_draw.py index e1b9845c4c..669889a2ae 100644 --- a/system/hardware/tici/tests/test_power_draw.py +++ b/system/hardware/tici/tests/test_power_draw.py @@ -33,7 +33,7 @@ class Proc: PROCS = [ Proc(['camerad'], 1.75, msgs=['roadCameraState', 'wideRoadCameraState', 'driverCameraState']), Proc(['modeld'], 1.12, atol=0.2, msgs=['modelV2']), - Proc(['dmonitoringmodeld'], 0.6, msgs=['driverStateV2']), + Proc(['dmonitoringmodeld'], 1.4, msgs=['driverStateV2']), Proc(['encoderd'], 0.23, msgs=[]), ]