Skip to content

Commit

Permalink
fix: check n_gpu_layers > 0 before check ggml-metal supported
Browse files Browse the repository at this point in the history
  • Loading branch information
jhen0409 committed Aug 10, 2023
1 parent 527c4cf commit 9a634af
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ios/RNLlamaContext.mm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ + (instancetype)initWithParams:(NSDictionary *)params {
BOOL isMetalEnabled = false;
NSString *reasonNoMetal = @"";
defaultParams.n_gpu_layers = 0;
if (params[@"n_gpu_layers"]) {
if (params[@"n_gpu_layers"] && [params[@"n_gpu_layers"] intValue] > 0) {
// Check ggml-metal availability
NSError * error = nil;
id<MTLDevice> device = MTLCreateSystemDefaultDevice();
Expand Down

1 comment on commit 9a634af

@FreakTheMighty
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jhen0409 is there a reason n_gpu_layers doesn't support -1 to use GPU for all layers?

https://github.com/ggerganov/llama.cpp/blob/30e70334f71b3bd115024affcf98cac3d79aaa95/common/common.h#L68

Please sign in to comment.