Skip to content

Commit f1cb0e3

Browse files
authored
Merge pull request #631 from evolcano/master
Add path to find llama.dll for MAUI
2 parents 156f369 + 3534129 commit f1cb0e3

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

LLama/Native/NativeApi.Load.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,15 @@ private static int GetCudaMajorVersion()
135135
{
136136
return -1;
137137
}
138+
139+
//Ensuring cuda bin path is reachable. Especially for MAUI environment.
140+
string cudaBinPath = Path.Combine(cudaPath, "bin");
141+
142+
if (Directory.Exists(cudaBinPath))
143+
{
144+
AddDllDirectory(cudaBinPath);
145+
}
146+
138147
version = GetCudaVersionFromPath(cudaPath);
139148
}
140149
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))

LLama/Native/NativeApi.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ public static void llama_empty_call()
2626
llama_max_devices();
2727
}
2828

29+
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
30+
private static extern int AddDllDirectory(string NewDirectory);
31+
2932
/// <summary>
3033
/// Get the maximum number of devices supported by llama.cpp
3134
/// </summary>

0 commit comments

Comments
 (0)