Skip to content

Commit c17a395

Browse files
committed
Revert "revert tg calib and opencl cleanup (#37113)"
This reverts commit 51312af.
1 parent 51312af commit c17a395

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+300
-5235
lines changed

Dockerfile.openpilot_base

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -18,43 +18,6 @@ RUN /tmp/tools/install_ubuntu_dependencies.sh && \
1818
cd /usr/lib/gcc/arm-none-eabi/* && \
1919
rm -rf arm/ thumb/nofp thumb/v6* thumb/v8* thumb/v7+fp thumb/v7-r+fp.sp
2020

21-
# Add OpenCL
22-
RUN apt-get update && apt-get install -y --no-install-recommends \
23-
apt-utils \
24-
alien \
25-
unzip \
26-
tar \
27-
curl \
28-
xz-utils \
29-
dbus \
30-
gcc-arm-none-eabi \
31-
tmux \
32-
vim \
33-
libx11-6 \
34-
wget \
35-
&& rm -rf /var/lib/apt/lists/*
36-
37-
RUN mkdir -p /tmp/opencl-driver-intel && \
38-
cd /tmp/opencl-driver-intel && \
39-
wget https://github.com/intel/llvm/releases/download/2024-WW14/oclcpuexp-2024.17.3.0.09_rel.tar.gz && \
40-
wget https://github.com/oneapi-src/oneTBB/releases/download/v2021.12.0/oneapi-tbb-2021.12.0-lin.tgz && \
41-
mkdir -p /opt/intel/oclcpuexp_2024.17.3.0.09_rel && \
42-
cd /opt/intel/oclcpuexp_2024.17.3.0.09_rel && \
43-
tar -zxvf /tmp/opencl-driver-intel/oclcpuexp-2024.17.3.0.09_rel.tar.gz && \
44-
mkdir -p /etc/OpenCL/vendors && \
45-
echo /opt/intel/oclcpuexp_2024.17.3.0.09_rel/x64/libintelocl.so > /etc/OpenCL/vendors/intel_expcpu.icd && \
46-
cd /opt/intel && \
47-
tar -zxvf /tmp/opencl-driver-intel/oneapi-tbb-2021.12.0-lin.tgz && \
48-
ln -s /opt/intel/oneapi-tbb-2021.12.0/lib/intel64/gcc4.8/libtbb.so /opt/intel/oclcpuexp_2024.17.3.0.09_rel/x64 && \
49-
ln -s /opt/intel/oneapi-tbb-2021.12.0/lib/intel64/gcc4.8/libtbbmalloc.so /opt/intel/oclcpuexp_2024.17.3.0.09_rel/x64 && \
50-
ln -s /opt/intel/oneapi-tbb-2021.12.0/lib/intel64/gcc4.8/libtbb.so.12 /opt/intel/oclcpuexp_2024.17.3.0.09_rel/x64 && \
51-
ln -s /opt/intel/oneapi-tbb-2021.12.0/lib/intel64/gcc4.8/libtbbmalloc.so.2 /opt/intel/oclcpuexp_2024.17.3.0.09_rel/x64 && \
52-
mkdir -p /etc/ld.so.conf.d && \
53-
echo /opt/intel/oclcpuexp_2024.17.3.0.09_rel/x64 > /etc/ld.so.conf.d/libintelopenclexp.conf && \
54-
ldconfig -f /etc/ld.so.conf.d/libintelopenclexp.conf && \
55-
cd / && \
56-
rm -rf /tmp/opencl-driver-intel
57-
5821
ENV NVIDIA_VISIBLE_DEVICES=all
5922
ENV NVIDIA_DRIVER_CAPABILITIES=graphics,utility,compute
6023
ENV QTWEBENGINE_DISABLE_SANDBOX=1

SConstruct

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ env = Environment(
9494

9595
# Arch-specific flags and paths
9696
if arch == "larch64":
97-
env.Append(CPPPATH=["#third_party/opencl/include"])
9897
env.Append(LIBPATH=[
9998
"/usr/local/lib",
10099
"/system/vendor/lib64",

common/SConscript

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ common_libs = [
55
'swaglog.cc',
66
'util.cc',
77
'ratekeeper.cc',
8-
'clutil.cc',
98
]
109

1110
_common = env.Library('common', common_libs, LIBS="json11")

common/clutil.cc

Lines changed: 0 additions & 98 deletions
This file was deleted.

common/clutil.h

Lines changed: 0 additions & 28 deletions
This file was deleted.

common/mat.h

Lines changed: 0 additions & 85 deletions
This file was deleted.

selfdrive/modeld/SConscript

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,10 @@
11
import os
22
import glob
33

4-
Import('env', 'envCython', 'arch', 'cereal', 'messaging', 'common', 'visionipc')
4+
Import('env', 'arch')
55
lenv = env.Clone()
6-
lenvCython = envCython.Clone()
76

8-
libs = [cereal, messaging, visionipc, common, 'capnp', 'kj', 'pthread']
9-
frameworks = []
10-
11-
common_src = [
12-
"models/commonmodel.cc",
13-
"transforms/loadyuv.cc",
14-
"transforms/transform.cc",
15-
]
16-
17-
# OpenCL is a framework on Mac
18-
if arch == "Darwin":
19-
frameworks += ['OpenCL']
20-
else:
21-
libs += ['OpenCL']
22-
23-
# Set path definitions
24-
for pathdef, fn in {'TRANSFORM': 'transforms/transform.cl', 'LOADYUV': 'transforms/loadyuv.cl'}.items():
25-
for xenv in (lenv, lenvCython):
26-
xenv['CXXFLAGS'].append(f'-D{pathdef}_PATH=\\"{File(fn).abspath}\\"')
27-
28-
# Compile cython
29-
cython_libs = envCython["LIBS"] + libs
30-
commonmodel_lib = lenv.Library('commonmodel', common_src)
31-
lenvCython.Program('models/commonmodel_pyx.so', 'models/commonmodel_pyx.pyx', LIBS=[commonmodel_lib, *cython_libs], FRAMEWORKS=frameworks)
32-
tinygrad_files = sorted(["#"+x for x in glob.glob(env.Dir("#tinygrad_repo").relpath + "/**", recursive=True, root_dir=env.Dir("#").abspath) if 'pycache' not in x])
7+
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]
338

349
# Get model metadata
3510
for model_name in ['driving_vision', 'driving_policy', 'dmonitoring_model']:
@@ -38,22 +13,30 @@ for model_name in ['driving_vision', 'driving_policy', 'dmonitoring_model']:
3813
cmd = f'python3 {Dir("#selfdrive/modeld").abspath}/get_model_metadata.py {fn}.onnx'
3914
lenv.Command(fn + "_metadata.pkl", [fn + ".onnx"] + tinygrad_files + script_files, cmd)
4015

16+
# compile warp
17+
tg_flags = {
18+
'larch64': 'DEV=QCOM FLOAT16=1 NOLOCALS=1 JIT_BATCH_SIZE=0',
19+
'Darwin': f'DEV=CPU HOME={os.path.expanduser("~")}', # tinygrad calls brew which needs a $HOME in the env
20+
}.get(arch, 'DEV=CPU CPU_LLVM=1')
21+
image_flag = {
22+
'larch64': 'IMAGE=2',
23+
}.get(arch, 'IMAGE=0')
24+
script_files = [File(Dir("#selfdrive/modeld").File("compile_warp.py").abspath)]
25+
cmd = f'{tg_flags} python3 {Dir("#selfdrive/modeld").abspath}/compile_warp.py '
26+
lenv.Command(fn + "warp_tinygrad.pkl", tinygrad_files + script_files, cmd)
27+
4128
def tg_compile(flags, model_name):
4229
pythonpath_string = 'PYTHONPATH="${PYTHONPATH}:' + env.Dir("#tinygrad_repo").abspath + '"'
4330
fn = File(f"models/{model_name}").abspath
4431
return lenv.Command(
4532
fn + "_tinygrad.pkl",
4633
[fn + ".onnx"] + tinygrad_files,
47-
f'{pythonpath_string} {flags} python3 {Dir("#tinygrad_repo").abspath}/examples/openpilot/compile3.py {fn}.onnx {fn}_tinygrad.pkl'
34+
f'{pythonpath_string} {flags} {image_flag} python3 {Dir("#tinygrad_repo").abspath}/examples/openpilot/compile3.py {fn}.onnx {fn}_tinygrad.pkl'
4835
)
4936

5037
# Compile small models
5138
for model_name in ['driving_vision', 'driving_policy', 'dmonitoring_model']:
52-
flags = {
53-
'larch64': 'DEV=QCOM FLOAT16=1 NOLOCALS=1 IMAGE=2 JIT_BATCH_SIZE=0',
54-
'Darwin': f'DEV=CPU HOME={os.path.expanduser("~")}', # tinygrad calls brew which needs a $HOME in the env
55-
}.get(arch, 'DEV=CPU CPU_LLVM=1')
56-
tg_compile(flags, model_name)
39+
tg_compile(tg_flags, model_name)
5740

5841
# Compile BIG model if USB GPU is available
5942
if "USBGPU" in os.environ:

0 commit comments

Comments
 (0)