From 00ec269321142681d2ff7e0e04180c35c4a47a6f Mon Sep 17 00:00:00 2001 From: Daniel Hiltgen Date: Sun, 10 Mar 2024 12:13:46 -0700 Subject: [PATCH] Add ollama executable peer dir for rocm This allows people who package up ollama on their own to place the rocm dependencies in a peer directory to the ollama executable much like our windows install flow. --- gpu/amd_linux.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/gpu/amd_linux.go b/gpu/amd_linux.go index 25f9128f..4d95f314 100644 --- a/gpu/amd_linux.go +++ b/gpu/amd_linux.go @@ -287,6 +287,21 @@ func AMDValidateLibDir() (string, error) { return rocmTargetDir, nil } + // next to the running binary + exe, err := os.Executable() + if err == nil { + peerDir := filepath.Dir(exe) + if rocmLibUsable(peerDir) { + slog.Debug("detected ROCM next to ollama executable " + peerDir) + return rocmTargetDir, setupLink(peerDir, rocmTargetDir) + } + peerDir = filepath.Join(filepath.Dir(exe), "rocm") + if rocmLibUsable(peerDir) { + slog.Debug("detected ROCM next to ollama executable " + peerDir) + return rocmTargetDir, setupLink(peerDir, rocmTargetDir) + } + } + // Well known ollama installer path installedRocmDir := "/usr/share/ollama/lib/rocm" if rocmLibUsable(installedRocmDir) {