replace assets on load
This commit is contained in:
parent
0e4669b04f
commit
6023044af3
@ -7,8 +7,6 @@ import (
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/jmorganca/ollama/version"
|
||||
)
|
||||
|
||||
func AssetsDir() (string, error) {
|
||||
@ -16,25 +14,8 @@ func AssetsDir() (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
baseDir := filepath.Join(home, ".ollama", "assets")
|
||||
libDirs, err := os.ReadDir(baseDir)
|
||||
if err == nil {
|
||||
for _, d := range libDirs {
|
||||
if d.Name() == version.Version {
|
||||
continue
|
||||
}
|
||||
// Special case the rocm dependencies, which are handled by the installer
|
||||
if d.Name() == "rocm" {
|
||||
continue
|
||||
}
|
||||
slog.Debug("stale lib detected, cleaning up " + d.Name())
|
||||
err = os.RemoveAll(filepath.Join(baseDir, d.Name()))
|
||||
if err != nil {
|
||||
slog.Warn(fmt.Sprintf("unable to clean up stale library %s: %s", filepath.Join(baseDir, d.Name()), err))
|
||||
}
|
||||
}
|
||||
}
|
||||
return filepath.Join(baseDir, version.Version), nil
|
||||
|
||||
return filepath.Join(home, ".ollama", "assets"), nil
|
||||
}
|
||||
|
||||
func UpdatePath(dir string) {
|
||||
|
16
llm/llm.go
16
llm/llm.go
@ -143,25 +143,15 @@ func newLlmServer(gpuInfo gpu.GpuInfo, model string, adapters, projectors []stri
|
||||
}
|
||||
}
|
||||
|
||||
// We stage into a temp directory, and if we've been idle for a while, it may have been reaped
|
||||
_, err := os.Stat(dynLibs[0])
|
||||
if err != nil {
|
||||
slog.Info(fmt.Sprintf("%s has disappeared, reloading libraries", dynLibs[0]))
|
||||
err = nativeInit()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
err2 := fmt.Errorf("unable to locate suitable llm library")
|
||||
err := fmt.Errorf("unable to locate suitable llm library")
|
||||
for _, dynLib := range dynLibs {
|
||||
srv, err := newDynExtServer(dynLib, model, adapters, projectors, opts)
|
||||
if err == nil {
|
||||
return srv, nil
|
||||
}
|
||||
slog.Warn(fmt.Sprintf("Failed to load dynamic library %s %s", dynLib, err))
|
||||
err2 = err
|
||||
err = err
|
||||
}
|
||||
|
||||
return nil, err2
|
||||
return nil, err
|
||||
}
|
||||
|
@ -109,6 +109,12 @@ func nativeInit() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// delete the assetsDir
|
||||
if err := os.RemoveAll(assetsDir); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if runtime.GOOS == "darwin" {
|
||||
err := extractPayloadFiles(assetsDir, "llama.cpp/ggml-metal.metal")
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user