From 8f58a40fb96dde3e4c9262d789cb5863d2e8f66d Mon Sep 17 00:00:00 2001 From: Martin Evans Date: Sat, 2 Sep 2023 14:21:06 +0100 Subject: [PATCH] Added Linux dependency loading --- LLama/Native/NativeApi.cs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/LLama/Native/NativeApi.cs b/LLama/Native/NativeApi.cs index f16462ac..bce92b1f 100644 --- a/LLama/Native/NativeApi.cs +++ b/LLama/Native/NativeApi.cs @@ -55,19 +55,27 @@ namespace LLama.Native if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { // All of the Windows libraries, in order of preference - return TryLoad("win/cu12.1.0/libllama.dll") - ?? TryLoad("win/cu11.7.1/libllama.dll") + return TryLoad("cu12.1.0/libllama.dll") + ?? TryLoad("cu11.7.1/libllama.dll") #if NET8_0_OR_GREATER - ?? TryLoad("win/avx512/libllama.dll", System.Runtime.Intrinsics.X86.Avx512.IsSupported) + ?? TryLoad("avx512/libllama.dll", System.Runtime.Intrinsics.X86.Avx512.IsSupported) #endif - ?? TryLoad("win/avx2/libllama.dll", System.Runtime.Intrinsics.X86.Avx2.IsSupported) - ?? TryLoad("win/avx/libllama.dll", System.Runtime.Intrinsics.X86.Avx.IsSupported) + ?? TryLoad("avx2/libllama.dll", System.Runtime.Intrinsics.X86.Avx2.IsSupported) + ?? TryLoad("avx/libllama.dll", System.Runtime.Intrinsics.X86.Avx.IsSupported) ?? IntPtr.Zero; } if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { - return IntPtr.Zero; + // All of the Linux libraries, in order of preference + return TryLoad("cu12.1.0/libllama.so") + ?? TryLoad("cu11.7.1/libllama.so") +#if NET8_0_OR_GREATER + ?? TryLoad("avx512/libllama.so", System.Runtime.Intrinsics.X86.Avx512.IsSupported) +#endif + ?? TryLoad("avx2/libllama.so", System.Runtime.Intrinsics.X86.Avx2.IsSupported) + ?? TryLoad("avx/libllama.so", System.Runtime.Intrinsics.X86.Avx.IsSupported) + ?? IntPtr.Zero; } if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))