diff --git a/ggml/src/ggml-backend-reg.cpp b/ggml/src/ggml-backend-reg.cpp index 6379479aa..a7d504a3b 100644 --- a/ggml/src/ggml-backend-reg.cpp +++ b/ggml/src/ggml-backend-reg.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #ifdef _WIN32 # define WIN32_LEAN_AND_MEAN @@ -418,6 +419,11 @@ static fs::path get_executable_path() { base_path = base_path.substr(0, last_slash); } return base_path + "/"; +#elif defined(__gnu_linux__) + std::string executable_path(reinterpret_cast(getauxval(AT_EXECFN))); + fs::path bindir = fs::path(executable_path.data()).parent_path(); + fs::path libdir = bindir.parent_path() / "lib" / "llama"; + return fs::is_directory(libdir) ? libdir : bindir; #elif defined(__linux__) || defined(__FreeBSD__) std::string base_path = "."; std::vector path(1024);