Browse Source

Add path to find llama.dll for MAUI

This commit is originally made by lcarrere in https://github.com/SciSharp/LLamaSharp/issues/180 .

I have confirmed this modification is OK in my windows 11 laptop, add make this commit according require of AsakusaRinne.
tags/0.11.0
evolcano 1 year ago
parent
commit
9d091c0316
2 changed files with 12 additions and 0 deletions
  1. +9
    -0
      LLama/Native/NativeApi.Load.cs
  2. +3
    -0
      LLama/Native/NativeApi.cs

+ 9
- 0
LLama/Native/NativeApi.Load.cs View File

@@ -74,6 +74,15 @@ namespace LLama.Native
{
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))


+ 3
- 0
LLama/Native/NativeApi.cs View File

@@ -26,6 +26,9 @@ namespace LLama.Native
llama_max_devices();
}

[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
private static extern int AddDllDirectory(string NewDirectory);

/// <summary>
/// Get the maximum number of devices supported by llama.cpp
/// </summary>


Loading…
Cancel
Save