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) {