Skip to content

Commit 47f2382

Browse files
authored
Tinygrad DEV=DEVICE (#35809)
* bump tg * step one cleanup * cleanup * typo * cleaner * cleaner * Revert "cleaner" This reverts commit 9c1abd0. * usbgpu * bit cleaner * cleaner sconscript
1 parent 938981d commit 47f2382

File tree

4 files changed

+10
-17
lines changed

4 files changed

+10
-17
lines changed

selfdrive/modeld/SConscript

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ def tg_compile(flags, model_name):
5050
# Compile small models
5151
for model_name in ['driving_vision', 'driving_policy', 'dmonitoring_model']:
5252
flags = {
53-
'larch64': 'QCOM=1',
54-
'Darwin': 'CPU=1 IMAGE=0 JIT=2',
55-
}.get(arch, 'LLVM=1 LLVMOPT=1 BEAM=0 IMAGE=0 JIT=2')
53+
'larch64': 'DEV=QCOM',
54+
'Darwin': 'DEV=CPU IMAGE=0',
55+
}.get(arch, 'DEV=LLVM IMAGE=0')
5656
tg_compile(flags, model_name)
5757

5858
# Compile BIG model if USB GPU is available
@@ -62,7 +62,7 @@ if "USBGPU" in os.environ:
6262
devs = subprocess.check_output('python3 -c "from tinygrad import Device; print(list(Device.get_available_devices()))"', shell=True, cwd=env.Dir('#').abspath)
6363
if b"AMD" in devs:
6464
print("USB GPU detected... building")
65-
flags = "AMD=1 AMD_IFACE=USB AMD_LLVM=1 NOLOCALS=0 IMAGE=0"
65+
flags = "DEV=AMD AMD_IFACE=USB AMD_LLVM=1 NOLOCALS=0 IMAGE=0"
6666
bp = tg_compile(flags, "big_driving_policy")
6767
bv = tg_compile(flags, "big_driving_vision")
6868
lenv.SideEffect('lock', [bp, bv]) # tg doesn't support multi-process so build serially

selfdrive/modeld/dmonitoringmodeld.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
#!/usr/bin/env python3
22
import os
33
from openpilot.system.hardware import TICI
4+
os.environ['DEV'] = 'QCOM' if TICI else 'LLVM'
45
from tinygrad.tensor import Tensor
56
from tinygrad.dtype import dtypes
6-
if TICI:
7-
from openpilot.selfdrive.modeld.runners.tinygrad_helpers import qcom_tensor_from_opencl_address
8-
os.environ['QCOM'] = '1'
9-
else:
10-
os.environ['LLVM'] = '1'
117
import math
128
import time
139
import pickle
@@ -24,6 +20,7 @@
2420
from openpilot.common.transformations.camera import _ar_ox_fisheye, _os_fisheye
2521
from openpilot.selfdrive.modeld.models.commonmodel_pyx import CLContext, MonitoringModelFrame
2622
from openpilot.selfdrive.modeld.parse_model_outputs import sigmoid
23+
from openpilot.selfdrive.modeld.runners.tinygrad_helpers import qcom_tensor_from_opencl_address
2724

2825
MODEL_WIDTH, MODEL_HEIGHT = DM_INPUT_SIZE
2926
CALIB_LEN = 3

selfdrive/modeld/modeld.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
#!/usr/bin/env python3
22
import os
33
from openpilot.system.hardware import TICI
4+
os.environ['DEV'] = 'QCOM' if TICI else 'LLVM'
45
USBGPU = "USBGPU" in os.environ
56
if USBGPU:
6-
os.environ['AMD'] = '1'
7+
os.environ['DEV'] = 'AMD'
78
os.environ['AMD_IFACE'] = 'USB'
8-
elif TICI:
9-
from openpilot.selfdrive.modeld.runners.tinygrad_helpers import qcom_tensor_from_opencl_address
10-
os.environ['QCOM'] = '1'
11-
else:
12-
os.environ['LLVM'] = '1'
13-
os.environ['JIT'] = '2'
149
from tinygrad.tensor import Tensor
1510
from tinygrad.dtype import dtypes
1611
import time
@@ -34,6 +29,7 @@
3429
from openpilot.selfdrive.modeld.fill_model_msg import fill_model_msg, fill_pose_msg, PublishState
3530
from openpilot.selfdrive.modeld.constants import ModelConstants, Plan
3631
from openpilot.selfdrive.modeld.models.commonmodel_pyx import DrivingModelFrame, CLContext
32+
from openpilot.selfdrive.modeld.runners.tinygrad_helpers import qcom_tensor_from_opencl_address
3733

3834

3935
PROCESS_NAME = "selfdrive.modeld.modeld"

0 commit comments

Comments
 (0)