-
Notifications
You must be signed in to change notification settings - Fork 43
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
Feature flag metal: Fails to load model when n_gpu_layers > 0 #18
Comments
Hmm weird i dont have a mac available currently to test this, i will try to see about this. Thanks |
i have the same problem on my Apple M1. |
@phudtran i have found root cause. you should put the build.rs fn compile_metal(cx: &mut Build, cxx: &mut Build) {
cx.flag("-DGGML_USE_METAL").flag("-DGGML_METAL_NDEBUG");
cxx.flag("-DGGML_USE_METAL");
println!("cargo:rustc-link-lib=framework=Metal");
println!("cargo:rustc-link-lib=framework=Foundation");
println!("cargo:rustc-link-lib=framework=MetalPerformanceShaders");
println!("cargo:rustc-link-lib=framework=MetalKit");
cx.include("./llama.cpp/ggml-metal.h")
.file("./llama.cpp/ggml-metal.m");
} disable fn compile_metal(cx: &mut Build, cxx: &mut Build) {
cx.flag("-DGGML_USE_METAL"); // <============== enable print debug log.
cxx.flag("-DGGML_USE_METAL");
println!("cargo:rustc-link-lib=framework=Metal");
println!("cargo:rustc-link-lib=framework=Foundation");
println!("cargo:rustc-link-lib=framework=MetalPerformanceShaders");
println!("cargo:rustc-link-lib=framework=MetalKit");
cx.include("./llama.cpp/ggml-metal.h")
.file("./llama.cpp/ggml-metal.m");
} @mdrokz Should add some flags to enable(disable) the debug log ? |
@zackshen I've tried adding the |
I have never seen this error before. just modified the example code in the this repo for testing gpu utilization. Can you show your code ? |
I will add an option for enabling / disabling debug |
Encountered the same error. Placing ggml-metal.metal into the project directory leads to the same error as @hugonijmek have seen. However, this solves the original issue: setting the following env variable to point to llama.cpp sources GGML_METAL_PATH_RESOURCES=/rust-llama.cpp/llama.cpp/ solves the issue. (https://github.com/ggerganov/whisper.cpp/blob/master/ggml-metal.m#L261) |
If you want to include it in the build so you don't have to worry about having the shader file parallel or using the environment variable, you can use the solution from the rustformers/llm respository: To get it working, update the needle to the current string. The file this puts in the output directory has a prefix to 'ggml-metal.o' so when checking the |
Can't utilize GPU on Mac with
Code
Error
The text was updated successfully, but these errors were encountered: