From c5ddef10cd92b277e14d72c355268cd368ec2540 Mon Sep 17 00:00:00 2001 From: m0nsky Date: Fri, 12 Jul 2024 10:57:58 +0200 Subject: [PATCH 1/3] Improve CUDA detection on WSL --- LLama/Native/Load/SystemInfo.cs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/LLama/Native/Load/SystemInfo.cs b/LLama/Native/Load/SystemInfo.cs index 0ffc67e91..f370cffa4 100644 --- a/LLama/Native/Load/SystemInfo.cs +++ b/LLama/Native/Load/SystemInfo.cs @@ -65,9 +65,26 @@ private static int GetCudaMajorVersion() } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { - // Try the default first - cudaPath = "/usr/local/bin/cuda"; - version = GetCudaVersionFromPath(cudaPath); + // List of default cuda paths + string[] defaultCudaPaths = + { + "/usr/local/bin/cuda", + "/usr/local/cuda/bin", + // "/usr/local/cuda-11/bin", + // "/usr/local/cuda-12/bin", + }; + + // Loop through every default path to find the version + foreach (var path in defaultCudaPaths) + { + // Attempt to get the version from the path + version = GetCudaVersionFromPath(path); + + // If a CUDA version is found, break the loop + if (!string.IsNullOrEmpty(version)) + break; + } + if (string.IsNullOrEmpty(version)) { cudaPath = Environment.GetEnvironmentVariable("LD_LIBRARY_PATH"); From af994cbcf6c8abb4f4b715290fc8c8983f4e87c1 Mon Sep 17 00:00:00 2001 From: m0nsky Date: Fri, 12 Jul 2024 11:03:27 +0200 Subject: [PATCH 2/3] GetCudaVersionFromPath parses version.json, so we need to go up one directory. --- LLama/Native/Load/SystemInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LLama/Native/Load/SystemInfo.cs b/LLama/Native/Load/SystemInfo.cs index f370cffa4..4e97d3d7f 100644 --- a/LLama/Native/Load/SystemInfo.cs +++ b/LLama/Native/Load/SystemInfo.cs @@ -69,7 +69,7 @@ private static int GetCudaMajorVersion() string[] defaultCudaPaths = { "/usr/local/bin/cuda", - "/usr/local/cuda/bin", + "/usr/local/cuda", // "/usr/local/cuda-11/bin", // "/usr/local/cuda-12/bin", }; From fd94c51ee842d6fc6a1457cfe1a74f37f5aa2dad Mon Sep 17 00:00:00 2001 From: m0nsky Date: Fri, 12 Jul 2024 11:09:03 +0200 Subject: [PATCH 3/3] Clean up --- LLama/Native/Load/SystemInfo.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/LLama/Native/Load/SystemInfo.cs b/LLama/Native/Load/SystemInfo.cs index 4e97d3d7f..7a075064e 100644 --- a/LLama/Native/Load/SystemInfo.cs +++ b/LLama/Native/Load/SystemInfo.cs @@ -70,8 +70,6 @@ private static int GetCudaMajorVersion() { "/usr/local/bin/cuda", "/usr/local/cuda", - // "/usr/local/cuda-11/bin", - // "/usr/local/cuda-12/bin", }; // Loop through every default path to find the version