diff --git a/src/SopHelper.CrossPlatform.Engine/Inference/CudaRuntime.cs b/src/SopHelper.CrossPlatform.Engine/Inference/CudaRuntime.cs index 6b0b231..c6ad1c7 100644 --- a/src/SopHelper.CrossPlatform.Engine/Inference/CudaRuntime.cs +++ b/src/SopHelper.CrossPlatform.Engine/Inference/CudaRuntime.cs @@ -10,7 +10,13 @@ internal static class CudaRuntime { if (!OperatingSystem.IsWindows()) return []; var handles = new List(); - 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)); } diff --git a/tools/Install-GpuRuntime.ps1 b/tools/Install-GpuRuntime.ps1 index 74f2412..27c790a 100644 --- a/tools/Install-GpuRuntime.ps1 +++ b/tools/Install-GpuRuntime.ps1 @@ -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.'