Skip to content

[BUG][SOLVED]: "Found full path file", but "Failed Loading" #1301

@shmightworks

Description

@shmightworks

Description

Running off Visual Studio works fine, but after I Publish the project, running off IIS it fails.
Especially with the fall back turned off, and if you ask it to load CUDA.
You can see in the log, that it finds the file, but fails to load it.

Reproduction Steps

Publish the project to run off IIS.
I haven't tested, but seeing a few other posts of "Failed Loading" with no solution, I don't think others are running it as a web service like I am, so maybe just compiling it to exe and running it will have similar issue?

Environment & Configuration

  • Operating system: Win 11
  • .NET runtime version: .NET 9
  • LLamaSharp version: 0.25
  • CUDA version (if you are using cuda backend): 12
  • CPU & GPU device: irrelevant

Known Workarounds

Looking at the log, running off VS, it shows full path, but from IIS, it shows relative path, like this:
[Debug] Got relative library path 'runtimes/win-x64/native/cuda12/llama.dll' from local with (NativeLibraryName: LLama, UseCuda: True, UseVulkan: False, AvxLevel: Avx2), trying to load it...
[Debug] Found full path file './runtimes\win-x64\native\cuda12\ggml-base.dll' for relative path 'runtimes\win-x64\native\cuda12\ggml-base.dll'
[Info] Failed Loading './runtimes\win-x64\native\cuda12\ggml-base.dll'

Figuring what if it has to do with the path, so in loading the library.
Maybe File.Exists knows how to deal with relative path, but loading the library doesn't?
To avoid this, I added this forcing the full path on the searchDirectories:
.WithSearchDirectory(AppContext.BaseDirectory)

With that the IIS now logs with full path just like when it runs off VS and it's successfully loaded.
Cheers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions