mirror of
				https://github.com/ggml-org/llama.cpp.git
				synced 2025-10-30 08:42:00 +00:00 
			
		
		
		
	metal : return null instead of exit(1) (#2573)
This commit is contained in:
		| @@ -126,7 +126,7 @@ struct ggml_metal_context * ggml_metal_init(int n_cb) { | |||||||
|         ctx->library = [ctx->device newLibraryWithSource:msl_library_source options:nil error:&error]; |         ctx->library = [ctx->device newLibraryWithSource:msl_library_source options:nil error:&error]; | ||||||
|         if (error) { |         if (error) { | ||||||
|             fprintf(stderr, "%s: error: %s\n", __func__, [[error description] UTF8String]); |             fprintf(stderr, "%s: error: %s\n", __func__, [[error description] UTF8String]); | ||||||
|             exit(1); |             return NULL; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| #else | #else | ||||||
| @@ -144,7 +144,7 @@ struct ggml_metal_context * ggml_metal_init(int n_cb) { | |||||||
|         NSString * src  = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error]; |         NSString * src  = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error]; | ||||||
|         if (error) { |         if (error) { | ||||||
|             fprintf(stderr, "%s: error: %s\n", __func__, [[error description] UTF8String]); |             fprintf(stderr, "%s: error: %s\n", __func__, [[error description] UTF8String]); | ||||||
|             exit(1); |             return NULL; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| #ifdef GGML_QKK_64 | #ifdef GGML_QKK_64 | ||||||
| @@ -156,7 +156,7 @@ struct ggml_metal_context * ggml_metal_init(int n_cb) { | |||||||
| #endif | #endif | ||||||
|         if (error) { |         if (error) { | ||||||
|             fprintf(stderr, "%s: error: %s\n", __func__, [[error description] UTF8String]); |             fprintf(stderr, "%s: error: %s\n", __func__, [[error description] UTF8String]); | ||||||
|             exit(1); |             return NULL; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| #endif | #endif | ||||||
|   | |||||||
| @@ -3337,6 +3337,12 @@ struct llama_context * llama_new_context_with_model( | |||||||
|         // this allocates all Metal resources and memory buffers |         // this allocates all Metal resources and memory buffers | ||||||
|         ctx->ctx_metal = ggml_metal_init(1); |         ctx->ctx_metal = ggml_metal_init(1); | ||||||
|  |  | ||||||
|  |         if (!ctx->ctx_metal) { | ||||||
|  |             LLAMA_LOG_ERROR("%s: ggml_metal_init() failed\n", __func__); | ||||||
|  |             llama_free(ctx); | ||||||
|  |             return NULL; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         void * data_ptr  = NULL; |         void * data_ptr  = NULL; | ||||||
|         size_t data_size = 0; |         size_t data_size = 0; | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jhen-Jie Hong
					Jhen-Jie Hong