Skip to content

Commit 9d091c0

Browse files
committed
Add path to find llama.dll for MAUI
This commit is originally made by lcarrere in #180 . I have confirmed this modification is OK in my windows 11 laptop, add make this commit according require of AsakusaRinne.
1 parent 6ddd45b commit 9d091c0

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
@@ -74,6 +74,15 @@ private static int GetCudaMajorVersion()
7474
{
7575
return -1;
7676
}
77+
78+
//Ensuring cuda bin path is reachable. Especially for MAUI environment.
79+
string cudaBinPath = Path.Combine(cudaPath, "bin");
80+
81+
if (Directory.Exists(cudaBinPath))
82+
{
83+
AddDllDirectory(cudaBinPath);
84+
}
85+
7786
version = GetCudaVersionFromPath(cudaPath);
7887
}
7988
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)