Skip to content

Commit

Permalink
onnxruntime: initialize CUDA provider before predictions (commaai#24330)
Browse files Browse the repository at this point in the history
* initialize CUDA runtime before predictions

* dmond pauses modeld execution...

* done in other PR
  • Loading branch information
sshane authored Apr 26, 2022
1 parent 59134c0 commit 60b7114
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions selfdrive/modeld/runners/onnx_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
5 changes: 5 additions & 0 deletions selfdrive/test/process_replay/regen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 60b7114

Please sign in to comment.