Skip to content

Commit 1bbf1f9

Browse files
akxggerganov
authored andcommitted
metal : try cwd for ggml-metal.metal if bundle lookup fails (ggml-org#3793)
* Try cwd for ggml-metal if bundle lookup fails When building with `-DBUILD_SHARED_LIBS=ON -DLLAMA_METAL=ON -DLLAMA_BUILD_SERVER=ON`, `server` would fail to load `ggml-metal.metal` because `[bundle pathForResource:...]` returns `nil`. In that case, fall back to `ggml-metal.metal` in the cwd instead of passing `null` as a path. Follows up on ggml-org#1782 * Update ggml-metal.m --------- Co-authored-by: Georgi Gerganov <[email protected]>
1 parent 0a5a5e5 commit 1bbf1f9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Diff for: ggml-metal.m

+4
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,10 @@ static void ggml_metal_log(enum ggml_log_level level, const char* format, ...){
210210
GGML_METAL_LOG_INFO("%s: default.metallib not found, loading from source\n", __func__);
211211

212212
NSString * sourcePath = [bundle pathForResource:@"ggml-metal" ofType:@"metal"];
213+
if (sourcePath == nil) {
214+
GGML_METAL_LOG_WARN("%s: error: could not use bundle path to find ggml-metal.metal, falling back to trying cwd\n", __func__);
215+
sourcePath = @"ggml-metal.metal";
216+
}
213217
GGML_METAL_LOG_INFO("%s: loading '%s'\n", __func__, [sourcePath UTF8String]);
214218
NSString * src = [NSString stringWithContentsOfFile:sourcePath encoding:NSUTF8StringEncoding error:&error];
215219
if (error) {

0 commit comments

Comments
 (0)