From 60b7114024181f79819c9a8b14863a8f23fb0252 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 26 Apr 2022 11:49:32 -0700 Subject: [PATCH] onnxruntime: initialize CUDA provider before predictions (#24330) * initialize CUDA runtime before predictions * dmond pauses modeld execution... * done in other PR --- selfdrive/modeld/runners/onnx_runner.py | 5 +++++ selfdrive/test/process_replay/regen.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/selfdrive/modeld/runners/onnx_runner.py b/selfdrive/modeld/runners/onnx_runner.py index 3b19550e8ff41e..2a6238c1d2755c 100755 --- a/selfdrive/modeld/runners/onnx_runner.py +++ b/selfdrive/modeld/runners/onnx_runner.py @@ -25,6 +25,11 @@ def write(d): def run_loop(m): ishapes = [[1]+ii.shape[1:] for ii in m.get_inputs()] keys = [x.name for x in m.get_inputs()] + + # run once to initialize CUDA provider + if "CUDAExecutionProvider" in m.get_providers(): + m.run(None, dict(zip(keys, [np.zeros(shp, dtype=np.float32) for shp in ishapes]))) + print("ready to run onnx model", keys, ishapes, file=sys.stderr) while 1: inputs = [] diff --git a/selfdrive/test/process_replay/regen.py b/selfdrive/test/process_replay/regen.py index a88aa72f389793..5084a4006073b8 100755 --- a/selfdrive/test/process_replay/regen.py +++ b/selfdrive/test/process_replay/regen.py @@ -224,6 +224,11 @@ def regen_segment(lr, frs=None, outdir=FAKEDATA): } try: + # TODO: make first run of onnxruntime CUDA provider fast + managed_processes["modeld"].start() + managed_processes["dmonitoringmodeld"].start() + time.sleep(5) + # start procs up ignore = list(fake_daemons.keys()) + ['ui', 'manage_athenad', 'uploader'] ensure_running(managed_processes.values(), started=True, not_run=ignore)