Avoid rocm runner and dependency clash

Putting the rocm symlink next to the runners is risky.  This moves
the payloads into a subdir to avoid potential clashes.
This commit is contained in:
Daniel Hiltgen
2024-03-11 08:45:57 -07:00
parent 41b00b9856
commit bc13da2bfe
3 changed files with 10 additions and 6 deletions

View File

@@ -282,7 +282,7 @@ func AMDValidateLibDir() (string, error) {
}
// If we already have a rocm dependency wired, nothing more to do
rocmTargetDir := filepath.Join(payloadsDir, "rocm")
rocmTargetDir := filepath.Clean(filepath.Join(payloadsDir, "..", "rocm"))
if rocmLibUsable(rocmTargetDir) {
return rocmTargetDir, nil
}

View File

@@ -23,7 +23,9 @@ func PayloadsDir() (string, error) {
if err != nil {
return "", fmt.Errorf("failed to generate tmp dir: %w", err)
}
payloadsDir = tmpDir
// We create a distinct subdirectory for payloads within the tmpdir
// This will typically look like /tmp/ollama3208993108/runners on linux
payloadsDir = filepath.Join(tmpDir, "runners")
}
return payloadsDir, nil
}
@@ -32,10 +34,12 @@ func Cleanup() {
lock.Lock()
defer lock.Unlock()
if payloadsDir != "" {
slog.Debug("cleaning up", "dir", payloadsDir)
err := os.RemoveAll(payloadsDir)
// We want to fully clean up the tmpdir parent of the payloads dir
tmpDir := filepath.Clean(filepath.Join(payloadsDir, ".."))
slog.Debug("cleaning up", "dir", tmpDir)
err := os.RemoveAll(tmpDir)
if err != nil {
slog.Warn("failed to clean up", "dir", payloadsDir, "err", err)
slog.Warn("failed to clean up", "dir", tmpDir, "err", err)
}
}
}