mirror of
https://github.com/ollama/ollama.git
synced 2025-11-10 21:17:32 +01:00
cpu: always ensure LibOllamaPath included (#12890)
In CPU only setups the LibOllamaPath was omitted causing us not to load the ggml-cpu-XXX libraries during inference.
This commit is contained in:
@@ -53,7 +53,7 @@ func GPUDevices(ctx context.Context, runners []ml.FilteredRunnerDiscovery) []ml.
|
|||||||
if eval, err := filepath.EvalSymlinks(exe); err == nil {
|
if eval, err := filepath.EvalSymlinks(exe); err == nil {
|
||||||
exe = eval
|
exe = eval
|
||||||
}
|
}
|
||||||
files, err := filepath.Glob(filepath.Join(LibOllamaPath, "*", "*ggml-*"))
|
files, err := filepath.Glob(filepath.Join(ml.LibOllamaPath, "*", "*ggml-*"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Debug("unable to lookup runner library directories", "error", err)
|
slog.Debug("unable to lookup runner library directories", "error", err)
|
||||||
}
|
}
|
||||||
@@ -64,7 +64,7 @@ func GPUDevices(ctx context.Context, runners []ml.FilteredRunnerDiscovery) []ml.
|
|||||||
// Our current packaging model places ggml-hip in the main directory
|
// Our current packaging model places ggml-hip in the main directory
|
||||||
// but keeps rocm in an isolated directory. We have to add it to
|
// but keeps rocm in an isolated directory. We have to add it to
|
||||||
// the [LD_LIBRARY_]PATH so ggml-hip will load properly
|
// the [LD_LIBRARY_]PATH so ggml-hip will load properly
|
||||||
rocmDir = filepath.Join(LibOllamaPath, "rocm")
|
rocmDir = filepath.Join(ml.LibOllamaPath, "rocm")
|
||||||
if _, err := os.Stat(rocmDir); err != nil {
|
if _, err := os.Stat(rocmDir); err != nil {
|
||||||
rocmDir = ""
|
rocmDir = ""
|
||||||
}
|
}
|
||||||
@@ -95,9 +95,9 @@ func GPUDevices(ctx context.Context, runners []ml.FilteredRunnerDiscovery) []ml.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if dir == "" {
|
if dir == "" {
|
||||||
dirs = []string{LibOllamaPath}
|
dirs = []string{ml.LibOllamaPath}
|
||||||
} else {
|
} else {
|
||||||
dirs = []string{LibOllamaPath, dir}
|
dirs = []string{ml.LibOllamaPath, dir}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ROCm can take a long time on some systems, so give it more time before giving up
|
// ROCm can take a long time on some systems, so give it more time before giving up
|
||||||
@@ -249,7 +249,7 @@ func GPUDevices(ctx context.Context, runners []ml.FilteredRunnerDiscovery) []ml.
|
|||||||
libDirs = make(map[string]struct{})
|
libDirs = make(map[string]struct{})
|
||||||
for _, dev := range devices {
|
for _, dev := range devices {
|
||||||
dir := dev.LibraryPath[len(dev.LibraryPath)-1]
|
dir := dev.LibraryPath[len(dev.LibraryPath)-1]
|
||||||
if dir != LibOllamaPath {
|
if dir != ml.LibOllamaPath {
|
||||||
libDirs[dir] = struct{}{}
|
libDirs[dir] = struct{}{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -339,7 +339,7 @@ func GPUDevices(ctx context.Context, runners []ml.FilteredRunnerDiscovery) []ml.
|
|||||||
devFilter := ml.GetVisibleDevicesEnv(devices)
|
devFilter := ml.GetVisibleDevicesEnv(devices)
|
||||||
|
|
||||||
for dir := range libDirs {
|
for dir := range libDirs {
|
||||||
updatedDevices := bootstrapDevices(ctx, []string{LibOllamaPath, dir}, devFilter)
|
updatedDevices := bootstrapDevices(ctx, []string{ml.LibOllamaPath, dir}, devFilter)
|
||||||
for _, u := range updatedDevices {
|
for _, u := range updatedDevices {
|
||||||
for i := range devices {
|
for i := range devices {
|
||||||
if u.DeviceID == devices[i].DeviceID && u.PCIID == devices[i].PCIID {
|
if u.DeviceID == devices[i].DeviceID && u.PCIID == devices[i].PCIID {
|
||||||
|
|||||||
@@ -361,7 +361,7 @@ func ByLibrary(l []DeviceInfo) [][]DeviceInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func LibraryPaths(l []DeviceInfo) []string {
|
func LibraryPaths(l []DeviceInfo) []string {
|
||||||
var gpuLibs []string
|
gpuLibs := []string{LibOllamaPath}
|
||||||
for _, gpu := range l {
|
for _, gpu := range l {
|
||||||
for _, dir := range gpu.LibraryPath {
|
for _, dir := range gpu.LibraryPath {
|
||||||
needed := true
|
needed := true
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package discover
|
package ml
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
Reference in New Issue
Block a user