diff --git a/core/gallery/backend_types.go b/core/gallery/backend_types.go index 439355a46..855195219 100644 --- a/core/gallery/backend_types.go +++ b/core/gallery/backend_types.go @@ -3,6 +3,7 @@ package gallery import ( "github.com/mudler/LocalAI/core/config" "github.com/mudler/LocalAI/pkg/system" + "github.com/rs/zerolog/log" ) // BackendMetadata represents the metadata stored in a JSON file for each installed backend @@ -33,9 +34,11 @@ func (backend *GalleryBackend) FindBestBackendFromMeta(systemState *system.Syste realBackend := backend.CapabilitiesMap[systemState.Capability(backend.CapabilitiesMap)] if realBackend == "" { + log.Debug().Str("backend", backend.Name).Str("reportedCapability", systemState.Capability(backend.CapabilitiesMap)).Msg("No backend found for reported capability") return nil } + log.Debug().Str("backend", backend.Name).Str("reportedCapability", systemState.Capability(backend.CapabilitiesMap)).Msg("Found backend for reported capability") return backends.FindByName(realBackend) } diff --git a/core/services/backends.go b/core/services/backends.go index fe6446b55..143c1bd14 100644 --- a/core/services/backends.go +++ b/core/services/backends.go @@ -24,6 +24,7 @@ func (g *GalleryService) backendHandler(op *GalleryOp[gallery.GalleryBackend], s g.modelLoader.DeleteExternalBackend(op.GalleryElementName) } else { log.Warn().Msgf("installing backend %s", op.GalleryElementName) + log.Debug().Msgf("backend galleries: %v", g.appConfig.BackendGalleries) err = gallery.InstallBackendFromGallery(g.appConfig.BackendGalleries, systemState, op.GalleryElementName, g.appConfig.BackendsPath, progressCallback, true) if err == nil { err = gallery.RegisterBackends(g.appConfig.BackendsPath, g.modelLoader) diff --git a/pkg/system/capabilities.go b/pkg/system/capabilities.go index 8d86fa9a3..9a45d0772 100644 --- a/pkg/system/capabilities.go +++ b/pkg/system/capabilities.go @@ -25,20 +25,24 @@ func (s *SystemState) Capability(capMap map[string]string) string { // Check if the reported capability is in the map if _, exists := capMap[reportedCapability]; exists { + log.Debug().Str("reportedCapability", reportedCapability).Any("capMap", capMap).Msg("Using reported capability") return reportedCapability } + log.Debug().Str("reportedCapability", reportedCapability).Any("capMap", capMap).Msg("The requested capability was not found, using default capability") // Otherwise, return the default capability (catch-all) return defaultCapability } func (s *SystemState) getSystemCapabilities() string { if os.Getenv("LOCALAI_FORCE_META_BACKEND_CAPABILITY") != "" { + log.Debug().Str("LOCALAI_FORCE_META_BACKEND_CAPABILITY", os.Getenv("LOCALAI_FORCE_META_BACKEND_CAPABILITY")).Msg("Using forced capability") return os.Getenv("LOCALAI_FORCE_META_BACKEND_CAPABILITY") } capabilityRunFile := "/run/localai/capability" if os.Getenv("LOCALAI_FORCE_META_BACKEND_CAPABILITY_RUN_FILE") != "" { + log.Debug().Str("LOCALAI_FORCE_META_BACKEND_CAPABILITY_RUN_FILE", os.Getenv("LOCALAI_FORCE_META_BACKEND_CAPABILITY_RUN_FILE")).Msg("Using forced capability run file") capabilityRunFile = os.Getenv("LOCALAI_FORCE_META_BACKEND_CAPABILITY_RUN_FILE") } @@ -48,31 +52,37 @@ func (s *SystemState) getSystemCapabilities() string { if _, err := os.Stat(capabilityRunFile); err == nil { capability, err := os.ReadFile(capabilityRunFile) if err == nil { - return string(capability) + log.Debug().Str("capability", string(capability)).Msg("Using capability from run file") + return strings.Trim(strings.TrimSpace(string(capability)), "\n") } } // If we are on mac and arm64, we will return metal if runtime.GOOS == "darwin" && runtime.GOARCH == "arm64" { + log.Debug().Msg("Using metal capability") return metal } // If we are on mac and x86, we will return darwin-x86 if runtime.GOOS == "darwin" && runtime.GOARCH == "amd64" { + log.Debug().Msg("Using darwin-x86 capability") return darwinX86 } // If arm64 on linux and a nvidia gpu is detected, we will return nvidia-l4t if runtime.GOOS == "linux" && runtime.GOARCH == "arm64" { if s.GPUVendor == "nvidia" { + log.Debug().Msg("Using nvidia-l4t capability") return nvidiaL4T } } if s.GPUVendor == "" { + log.Debug().Msg("Using default capability") return defaultCapability } + log.Debug().Str("GPUVendor", s.GPUVendor).Msg("Using GPU vendor capability") return s.GPUVendor }