forked from commaai/controls_challenge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_gpu.sh
More file actions
72 lines (60 loc) · 2.06 KB
/
Copy pathsetup_gpu.sh
File metadata and controls
72 lines (60 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env bash
set -euo pipefail
ORT_NIGHTLY_INDEX="https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ort-cuda-13-nightly/pypi/simple/"
CUDA_LIB_DIR="${CUDA_LIB_DIR:-/usr/local/cuda-13.1/lib64}"
# 1. Generic deps first.
uv pip install -r requirements.txt
# 2. Nuke any existing ORT build so the GPU build is authoritative.
uv pip uninstall onnxruntime onnxruntime-gpu || true
# 3. GPU-specific: TensorRT libs + nightly onnxruntime-gpu (CUDA 13 + TRT provider).
uv pip install tensorrt-cu13
uv pip install --pre --extra-index-url "${ORT_NIGHTLY_INDEX}" onnxruntime-gpu
TRT_LIB_DIR="$(
python - <<'PY'
from pathlib import Path
import site
for base in site.getsitepackages():
p = Path(base) / "tensorrt_libs"
if p.exists():
print(p)
break
else:
raise SystemExit("tensorrt_libs not found in site-packages")
PY
)"
# 4. Persist CUDA/TRT env for future interactive shells via a managed ~/.bashrc block.
python - <<PY
from pathlib import Path
import re
bashrc = Path.home() / ".bashrc"
text = bashrc.read_text() if bashrc.exists() else ""
block = """# >>> controls_challenge trt >>>
export CUDA=1
export TRT=1
export CUDA_LIB_DIR="${CUDA_LIB_DIR}"
export TRT_LIB_DIR="${TRT_LIB_DIR}"
export LD_LIBRARY_PATH="${CUDA_LIB_DIR}:${TRT_LIB_DIR}:${LD_LIBRARY_PATH:-}"
# <<< controls_challenge trt <<<
"""
pattern = re.compile(r"\n?# >>> controls_challenge trt >>>.*?# <<< controls_challenge trt <<<\n?", re.S)
if pattern.search(text):
text = pattern.sub("\n" + block, text)
else:
if text and not text.endswith("\n"):
text += "\n"
text += block
bashrc.write_text(text)
PY
# Export into the current shell running this script too.
export CUDA=1
export TRT=1
export LD_LIBRARY_PATH="${CUDA_LIB_DIR}:${TRT_LIB_DIR}:${LD_LIBRARY_PATH:-}"
# 5. Verify.
python - <<'PY'
import onnxruntime as ort
provs = ort.get_available_providers()
print("Providers:", provs)
assert 'CUDAExecutionProvider' in provs, 'CUDA provider missing!'
assert 'TensorrtExecutionProvider' in provs, 'TensorRT provider missing!'
PY
echo "Done. CUDA + TensorRT providers available."