Skip to content

Commit 5e07636

Browse files
committed
Revert "Tinygrad DEV=DEVICE (#35809)"
This reverts commit 47f2382.
1 parent b99c73e commit 5e07636

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
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': 'DEV=QCOM',
54-
'Darwin': 'DEV=CPU IMAGE=0',
55-
}.get(arch, 'DEV=LLVM IMAGE=0')
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')
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 = "DEV=AMD AMD_IFACE=USB AMD_LLVM=1 NOLOCALS=0 IMAGE=0"
65+
flags = "AMD=1 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: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
#!/usr/bin/env python3
22
import os
33
from openpilot.system.hardware import TICI
4-
os.environ['DEV'] = 'QCOM' if TICI else 'LLVM'
54
from tinygrad.tensor import Tensor
65
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'
711
import math
812
import time
913
import pickle
@@ -20,7 +24,6 @@
2024
from openpilot.common.transformations.camera import _ar_ox_fisheye, _os_fisheye
2125
from openpilot.selfdrive.modeld.models.commonmodel_pyx import CLContext, MonitoringModelFrame
2226
from openpilot.selfdrive.modeld.parse_model_outputs import sigmoid
23-
from openpilot.selfdrive.modeld.runners.tinygrad_helpers import qcom_tensor_from_opencl_address
2427

2528
MODEL_WIDTH, MODEL_HEIGHT = DM_INPUT_SIZE
2629
CALIB_LEN = 3

selfdrive/modeld/modeld.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
#!/usr/bin/env python3
22
import os
33
from openpilot.system.hardware import TICI
4-
os.environ['DEV'] = 'QCOM' if TICI else 'LLVM'
54
USBGPU = "USBGPU" in os.environ
65
if USBGPU:
7-
os.environ['DEV'] = 'AMD'
6+
os.environ['AMD'] = '1'
87
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'
914
from tinygrad.tensor import Tensor
1015
from tinygrad.dtype import dtypes
1116
import time
@@ -29,7 +34,6 @@
2934
from openpilot.selfdrive.modeld.fill_model_msg import fill_model_msg, fill_pose_msg, PublishState
3035
from openpilot.selfdrive.modeld.constants import ModelConstants, Plan
3136
from openpilot.selfdrive.modeld.models.commonmodel_pyx import DrivingModelFrame, CLContext
32-
from openpilot.selfdrive.modeld.runners.tinygrad_helpers import qcom_tensor_from_opencl_address
3337

3438

3539
PROCESS_NAME = "selfdrive.modeld.modeld"

0 commit comments

Comments
 (0)