Browse Source

Merge pull request #631 from evolcano/master

Add path to find llama.dll for MAUI
tags/0.11.0
Rinne GitHub 1 year ago
parent
commit
f1cb0e3b35
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
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

@@ -135,6 +135,15 @@ namespace LLama.Native
{ {
return -1; 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); version = GetCudaVersionFromPath(cudaPath);
} }
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))


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

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


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

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


Loading…
Cancel
Save