Narrow set of paths we load GGML from (#10485)
Users may have other incompatible GGML installs on their systems. This will prevent us from trying to load them from the path.
This commit is contained in:
parent
421b7edeb4
commit
718eda1b3e
@ -329,11 +329,13 @@ func NewLlamaServer(gpus discover.GpuInfoList, modelPath string, f *ggml.GGML, a
|
|||||||
libraryPaths = append(libraryPaths, filepath.SplitList(libraryPath)...)
|
libraryPaths = append(libraryPaths, filepath.SplitList(libraryPath)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ggmlPaths := []string{discover.LibOllamaPath}
|
||||||
if len(compatible) > 0 {
|
if len(compatible) > 0 {
|
||||||
c := compatible[0]
|
c := compatible[0]
|
||||||
if libpath, ok := libs[c]; ok {
|
if libpath, ok := libs[c]; ok {
|
||||||
slog.Debug("adding gpu library", "path", libpath)
|
slog.Debug("adding gpu library", "path", libpath)
|
||||||
libraryPaths = append(libraryPaths, libpath)
|
libraryPaths = append(libraryPaths, libpath)
|
||||||
|
ggmlPaths = append(ggmlPaths, libpath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,6 +371,8 @@ func NewLlamaServer(gpus discover.GpuInfoList, modelPath string, f *ggml.GGML, a
|
|||||||
s.cmd.Stderr = s.status
|
s.cmd.Stderr = s.status
|
||||||
s.cmd.SysProcAttr = LlamaServerSysProcAttr
|
s.cmd.SysProcAttr = LlamaServerSysProcAttr
|
||||||
|
|
||||||
|
s.cmd.Env = append(s.cmd.Env, "OLLAMA_LIBRARY_PATH="+strings.Join(ggmlPaths, string(filepath.ListSeparator)))
|
||||||
|
|
||||||
envWorkarounds := [][2]string{}
|
envWorkarounds := [][2]string{}
|
||||||
for _, gpu := range gpus {
|
for _, gpu := range gpus {
|
||||||
envWorkarounds = append(envWorkarounds, gpu.EnvWorkarounds...)
|
envWorkarounds = append(envWorkarounds, gpu.EnvWorkarounds...)
|
||||||
@ -406,7 +410,8 @@ func NewLlamaServer(gpus discover.GpuInfoList, modelPath string, f *ggml.GGML, a
|
|||||||
if envconfig.Debug() {
|
if envconfig.Debug() {
|
||||||
filteredEnv := []string{}
|
filteredEnv := []string{}
|
||||||
for _, ev := range s.cmd.Env {
|
for _, ev := range s.cmd.Env {
|
||||||
if strings.HasPrefix(ev, "CUDA_") ||
|
if strings.HasPrefix(ev, "OLLAMA_") ||
|
||||||
|
strings.HasPrefix(ev, "CUDA_") ||
|
||||||
strings.HasPrefix(ev, "ROCR_") ||
|
strings.HasPrefix(ev, "ROCR_") ||
|
||||||
strings.HasPrefix(ev, "ROCM_") ||
|
strings.HasPrefix(ev, "ROCM_") ||
|
||||||
strings.HasPrefix(ev, "HIP_") ||
|
strings.HasPrefix(ev, "HIP_") ||
|
||||||
|
@ -57,26 +57,20 @@ var OnceLoad = sync.OnceFunc(func() {
|
|||||||
exe = "."
|
exe = "."
|
||||||
}
|
}
|
||||||
|
|
||||||
// PATH, LD_LIBRARY_PATH, and DYLD_LIBRARY_PATH are often
|
var value string
|
||||||
// set by the parent process, however, use a default value
|
|
||||||
// if the environment variable is not set.
|
|
||||||
var name, value string
|
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "darwin":
|
case "darwin":
|
||||||
// On macOS, DYLD_LIBRARY_PATH is often not set, so
|
|
||||||
// we use the directory of the executable as the default.
|
|
||||||
name = "DYLD_LIBRARY_PATH"
|
|
||||||
value = filepath.Dir(exe)
|
value = filepath.Dir(exe)
|
||||||
case "windows":
|
case "windows":
|
||||||
name = "PATH"
|
|
||||||
value = filepath.Join(filepath.Dir(exe), "lib", "ollama")
|
value = filepath.Join(filepath.Dir(exe), "lib", "ollama")
|
||||||
default:
|
default:
|
||||||
name = "LD_LIBRARY_PATH"
|
|
||||||
value = filepath.Join(filepath.Dir(exe), "..", "lib", "ollama")
|
value = filepath.Join(filepath.Dir(exe), "..", "lib", "ollama")
|
||||||
}
|
}
|
||||||
|
|
||||||
paths, ok := os.LookupEnv(name)
|
// Avoid potentially loading incompatible GGML libraries
|
||||||
|
paths, ok := os.LookupEnv("OLLAMA_LIBRARY_PATH")
|
||||||
if !ok {
|
if !ok {
|
||||||
|
slog.Debug("OLLAMA_LIBRARY_PATH not set, falling back to default", "search", value)
|
||||||
paths = value
|
paths = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user