Open philippjbauer opened 1 year ago
I can run go-llama / llama.cpp from within the go-llama folder with Metal acceleration. I've tried copying the ggml-metal.metal
into different folders that would make sense to load it from but with no success.
I would expect it to be loaded from the CWD that I have LocalAI installed to as the Makefile indicates
Hi! I'm a bot running with LocalAI ( a crazy experiment of @mudler ) - please beware that I might hallucinate sometimes!
_but.... I can also be funny or helpful :smilecat: and I can provide generally speaking good tips or places where to look after in the documentation or in the code based on what you wrote in the issue.
Don't engage in conversation with me, I don't support (yet) replying!
It seems like the issue is related to the loading of the model file. The error message indicates that there might be a problem with the file name or path. Please double check the file name and path and ensure that it is correct. Additionally, please try restarting the application and running the code again to see if the issue persists. If the issue still occurs, please provide more information about the environment and setup used for debugging.
Sources:
hey @philippjbauer , I don't have an Apple HW, could you give a shot at #777?
This worked for me: just copy ggml-metal.metal
to wherever you copied the executable (or libllama.so
, I guess) to.
For example, if you cp ./main /tmp/main
, then you also have to cp ./ggml-metal.metal /tmp
, otherwise /tmp/main
won't run when MPS is enabled.
The problem is in ggml-meta.m
, where path
becomes null
when ggml-meta.metal
isn't in the same directory as the executable:
// read the source from "ggml-metal.metal" into a string and use newLibraryWithSource
{
// ...
NSBundle * bundle = [NSBundle bundleForClass:[GGMLMetalClass class]];
NSString * path = [bundle pathForResource:@"ggml-metal" ofType:@"metal"];
fprintf(stderr, "%s: loading '%s'\n", __func__, [path UTF8String]);
NSString * src = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error];
if (error) {
// this error got triggered
fprintf(stderr, "%s: error: %s\n", __func__, [[error description] UTF8String]);
exit(1);
}
after building the ggml-metal.m file should be already next to the binary - at least after #777 , and nothing should be actually be needed anymore - can you confirm ?
Yes, you are right, mudler!
By default, ggml-metal.metal
(not ggml-metal.m
, which gets compiled and linked into the executables) is already in the same directory as the executables, and nothing is required to run the models using MPS.
I posted that comment because I happened to move ./main
around and the exact same error came up, and I was able to resolve it by moving ggml-metal.metal
to the same directory (after the move).
Maybe philippjbauer ran into a different problem than mine, but the error message is the same as mine, and I searched through the entire code base, there's only one place for that message to happen.
LocalAI version:
LocalAI version v1.20.1-57-gd0e67cc (d0e67cce7550389b657d37bc5956ce4a9e925321)
(compiled with Metal flag)
Environment, CPU architecture, OS, and Version:
Local, Apple M1 Pro, macOS Ventura 13.4.1
Describe the bug
When trying to load a model with the
gpu_layers: 1
andf16: true
parameters set in the model yaml file, Metal initialization appears to fail. The models run without these parameters set and create an answer.To Reproduce
Build the project with Metal enabled. Add
gpu_layers
andf16
parameters to model yaml file according to comment in the documentation for how to integrate Metal support. Send question to LocalAI using the selected model.Expected behavior
Metal initialization succeeds and LocalAI generates response with Metal acceleration.
Logs
The
ggml_metal_init
output at the end only appears when the aforementioned parameters are set in the model's yaml file. Theggml_metal_init
output is not present when those parameters are not set.Additional Information
Tried with the following models: vicuna-7b-1.1.ggmlv3.q4_0.bin nous-hermes-13b.ggmlv3.q4_0.bin Wizard-Vicuna-13B-Uncensored.ggmlv3.q4_0.bin