mirror of
				https://github.com/ggml-org/llama.cpp.git
				synced 2025-10-30 08:42:00 +00:00 
			
		
		
		
	metal : try cwd for ggml-metal.metal if bundle lookup fails (#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 #1782 * Update ggml-metal.m --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
This commit is contained in:
		| @@ -210,6 +210,10 @@ struct ggml_metal_context * ggml_metal_init(int n_cb) { | |||||||
|             GGML_METAL_LOG_INFO("%s: default.metallib not found, loading from source\n", __func__); |             GGML_METAL_LOG_INFO("%s: default.metallib not found, loading from source\n", __func__); | ||||||
|  |  | ||||||
|             NSString * sourcePath = [bundle pathForResource:@"ggml-metal" ofType:@"metal"]; |             NSString * sourcePath = [bundle pathForResource:@"ggml-metal" ofType:@"metal"]; | ||||||
|  |             if (sourcePath == nil) { | ||||||
|  |                 GGML_METAL_LOG_WARN("%s: error: could not use bundle path to find ggml-metal.metal, falling back to trying cwd\n", __func__); | ||||||
|  |                 sourcePath = @"ggml-metal.metal"; | ||||||
|  |             } | ||||||
|             GGML_METAL_LOG_INFO("%s: loading '%s'\n", __func__, [sourcePath UTF8String]); |             GGML_METAL_LOG_INFO("%s: loading '%s'\n", __func__, [sourcePath UTF8String]); | ||||||
|             NSString * src = [NSString stringWithContentsOfFile:sourcePath encoding:NSUTF8StringEncoding error:&error]; |             NSString * src = [NSString stringWithContentsOfFile:sourcePath encoding:NSUTF8StringEncoding error:&error]; | ||||||
|             if (error) { |             if (error) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Aarni Koskela
					Aarni Koskela