From 79b88f8ddcc22b098cfefb7448ee189fe29b6c86 Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Tue, 23 Jan 2024 01:43:15 -0800 Subject: [PATCH] Sanitize -ngl flag on Apple Metal Passing `-ngl 35` (as shown by examples) to Apple Metal causes weird output. This should be `-ngl 1` since it enables full GPU offloading --- llamafile/gpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llamafile/gpu.c b/llamafile/gpu.c index 2a1bfb5e05..440a5b8e85 100644 --- a/llamafile/gpu.c +++ b/llamafile/gpu.c @@ -70,7 +70,7 @@ int llamafile_gpu_layers(int n_gpu_layers) { } // Apple Metal is safe enough to enable by default. - if (n_gpu_layers == -1 && ggml_metal_supported()) { + if ((n_gpu_layers < 0 || n_gpu_layers > 1) && ggml_metal_supported()) { n_gpu_layers = 1; }