17 lines
654 B
C#
17 lines
654 B
C#
using System.Runtime.InteropServices;
|
||
|
||
namespace SopHelper.Engine.Inference;
|
||
|
||
internal static class CudaRuntime
|
||
{
|
||
// ORT 的 provider 位于 runtimes/win-x64/native,而随应用提供的 cuDNN 位于输出根目录。
|
||
// 显式加载其绝对路径,避免依赖当前工作目录或系统 PATH,句柄保留到进程结束。
|
||
private static readonly Lazy<nint> BundledCudnn = new(() =>
|
||
{
|
||
var path = Path.Combine(AppContext.BaseDirectory, "cudnn64_9.dll");
|
||
return OperatingSystem.IsWindows() && File.Exists(path) ? NativeLibrary.Load(path) : 0;
|
||
});
|
||
|
||
internal static void Prepare() => _ = BundledCudnn.Value;
|
||
}
|