Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions src/TorchSharp/Torch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private static void LoadNativeBackend(bool useCudaBackend, out StringBuilder? tr
trace = null;

if (!alreadyLoaded) {
bool ok;
bool ok = true;
trace = new StringBuilder();
trace.AppendLine($"");
trace.AppendLine($"TorchSharp: LoadNativeBackend: Initialising native backend, useCudaBackend = {useCudaBackend}");
Expand All @@ -134,30 +134,30 @@ private static void LoadNativeBackend(bool useCudaBackend, out StringBuilder? tr
// Preloading these DLLs on windows seems to iron out problems where one native DLL
// requests a load of another through dynamic linking techniques.
//
ok = TryLoadNativeLibraryByName("cudnn_adv64_9", typeof(torch).Assembly, trace);
ok = TryLoadNativeLibraryByName("cudnn_cnn64_9", typeof(torch).Assembly, trace);
ok = TryLoadNativeLibraryByName("cudnn_ops64_9", typeof(torch).Assembly, trace);
ok = TryLoadNativeLibraryByName("cudnn_graph64_9.dll", typeof(torch).Assembly, trace);
ok = TryLoadNativeLibraryByName("cudnn_heuristic64_9.dll", typeof(torch).Assembly, trace);
ok = TryLoadNativeLibraryByName("cudnn_engines_precompiled64_9.dll", typeof(torch).Assembly, trace);
ok = TryLoadNativeLibraryByName("cudnn_engines_runtime_compiled64_9.dll", typeof(torch).Assembly, trace);
ok = TryLoadNativeLibraryByName("nvrtc-builtins64_128", typeof(torch).Assembly, trace);
ok = TryLoadNativeLibraryByName("caffe2_nvrtc", typeof(torch).Assembly, trace);
ok = TryLoadNativeLibraryByName("nvrtc64_120_0", typeof(torch).Assembly, trace);
ok = TryLoadNativeLibraryByName("cublasLt64_12", typeof(torch).Assembly, trace);
ok = TryLoadNativeLibraryByName("cufft64_11", typeof(torch).Assembly, trace);
ok = TryLoadNativeLibraryByName("cusparse64_12", typeof(torch).Assembly, trace);
ok = TryLoadNativeLibraryByName("cusolver64_11", typeof(torch).Assembly, trace);
ok &= TryLoadNativeLibraryByName("cudnn_adv64_9", typeof(torch).Assembly, trace);
ok &= TryLoadNativeLibraryByName("cudnn_cnn64_9", typeof(torch).Assembly, trace);
ok &= TryLoadNativeLibraryByName("cudnn_ops64_9", typeof(torch).Assembly, trace);
ok &= TryLoadNativeLibraryByName("cudnn_graph64_9.dll", typeof(torch).Assembly, trace);
ok &= TryLoadNativeLibraryByName("cudnn_heuristic64_9.dll", typeof(torch).Assembly, trace);
ok &= TryLoadNativeLibraryByName("cudnn_engines_precompiled64_9.dll", typeof(torch).Assembly, trace);
ok &= TryLoadNativeLibraryByName("cudnn_engines_runtime_compiled64_9.dll", typeof(torch).Assembly, trace);
ok &= TryLoadNativeLibraryByName("nvrtc-builtins64_128", typeof(torch).Assembly, trace);
ok &= TryLoadNativeLibraryByName("caffe2_nvrtc", typeof(torch).Assembly, trace);
ok &= TryLoadNativeLibraryByName("nvrtc64_120_0", typeof(torch).Assembly, trace);
ok &= TryLoadNativeLibraryByName("cublasLt64_12", typeof(torch).Assembly, trace);
ok &= TryLoadNativeLibraryByName("cufft64_11", typeof(torch).Assembly, trace);
ok &= TryLoadNativeLibraryByName("cusparse64_12", typeof(torch).Assembly, trace);
ok &= TryLoadNativeLibraryByName("cusolver64_11", typeof(torch).Assembly, trace);
}

ok = TryLoadNativeLibraryByName("torch_cuda", typeof(torch).Assembly, trace);
ok = TryLoadNativeLibraryByName("LibTorchSharp", typeof(torch).Assembly, trace);
ok &= TryLoadNativeLibraryByName("torch_cuda", typeof(torch).Assembly, trace);
ok &= TryLoadNativeLibraryByName("LibTorchSharp", typeof(torch).Assembly, trace);
} else {
ok = TryLoadNativeLibraryByName("torch_cpu", typeof(torch).Assembly, trace);
ok = TryLoadNativeLibraryByName("LibTorchSharp", typeof(torch).Assembly, trace);
ok &= TryLoadNativeLibraryByName("torch_cpu", typeof(torch).Assembly, trace);
ok &= TryLoadNativeLibraryByName("LibTorchSharp", typeof(torch).Assembly, trace);
}

trace.AppendLine($" Result from regular native load of LibTorchSharp is {ok}");
trace.AppendLine($" Result from regular native load of backend libraries (CUDA preloads + torch_* + LibTorchSharp) is {ok}");

// Try dynamic load from package directories
if (!ok) {
Expand Down