Skip to content

Issue loading Metal kernels from shared library #1769

Closed
@abetlen

Description

@abetlen

Just looking for some help on this issue integrating the new Metal support as I'm not really familiar with MacOS.

The issue, orignally reported here, seems to be that path resolution for the ggml-metal.metal file fails when llama.cpp is built as a shared library. This produces the following output

llama_model_load_internal: mem required  = 2532.67 MB (+ 3124.00 MB per state)
....................................................................................................
llama_init_from_file: kv self size  = 3120.00 MB
ggml_metal_init: allocating
ggml_metal_init: using MPS
ggml_metal_init: loading '(null)'
ggml_metal_init: error: Error Domain=NSCocoaErrorDomain Code=258 "The file name is invalid."

It seems the issue stems from ggml_metal_init calling [[NSBundle mainBundle] pathForResource:@"ggml-metal" ofType:@"metal"] to locate the ggml-metal.metal file.

I've tried copying the file to a location relative to the shared library but that doesn't seem to work. It seems that pathForResource expects the file location relative to the absolute path of the executable loading the shared libray (in this case system python).

If anyone here has any thoughts please let me know, much appreciated.

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