Skip to content

Commit b57eb9c

Browse files
authored
ggml : add friendlier error message to fopen errors (#8575)
* Add additional error information when model files fail to load. * Adding additional error information to most instances of fopen.
1 parent f299aa9 commit b57eb9c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ggml/src/ggml.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19019,7 +19019,7 @@ void ggml_graph_export(const struct ggml_cgraph * cgraph, const char * fname) {
1901919019
FILE * fout = ggml_fopen(fname, "wb");
1902019020

1902119021
if (!fout) {
19022-
fprintf(stderr, "%s: failed to open %s\n", __func__, fname);
19022+
fprintf(stderr, "%s: failed to open %s: %s\n", __func__, fname, strerror(errno));
1902319023
return;
1902419024
}
1902519025

@@ -19156,7 +19156,7 @@ struct ggml_cgraph * ggml_graph_import(const char * fname, struct ggml_context *
1915619156
{
1915719157
FILE * fin = ggml_fopen(fname, "rb");
1915819158
if (!fin) {
19159-
fprintf(stderr, "%s: failed to open %s\n", __func__, fname);
19159+
fprintf(stderr, "%s: failed to open %s: %s\n", __func__, fname, strerror(errno));
1916019160
return result;
1916119161
}
1916219162

@@ -20830,6 +20830,7 @@ struct gguf_context * gguf_init_empty(void) {
2083020830
struct gguf_context * gguf_init_from_file(const char * fname, struct gguf_init_params params) {
2083120831
FILE * file = ggml_fopen(fname, "rb");
2083220832
if (!file) {
20833+
fprintf(stderr, "%s: failed to open '%s': '%s'\n", __func__, fname, strerror(errno));
2083320834
return NULL;
2083420835
}
2083520836

0 commit comments

Comments
 (0)