修复:统一 CUDA 13 的 cuDNN 与运行时编译依赖

This commit is contained in:
tfarcraw 2026-11-09 20:43:17 +08:00
parent 81b42a2d1b
commit ca0a5c72b2
2 changed files with 21 additions and 3 deletions

View File

@ -10,7 +10,13 @@ internal static class CudaRuntime
{
if (!OperatingSystem.IsWindows()) return [];
var handles = new List<nint>();
foreach (var name in new[] { "cublasLt64_13.dll", "cublas64_13.dll", "cudart64_13.dll", "cudnn64_9.dll" })
foreach (var name in new[]
{
"cublasLt64_13.dll", "cublas64_13.dll", "cudart64_13.dll",
"nvrtc-builtins64_130.dll", "nvrtc64_130_0.dll",
"cudnn_graph64_9.dll", "cudnn_ops64_9.dll", "cudnn_cnn64_9.dll", "cudnn_adv64_9.dll",
"cudnn_engines_precompiled64_9.dll", "cudnn_engines_runtime_compiled64_9.dll", "cudnn_heuristic64_9.dll", "cudnn64_9.dll",
})
{
var path = Path.Combine(AppContext.BaseDirectory, name);
try { handles.Add(NativeLibrary.Load(File.Exists(path) ? path : name)); }

View File

@ -54,11 +54,23 @@ if ($CudaRuntimeSource) {
Install-NvidiaArchive $name 'https://developer.download.nvidia.com/compute/cuda/redist/' $cuda.$name.'windows-x86_64'
}
}
if (!(Test-Path -LiteralPath (Join-Path $runtimeDirectory 'cudnn64_9.dll'))) {
$nvrtcDlls = @('nvrtc-builtins64_130.dll','nvrtc64_130_0.dll')
if (@($nvrtcDlls | Where-Object { !(Test-Path -LiteralPath (Join-Path $runtimeDirectory $_)) }).Count) {
$cuda = Invoke-RestMethod 'https://developer.download.nvidia.com/compute/cuda/redist/redistrib_13.0.2.json'
Install-NvidiaArchive 'cuda_nvrtc' 'https://developer.download.nvidia.com/compute/cuda/redist/' $cuda.cuda_nvrtc.'windows-x86_64'
}
$cudnnDlls = @('cudnn_graph64_9.dll','cudnn_ops64_9.dll','cudnn_cnn64_9.dll','cudnn_adv64_9.dll',
'cudnn_engines_precompiled64_9.dll','cudnn_engines_runtime_compiled64_9.dll','cudnn_heuristic64_9.dll','cudnn64_9.dll')
# CUDA 12 与 CUDA 13 的 cuDNN 文件名相同,必须记录已安装的发行包,不能只判断 DLL 是否存在。
$cudnnStamp = Join-Path $runtimeDirectory '.cudnn-cuda13-version'
if (!(Test-Path -LiteralPath $cudnnStamp) -or
(Get-Content -LiteralPath $cudnnStamp -Raw).Trim() -ne '9.13.0' -or
@($cudnnDlls | Where-Object { !(Test-Path -LiteralPath (Join-Path $runtimeDirectory $_)) }).Count) {
$cudnn = Invoke-RestMethod 'https://developer.download.nvidia.com/compute/cudnn/redist/redistrib_9.13.0.json'
Install-NvidiaArchive 'cudnn' 'https://developer.download.nvidia.com/compute/cudnn/redist/' $cudnn.cudnn.'windows-x86_64'.cuda13
Set-Content -LiteralPath $cudnnStamp -Value '9.13.0'
}
foreach ($name in $cudaDlls + 'cudnn64_9.dll') {
foreach ($name in $cudaDlls + $nvrtcDlls + $cudnnDlls) {
if (!(Test-Path -LiteralPath (Join-Path $runtimeDirectory $name))) { throw "GPU 运行库不完整:$name" }
}
Write-Host 'CUDA 13 / cuDNN 9 ready. Rebuild and restart the application to use GPU inference.'