Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Failed to load ./runtimes/win-x64/native/cuda12/llama.dll #1014

Open
vadsavin opened this issue Dec 7, 2024 · 5 comments
Open

[BUG]: Failed to load ./runtimes/win-x64/native/cuda12/llama.dll #1014

vadsavin opened this issue Dec 7, 2024 · 5 comments

Comments

@vadsavin
Copy link

vadsavin commented Dec 7, 2024

Description

Installed CUDA12 toolkit:
C:\Users\Home>nvcc --version

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Wed_Oct_30_01:18:48_Pacific_Daylight_Time_2024
Cuda compilation tools, release 12.6, V12.6.85
Build cuda_12.6.r12.6/compiler.35059454_0

Installed packeges:

  • LLamaSharp.Backend
  • LLamaSharp.Backend.Cuda12
  • LLamaSharp.Backend.Cuda12.Windows

Run:
using LLama.Native;
NativeLibraryConfig.All
.WithCuda()
.SkipCheck(true)
.WithAutoFallback(false)
.WithLogCallback((level, message) => Console.Write($"{level}: {message}"));
NativeApi.llama_empty_call();

Outputs:

Debug: Loading library: 'llama'
Info: Detected OS Platform: 'WINDOWS'
Debug: Detected OS string: 'win-x64'
Debug: Detected extension string: '.dll'
Debug: Detected prefix string: ''
Info: NativeLibraryConfig Description:
- LibraryName: LLama
- Path: ''
- PreferCuda: True
- PreferVulkan: True
- PreferredAvxLevel: NoAVX
- AllowFallback: False
- SkipCheck: True
- SearchDirectories and Priorities: { ./ }
Info: NativeLibraryConfig Description:
- LibraryName: LLama
- Path: ''
- PreferCuda: True
- PreferVulkan: True
- PreferredAvxLevel: NoAVX
- AllowFallback: False
- SkipCheck: True
- SearchDirectories and Priorities: { ./ }
Debug: Got relative library path 'runtimes/win-x64/native/cuda12/llama.dll' from local with (NativeLibraryName: LLama, UseCuda: True, UseVulkan: False, AvxLevel: None), trying to load it...
Debug: Found full path file './runtimes/win-x64/native/cuda12/llama.dll' for relative path 'runtimes/win-x64/native/cuda12/llama.dll'
Info: Failed Loading './runtimes/win-x64/native/cuda12/llama.dll'
Debug: Got relative library path 'runtimes/win-x64/native/vulkan/llama.dll' from local with (NativeLibraryName: LLama, UseCuda: False, UseVulkan: True, AvxLevel: None), trying to load it...
Debug: Found full path file 'runtimes/win-x64/native/vulkan/llama.dll' for relative path 'runtimes/win-x64/native/vulkan/llama.dll'
Info: Failed Loading 'runtimes/win-x64/native/vulkan/llama.dll'
Unhandled exception. System.TypeInitializationException: The type initializer for 'LLama.Native.NativeApi' threw an exception.
---> LLama.Exceptions.RuntimeError: Failed to load the native library. Please check the log for more information.
at LLama.Native.NativeLibraryUtils.TryLoadLibrary(NativeLibraryConfig config, INativeLibrary& loadedLibrary)
at LLama.Native.NativeApi.<>c.b__50_0(String name, Assembly _, Nullable`1 _)
at System.Runtime.InteropServices.NativeLibrary.LoadLibraryCallbackStub(String libraryName, Assembly assembly, Boolean hasDllImportSearchPathFlags, UInt32 dllImportSearchPathFlags)
at LLama.Native.NativeApi.llama_max_devices()
at LLama.Native.NativeApi.llama_empty_call()
at LLama.Native.NativeApi..cctor()
--- End of inner exception stack trace ---
at LLama.Native.NativeApi.llama_empty_call()

And it works fine (slow) when i use CPU backend. So what can I do to run model on GPU with CUDA?

Reproduction Steps

run example code

Environment & Configuration

  • Operating system: win10
  • .NET runtime version: net8
  • LLamaSharp version: 0.19.0
  • CUDA version (if you are using cuda backend): 12.6
  • CPU & GPU device: i7-960 x GTX970

Known Workarounds

No response

@martindevans
Copy link
Member

It's finding the CUDA binaries but failing to load them for some reason, probably a prerequisite is missing.

@vadsavin
Copy link
Author

vadsavin commented Dec 7, 2024

What kind of prerequisite should I check for?

@martindevans
Copy link
Member

Th CUDA toolkit is the most common one people are missing (https://developer.nvidia.com/cuda-toolkit)

@vadsavin
Copy link
Author

vadsavin commented Dec 8, 2024

First line of subject tells that CUDA Toolkit is installed, isn't it?

Also -- LLama.Exceptions.RuntimeError: Failed to load the native library. Please check the log for more information. : how can I retrieve logs?

@martindevans
Copy link
Member

First line of subject tells that CUDA Toolkit is installed, isn't it?

Oops, missed that! Unfortunately that makes it a lot trickier to debug, something like dependency walker might help (but it's hard to use).

how can I retrieve logs?

That log message is coming from here, it's referring to the logs you're already looking at.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants