forked from third-party-mirrors/ollama
Compare commits
1 Commits
main
...
jmorganca/
Author | SHA1 | Date | |
---|---|---|---|
|
6023044af3 |
@ -7,8 +7,6 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/jmorganca/ollama/version"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func AssetsDir() (string, error) {
|
func AssetsDir() (string, error) {
|
||||||
@ -16,25 +14,8 @@ func AssetsDir() (string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
baseDir := filepath.Join(home, ".ollama", "assets")
|
|
||||||
libDirs, err := os.ReadDir(baseDir)
|
return filepath.Join(home, ".ollama", "assets"), nil
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdatePath(dir string) {
|
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 := fmt.Errorf("unable to locate suitable llm library")
|
||||||
_, 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")
|
|
||||||
for _, dynLib := range dynLibs {
|
for _, dynLib := range dynLibs {
|
||||||
srv, err := newDynExtServer(dynLib, model, adapters, projectors, opts)
|
srv, err := newDynExtServer(dynLib, model, adapters, projectors, opts)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return srv, nil
|
return srv, nil
|
||||||
}
|
}
|
||||||
slog.Warn(fmt.Sprintf("Failed to load dynamic library %s %s", dynLib, err))
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// delete the assetsDir
|
||||||
|
if err := os.RemoveAll(assetsDir); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" {
|
||||||
err := extractPayloadFiles(assetsDir, "llama.cpp/ggml-metal.metal")
|
err := extractPayloadFiles(assetsDir, "llama.cpp/ggml-metal.metal")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user