Skip to content

Commit d86b489

Browse files
team-coding-agent-1localai-bot
authored andcommitted
fix: add capability fallback for versioned CUDA backends
When the system reports 'nvidia-cuda-13' but the meta backend only has 'nvidia' in its capabilities map, we now try stripping the version suffix to find a parent capability match. This resolves issue mudler#8509 where installing the faster-whisper backend fails when a CUDA variant like cuda13-faster-whisper is already installed. The implementation adds a three-tier fallback strategy: 1. First try exact capability match (e.g., nvidia-cuda-13) 2. If not found, try parent capability by stripping version suffix (e.g., nvidia-cuda-13 -> nvidia) 3. Finally try 'default' capability Signed-off-by: localai-bot <localai-bot@users.noreply.github.com>
1 parent 00abf1b commit d86b489

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

pkg/system/capabilities.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77
"path/filepath"
88
"runtime"
9+
"strconv"
910
"strings"
1011

1112
"github.com/mudler/xlog"
@@ -65,11 +66,47 @@ func (s *SystemState) Capability(capMap map[string]string) string {
6566
return reportedCapability
6667
}
6768

69+
// Try parent capability by stripping version suffix (e.g., "nvidia-cuda-13" -> "nvidia")
70+
parentCapability := stripVersionSuffix(reportedCapability)
71+
if parentCapability != reportedCapability {
72+
if _, exists := capMap[parentCapability]; exists {
73+
xlog.Debug("Using parent capability after stripping version", "reportedCapability", reportedCapability, "parentCapability", parentCapability, "capMap", capMap)
74+
return parentCapability
75+
}
76+
}
77+
6878
xlog.Debug("The requested capability was not found, using default capability", "reportedCapability", reportedCapability, "capMap", capMap)
6979
// Otherwise, return the default capability (catch-all)
7080
return defaultCapability
7181
}
7282

83+
// stripVersionSuffix removes version suffixes from capability strings.
84+
// For example: "nvidia-cuda-13" -> "nvidia", "nvidia-l4t-cuda-12" -> "nvidia-l4t"
85+
func stripVersionSuffix(capability string) string {
86+
// Remove trailing "-cuda-XX", "-rocm-XX", etc.
87+
// Pattern: remove the last "-<number>" or "-<number>-<number>" suffix
88+
parts := strings.Split(capability, "-")
89+
90+
// If the last part is a number or number-number, remove it
91+
if len(parts) >= 2 {
92+
lastPart := parts[len(parts)-1]
93+
secondLast := parts[len(parts)-2]
94+
95+
// Check if last part is a number
96+
if _, err := strconv.Atoi(lastPart); err == nil {
97+
// Check if second last is also a number (e.g., "cuda-12")
98+
if _, err := strconv.Atoi(secondLast); err == nil {
99+
// Both are numbers, remove both (e.g., "nvidia-cuda-12" -> "nvidia")
100+
return strings.Join(parts[:len(parts)-2], "-")
101+
}
102+
// Only last is a number, remove just the last (e.g., "nvidia-cuda-13" -> "nvidia")
103+
return strings.Join(parts[:len(parts)-1], "-")
104+
}
105+
}
106+
107+
return capability
108+
}
109+
73110
func (s *SystemState) getSystemCapabilities() string {
74111

75112
if s.systemCapabilities != "" {

0 commit comments

Comments
 (0)