From 158a76289e61d66bffbf16ca48d9da44863445ff Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Sun, 5 Jan 2025 07:35:41 -0500 Subject: [PATCH] try this --- sunnypilot/modeld/SConscript | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/sunnypilot/modeld/SConscript b/sunnypilot/modeld/SConscript index c1db9baeb9..fa4de7a6ce 100644 --- a/sunnypilot/modeld/SConscript +++ b/sunnypilot/modeld/SConscript @@ -52,7 +52,7 @@ lenvCython.Program('runners/runmodel_pyx.so', 'runners/runmodel_pyx.pyx', LIBS=c lenvCython.Program('runners/snpemodel_pyx.so', 'runners/snpemodel_pyx.pyx', LIBS=[snpemodel_lib, snpe_lib, *cython_libs], FRAMEWORKS=frameworks, RPATH=snpe_rpath) lenvCython.Program('models/commonmodel_pyx.so', 'models/commonmodel_pyx.pyx', LIBS=[commonmodel_lib, *cython_libs], FRAMEWORKS=frameworks) -tinygrad_files = ["#"+x for x in glob.glob(env.Dir("#tinygrad_repo").relpath + "/**", recursive=True, root_dir=env.Dir("#").abspath)] +tinygrad_files = ["#"+x for x in glob.glob(env.Dir("#tinygrad_repo").relpath + "/**", recursive=True, root_dir=env.Dir("#").abspath) if 'pycache' not in x] # Get model metadata fn = File("models/supercombo").abspath @@ -60,12 +60,14 @@ cmd = f'python3 {Dir("#selfdrive/modeld").abspath}/get_model_metadata.py {fn}.on lenv.Command(fn + "_metadata.pkl", [fn + ".onnx"] + tinygrad_files, cmd) # Build thneed model -if arch == "larch64" or GetOption('pc_thneed'): - tinygrad_opts = [] - if not GetOption('pc_thneed'): - # use FLOAT16 on device for speed + don't cache the CL kernels for space - tinygrad_opts += ["FLOAT16=1", "PYOPENCL_NO_CACHE=1"] - cmd = f"cd {Dir('#').abspath}/tinygrad_repo && " + ' '.join(tinygrad_opts) + f" python3 examples/openpilot/compile3.py {fn}.onnx {fn}.thneed" +pythonpath_string = 'PYTHONPATH="${PYTHONPATH}:' + env.Dir("#tinygrad_repo").abspath + '"' +if arch == 'larch64': + device_string = 'QCOM=1' +else: + device_string = 'CLANG=1 IMAGE=0' +if arch == "larch64": + fn = File(f"models/supercombo").abspath + cmd = f'{pythonpath_string} {device_string} python3 {Dir("#tinygrad_repo").abspath}/examples/openpilot/compile3.py {fn}.onnx {fn}.thneed' lenv.Command(fn + ".thneed", [fn + ".onnx"] + tinygrad_files, cmd)