Skip to content

Commit 8f58a40

Browse files
committed
Added Linux dependency loading
1 parent dd49574 commit 8f58a40

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

LLama/Native/NativeApi.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,27 @@ private static IntPtr TryLoadLibrary()
5555
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
5656
{
5757
// All of the Windows libraries, in order of preference
58-
return TryLoad("win/cu12.1.0/libllama.dll")
59-
?? TryLoad("win/cu11.7.1/libllama.dll")
58+
return TryLoad("cu12.1.0/libllama.dll")
59+
?? TryLoad("cu11.7.1/libllama.dll")
6060
#if NET8_0_OR_GREATER
61-
?? TryLoad("win/avx512/libllama.dll", System.Runtime.Intrinsics.X86.Avx512.IsSupported)
61+
?? TryLoad("avx512/libllama.dll", System.Runtime.Intrinsics.X86.Avx512.IsSupported)
6262
#endif
63-
?? TryLoad("win/avx2/libllama.dll", System.Runtime.Intrinsics.X86.Avx2.IsSupported)
64-
?? TryLoad("win/avx/libllama.dll", System.Runtime.Intrinsics.X86.Avx.IsSupported)
63+
?? TryLoad("avx2/libllama.dll", System.Runtime.Intrinsics.X86.Avx2.IsSupported)
64+
?? TryLoad("avx/libllama.dll", System.Runtime.Intrinsics.X86.Avx.IsSupported)
6565
?? IntPtr.Zero;
6666
}
6767

6868
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
6969
{
70-
return IntPtr.Zero;
70+
// All of the Linux libraries, in order of preference
71+
return TryLoad("cu12.1.0/libllama.so")
72+
?? TryLoad("cu11.7.1/libllama.so")
73+
#if NET8_0_OR_GREATER
74+
?? TryLoad("avx512/libllama.so", System.Runtime.Intrinsics.X86.Avx512.IsSupported)
75+
#endif
76+
?? TryLoad("avx2/libllama.so", System.Runtime.Intrinsics.X86.Avx2.IsSupported)
77+
?? TryLoad("avx/libllama.so", System.Runtime.Intrinsics.X86.Avx.IsSupported)
78+
?? IntPtr.Zero;
7179
}
7280

7381
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))

0 commit comments

Comments
 (0)