Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
fix for cuda version from env variable when working with nvidia/cuda …
…containers -- white space cleaup
  • Loading branch information
Crelex committed Jul 19, 2025
commit e59bf81dd27138d3de1ad20ac6ebbfaa2102787c
18 changes: 0 additions & 18 deletions LLama/Native/Load/SystemInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,18 @@ public static SystemInfo Get()
{
// Get Vulkan Summary
string? vulkanSummary = GetVulkanSummary();

// If we have a Vulkan summary
if (vulkanSummary != null)
{
// Extract Vulkan version from summary
string? vulkanVersion = ExtractVulkanVersionFromSummary(vulkanSummary);

// If we have a Vulkan version
if (vulkanVersion != null)
{
// Return the Vulkan version
return vulkanVersion;
}
}

// Return null if we failed to get the Vulkan version
return null;
}
Expand All @@ -83,7 +80,6 @@ public static SystemInfo Get()
}
};
var (exitCode, output, error, ok) = process.SafeRun(TimeSpan.FromSeconds(12));

// If ok return the output else return null
return ok ? output :
null;
Expand All @@ -99,32 +95,25 @@ public static SystemInfo Get()
// We have three ways of parsing the Vulkan version from the summary (output is a different between Windows and Linux)
// For now, I have decided to go with the full version number, and leave it up to the user to parse it further if needed
// I have left the other patterns in, in case we need them in the future

// Output on linux : 4206847 (1.3.255)
// Output on windows : 1.3.255
string pattern = @"apiVersion\s*=\s*([^\r\n]+)";

// Output on linux : 4206847
// Output on windows : 1.3.255
//string pattern = @"apiVersion\s*=\s*([\d\.]+)";

// Output on linux : 1.3.255
// Output on windows : 1.3.255
//string pattern = @"apiVersion\s*=\s*(?:\d+\s*)?(?:\(\s*)?([\d]+\.[\d]+\.[\d]+)(?:\s*\))?";

// Create a Regex object to match the pattern
Regex regex = new Regex(pattern);

// Match the pattern in the input string
Match match = regex.Match(vulkanSummary);

// If a match is found
if (match.Success)
{
// Return the version number
return match.Groups[1].Value;
}

// Return null if no match is found
return null;
}
Expand All @@ -142,15 +131,12 @@ private static int GetCudaMajorVersion()
{
return -1;
}

//Ensuring cuda bin path is reachable. Especially for MAUI environment.
string cudaBinPath = Path.Combine(cudaPath, "bin");

if (Directory.Exists(cudaBinPath))
{
AddDllDirectory(cudaBinPath);
}

version = GetCudaVersionFromPath(cudaPath);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
Expand All @@ -160,14 +146,12 @@ private static int GetCudaMajorVersion()
{
return ExtractMajorVersion(ref env_version);
}

// List of default cuda paths
string[] defaultCudaPaths =
[
"/usr/local/bin/cuda",
"/usr/local/cuda",
];

// Loop through every default path to find the version
foreach (var path in defaultCudaPaths)
{
Expand All @@ -178,7 +162,6 @@ private static int GetCudaMajorVersion()
if (!string.IsNullOrEmpty(version))
break;
}

if (string.IsNullOrEmpty(version))
{
cudaPath = Environment.GetEnvironmentVariable("LD_LIBRARY_PATH");
Expand Down Expand Up @@ -233,7 +216,6 @@ private static string GetCudaVersionFromPath(string cudaPath)
// Put it here to avoid calling NativeApi when getting the cuda version.
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern int AddDllDirectory(string NewDirectory);

private const string cudaVersionFile = "version.json";
#endregion
}
Expand Down