Skip to content

Commit 3d4266e

Browse files
committed
Add CUDA 13 support with version-based package matching
1 parent 02e8331 commit 3d4266e

File tree

4 files changed

+117
-8
lines changed

4 files changed

+117
-8
lines changed

data/ort_gpu.json

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,61 @@
55
"vendor": "nvidia",
66
"platform": "linux",
77
"arch": "x86_64",
8+
"cuda_min": "13.0",
9+
"cuda_max": "13.99",
10+
"ort_version": "1.24.4",
11+
"url": "https://github.com/microsoft/onnxruntime/releases/download/v1.24.4/onnxruntime-linux-x64-gpu_cuda13-1.24.4.tgz",
12+
"sha256": "fdc6eb18317b4eaeda8b3b86595e5da7e853f72bac67ccac9b04ffc20c9f7fe0",
13+
"format": "tgz",
14+
"lib_pattern": "libonnxruntime",
15+
"install_subdir": "onnxruntime-cuda",
16+
"size_mb": 200,
17+
"requirements": "CUDA 13.x, cuDNN 9.x"
18+
},
19+
{
20+
"vendor": "nvidia",
21+
"platform": "linux",
22+
"arch": "x86_64",
23+
"cuda_min": "12.0",
24+
"cuda_max": "12.99",
825
"ort_version": "1.24.4",
926
"url": "https://github.com/microsoft/onnxruntime/releases/download/v1.24.4/onnxruntime-linux-x64-gpu-1.24.4.tgz",
1027
"sha256": "c5f804ff5d239b436fa59e9f2fb288a39f7eb9552f6a636c8b71e792e91a8808",
1128
"format": "tgz",
1229
"lib_pattern": "libonnxruntime",
1330
"install_subdir": "onnxruntime-cuda",
1431
"size_mb": 200,
15-
"requirements": "NVIDIA driver 525+, CUDA 12.x, cuDNN 9.x"
32+
"requirements": "CUDA 12.x, cuDNN 9.x"
33+
},
34+
{
35+
"vendor": "nvidia",
36+
"platform": "windows",
37+
"arch": "x86_64",
38+
"cuda_min": "13.0",
39+
"cuda_max": "13.99",
40+
"ort_version": "1.24.4",
41+
"url": "https://github.com/microsoft/onnxruntime/releases/download/v1.24.4/onnxruntime-win-x64-gpu_cuda13-1.24.4.zip",
42+
"sha256": "971be8cf984950672934a3173669590a8ece10b44746883420da8066ba836707",
43+
"format": "zip",
44+
"lib_pattern": "onnxruntime",
45+
"install_subdir": "onnxruntime-cuda",
46+
"size_mb": 200,
47+
"requirements": "CUDA 13.x, cuDNN 9.x"
1648
},
1749
{
1850
"vendor": "nvidia",
1951
"platform": "windows",
2052
"arch": "x86_64",
53+
"cuda_min": "12.0",
54+
"cuda_max": "12.99",
2155
"ort_version": "1.24.4",
2256
"url": "https://github.com/microsoft/onnxruntime/releases/download/v1.24.4/onnxruntime-win-x64-gpu-1.24.4.zip",
2357
"sha256": "ef3337a0b8184eb8beec310f7c83bd50376b3eefc43aab84ac8e452f6987df0a",
2458
"format": "zip",
2559
"lib_pattern": "onnxruntime",
2660
"install_subdir": "onnxruntime-cuda",
2761
"size_mb": 200,
28-
"requirements": "NVIDIA driver 525+, CUDA 12.x, cuDNN 9.x"
62+
"requirements": "CUDA 12.x, cuDNN 9.x"
2963
},
3064
{
3165
"vendor": "amd",

src/ai/ort_install.c

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ typedef struct
5050
char *sha256; // expected SHA-256 hash (optional but recommended)
5151
char *rocm_min; // optional, AMD only
5252
char *rocm_max; // optional, AMD only
53+
char *cuda_min; // optional, NVIDIA only
54+
char *cuda_max; // optional, NVIDIA only
5355
gsize size_mb;
5456
char *requirements;
5557
} _ort_package_t;
@@ -61,6 +63,7 @@ static void _package_free(_ort_package_t *p)
6163
g_free(p->url); g_free(p->format); g_free(p->lib_pattern);
6264
g_free(p->install_subdir); g_free(p->sha256);
6365
g_free(p->rocm_min); g_free(p->rocm_max);
66+
g_free(p->cuda_min); g_free(p->cuda_max);
6467
g_free(p->requirements); g_free(p);
6568
}
6669

@@ -116,6 +119,10 @@ static GList *_load_manifest(void)
116119
pkg->rocm_min = g_strdup(json_object_get_string_member(p, "rocm_min"));
117120
if(json_object_has_member(p, "rocm_max"))
118121
pkg->rocm_max = g_strdup(json_object_get_string_member(p, "rocm_max"));
122+
if(json_object_has_member(p, "cuda_min"))
123+
pkg->cuda_min = g_strdup(json_object_get_string_member(p, "cuda_min"));
124+
if(json_object_has_member(p, "cuda_max"))
125+
pkg->cuda_max = g_strdup(json_object_get_string_member(p, "cuda_max"));
119126

120127
result = g_list_append(result, pkg);
121128
}
@@ -135,6 +142,17 @@ static gchar *_version_major_minor(const char *version)
135142
return mm;
136143
}
137144

145+
// numeric version compare: returns -1, 0, or 1
146+
static int _version_cmp(const char *a, const char *b)
147+
{
148+
int ax = 0, ay = 0, bx = 0, by = 0;
149+
if(a) sscanf(a, "%d.%d", &ax, &ay);
150+
if(b) sscanf(b, "%d.%d", &bx, &by);
151+
if(ax != bx) return ax < bx ? -1 : 1;
152+
if(ay != by) return ay < by ? -1 : 1;
153+
return 0;
154+
}
155+
138156
// Find the best matching package for vendor + current platform + ROCm version
139157
static _ort_package_t *_find_package(GList *packages, dt_ort_gpu_vendor_t vendor)
140158
{
@@ -154,23 +172,52 @@ static _ort_package_t *_find_package(GList *packages, dt_ort_gpu_vendor_t vendor
154172
g_free(rocm_ver);
155173
}
156174

175+
// detect CUDA toolkit version via nvcc
176+
gchar *cuda_mm = NULL;
177+
if(vendor == DT_ORT_GPU_NVIDIA)
178+
{
179+
gchar *nvcc_out = NULL;
180+
if(g_spawn_command_line_sync("nvcc --version", &nvcc_out,
181+
NULL, NULL, NULL)
182+
&& nvcc_out)
183+
{
184+
// parse "Cuda compilation tools, release X.Y, VX.Y.Z"
185+
gchar *v = g_strstr_len(nvcc_out, -1, ", V");
186+
if(v)
187+
{
188+
v += 3; // skip ", V"
189+
cuda_mm = _version_major_minor(v);
190+
}
191+
g_free(nvcc_out);
192+
}
193+
}
194+
157195
_ort_package_t *best = NULL;
158196
for(GList *l = packages; l; l = g_list_next(l))
159197
{
160198
_ort_package_t *pkg = l->data;
161199
if(g_strcmp0(pkg->vendor, vendor_str) != 0) continue;
162200
if(g_strcmp0(pkg->platform, platform) != 0) continue;
163201

164-
// AMD: match ROCm version range (string compare works for single-digit majors)
202+
// AMD: match ROCm version range
165203
if(rocm_mm && pkg->rocm_min)
166204
{
167-
if(g_strcmp0(rocm_mm, pkg->rocm_min) < 0) continue;
168-
if(pkg->rocm_max && g_strcmp0(rocm_mm, pkg->rocm_max) > 0) continue;
205+
if(_version_cmp(rocm_mm, pkg->rocm_min) < 0) continue;
206+
if(pkg->rocm_max && _version_cmp(rocm_mm, pkg->rocm_max) > 0) continue;
169207
}
208+
209+
// NVIDIA: match CUDA version range
210+
if(cuda_mm && pkg->cuda_min)
211+
{
212+
if(_version_cmp(cuda_mm, pkg->cuda_min) < 0) continue;
213+
if(pkg->cuda_max && _version_cmp(cuda_mm, pkg->cuda_max) > 0) continue;
214+
}
215+
170216
best = pkg;
171217
break;
172218
}
173219
g_free(rocm_mm);
220+
g_free(cuda_mm);
174221
return best;
175222
}
176223

tools/ai/install-ort-gpu.ps1

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,36 @@ if ($Vendor) {
116116
}
117117
}
118118

119+
# --- Detect CUDA version for NVIDIA package matching ---
120+
$CudaMM = ""
121+
if ($Selected.vendor -eq "nvidia") {
122+
$nvcc = Get-Command nvcc -ErrorAction SilentlyContinue
123+
if ($nvcc) {
124+
$nvccOut = nvcc --version 2>$null | Select-String 'V(\d+\.\d+)' |
125+
ForEach-Object { $_.Matches[0].Groups[1].Value }
126+
if ($nvccOut) { $CudaMM = $nvccOut }
127+
}
128+
}
129+
119130
# --- Find matching package in manifest ---
120131
$Package = $null
121132
foreach ($p in $ManifestData.packages) {
122133
if ($p.vendor -ne $Selected.vendor) { continue }
123134
if ($p.platform -ne $Platform) { continue }
124135
if ($p.arch -and $p.arch -ne $Arch) { continue }
136+
# NVIDIA: match CUDA version range
137+
if ($CudaMM -and $p.cuda_min) {
138+
if ([version]$CudaMM -lt [version]$p.cuda_min) { continue }
139+
if ($p.cuda_max -and [version]$CudaMM -gt [version]$p.cuda_max) { continue }
140+
}
125141
$Package = $p
126142
break
127143
}
128144

129145
if (-not $Package) {
130146
Write-Host ""
131147
Write-Host "Error: no matching package found for $($Selected.vendor)/$Platform/$Arch" -ForegroundColor Red
148+
if ($CudaMM) { Write-Host " CUDA version: $CudaMM" }
132149
exit 1
133150
}
134151

tools/ai/install-ort-gpu.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ GPU_LABEL_AMD=""
6565
DRIVER_VERSION_AMD=""
6666
GPU_LABEL_INTEL=""
6767
ROCM_MM=""
68+
CUDA_MM=""
6869

6970
if [ -n "$VENDOR_OVERRIDE" ]; then
7071
case "$VENDOR_OVERRIDE" in
@@ -75,11 +76,14 @@ if [ -n "$VENDOR_OVERRIDE" ]; then
7576
;;
7677
esac
7778
echo "Vendor override: $VENDOR_OVERRIDE (skipping GPU detection)"
78-
# still collect ROCm version for AMD package matching
79+
# still collect version info for package matching
7980
if [ "$VENDOR_OVERRIDE" = "amd" ] && [ -f "/opt/rocm/.info/version" ]; then
8081
ROCM_VERSION=$(cat /opt/rocm/.info/version | tr -d '[:space:]')
8182
ROCM_MM=$(echo "$ROCM_VERSION" | grep -oP '^\d+\.\d+')
8283
fi
84+
if [ "$VENDOR_OVERRIDE" = "nvidia" ] && command -v nvcc &>/dev/null; then
85+
CUDA_MM=$(nvcc --version 2>/dev/null | grep -oP 'V\K\d+\.\d+' || true)
86+
fi
8387
else
8488
# NVIDIA
8589
if command -v nvidia-smi &>/dev/null; then
@@ -88,6 +92,10 @@ else
8892
GPU_LABEL=$(echo "$NVIDIA_INFO" | cut -d, -f1 | xargs)
8993
DRIVER_VERSION=$(echo "$NVIDIA_INFO" | cut -d, -f2 | xargs)
9094
VENDOR="nvidia"
95+
# detect CUDA toolkit version
96+
if command -v nvcc &>/dev/null; then
97+
CUDA_MM=$(nvcc --version 2>/dev/null | grep -oP 'V\K\d+\.\d+' || true)
98+
fi
9199
fi
92100
fi
93101

@@ -168,15 +176,18 @@ if ! command -v jq &>/dev/null; then
168176
exit 1
169177
fi
170178

171-
PKG_JSON=$(jq -c --arg v "$SELECTED" --arg p "$PLATFORM" --arg a "$ARCH" --arg r "${ROCM_MM:-}" \
179+
PKG_JSON=$(jq -c --arg v "$SELECTED" --arg p "$PLATFORM" --arg a "$ARCH" \
180+
--arg r "${ROCM_MM:-}" --arg c "${CUDA_MM:-}" \
172181
'[.packages[] | select(.vendor==$v and .platform==$p and (.arch // "x86_64")==$a) |
173-
if ($r != "" and .rocm_min != null) then select(.rocm_min <= $r and (.rocm_max // "99") >= $r) else . end] | first' \
182+
if ($r != "" and .rocm_min != null) then select(.rocm_min <= $r and (.rocm_max // "99") >= $r) else . end |
183+
if ($c != "" and .cuda_min != null) then select(.cuda_min <= $c and (.cuda_max // "99") >= $c) else . end] | first' \
174184
"$MANIFEST" 2>/dev/null || true)
175185

176186
if [ -z "$PKG_JSON" ]; then
177187
echo ""
178188
echo "Error: no matching package found in manifest for $SELECTED/$PLATFORM/$ARCH"
179189
[ -n "${ROCM_MM:-}" ] && echo " ROCm version: $ROCM_MM"
190+
[ -n "${CUDA_MM:-}" ] && echo " CUDA version: $CUDA_MM"
180191
echo " Check ort_gpu.json for supported configurations."
181192
echo ""
182193
exit 1

0 commit comments

Comments
 (0)