diff --git a/SConstruct b/SConstruct index bb5c35feb785ff..98951b8e13d999 100644 --- a/SConstruct +++ b/SConstruct @@ -55,6 +55,16 @@ assert arch in [ "Darwin", # macOS arm64 (x86 not supported) ] +if arch == "comma_arm64": + from openpilot.common.utils import sudo_write + for cpu in range(4, 8): + sudo_write('1', f'/sys/devices/system/cpu/cpu{cpu}/online') + for policy in ('0', '4'): + governor_path = f'/sys/devices/system/cpu/cpufreq/policy{policy}' + sudo_write('performance', f'{governor_path}/scaling_governor') + with open(f'{governor_path}/cpuinfo_max_freq') as f: + sudo_write(f.read().strip(), f'{governor_path}/scaling_max_freq') + pkg_names = ['acados', 'capnproto', 'ffmpeg', 'json11', 'ncurses', 'zeromq', 'zstd'] pkgs = [importlib.import_module(name) for name in pkg_names] acados = pkgs[pkg_names.index('acados')] diff --git a/openpilot/selfdrive/modeld/SConscript b/openpilot/selfdrive/modeld/SConscript index 30a31aae271f8e..1f40fe1ce1d733 100644 --- a/openpilot/selfdrive/modeld/SConscript +++ b/openpilot/selfdrive/modeld/SConscript @@ -45,7 +45,7 @@ tg_devices = { # which device to put jit inputs to at runtime USBGPU = usbgpu_present() if USBGPU: - usbgpu_tg_flags = f'DEBUG=2 DEV=USB+AMD:LLVM WARP_DEV={tg_backend} FLOAT16=1 JIT_BATCH_SIZE=0 GMMU=0 TC_OPT=2' + usbgpu_tg_flags = f'DEBUG=1 DEV=USB+AMD:LLVM WARP_DEV={tg_backend} FLOAT16=1 JIT_BATCH_SIZE=0 GMMU=0 TC_OPT=2' # the USB+AMD GPU takes an exclusive flock; serialize all targets that touch it usbgpu_lock = File("models/.usb_gpu.lock").abspath @@ -79,8 +79,8 @@ for usbgpu in [False, True] if USBGPU else [False]: file_prefix, cmd_flags = ('big_', usbgpu_tg_flags) if usbgpu else ('big_' if os.getenv('BIG_INTO_SMALL') else '', tg_flags) driving_onnx_deps = get_existing_chunks(File(f"models/{file_prefix}driving_supercombo.onnx").abspath) camera_res_args = ' '.join(f'{cw}x{ch}' for cw, ch in CAMERA_CONFIGS) - # CPU 7 is isolated with isolcpus on AGNOS, so explicitly pin the compiler to it. - taskset = 'taskset -c 7 ' if arch == 'comma_arm64' else '' + # CPU 7 is isolated with isolcpus on AGNOS, so explicitly include it along with the other cores. + taskset = 'taskset -c 0-7 ' if arch == 'comma_arm64' else '' cmd = (f'{cmd_flags} {mac_brew_string} {taskset}python3 {modeld_dir}/compile_modeld.py ' f'--model-size {model_w}x{model_h} ' f'--camera-resolutions {camera_res_args} ' diff --git a/openpilot/selfdrive/modeld/compile_modeld.py b/openpilot/selfdrive/modeld/compile_modeld.py index 2d27a41496e8b4..dec4944e1f8784 100755 --- a/openpilot/selfdrive/modeld/compile_modeld.py +++ b/openpilot/selfdrive/modeld/compile_modeld.py @@ -3,7 +3,6 @@ import atexit import math import os -import tempfile import time import shutil from functools import partial @@ -11,7 +10,7 @@ import numpy as np -from openpilot.selfdrive.modeld.helpers import dump_oob, load_oob +from openpilot.selfdrive.modeld.helpers import dump_oob def _patch_tinygrad_fetch_fw(): import hashlib @@ -35,7 +34,6 @@ def fetch_fw(path, name, sha256): from tinygrad.device import Device from tinygrad.engine.jit import TinyJit - NV12Frame = namedtuple("NV12Frame", ['width', 'height', 'stride', 'y_height', 'uv_height', 'size']) WARP_INPUTS = ['tfm', 'big_tfm'] POLICY_INPUTS = ['img_q', 'big_img_q', 'feat_q', 'desire_q', 'packed_npy_inputs'] @@ -257,11 +255,7 @@ def random_inputs_run(fn, seed, test_val=None, test_buffers=None, expect_match=T print('capture + replay') test_val, test_buffers = random_inputs_run(jit, SEED) - print('pickle round trip') - with tempfile.TemporaryFile(dir=".") as f: - dump_oob(jit, f) - f.seek(0) - jit = load_oob(f) + print('validate replay') random_inputs_run(jit, SEED, test_val, test_buffers, expect_match=True) random_inputs_run(jit, SEED+1, test_val, test_buffers, expect_match=False) return jit @@ -274,6 +268,8 @@ def _parse_size(s): def read_file_chunked_to_disk(path): from openpilot.common.file_chunker import open_file_chunked + if os.path.isfile(path): + return path tmp_path = f'{path}.unchunked' with open(tmp_path, 'wb') as f, open_file_chunked(path) as src: shutil.copyfileobj(src, f)