GPUOptions returns the GPU type identifiers available in any size, ordered by gpuDisplayOrder. Out-of-stock types are preserved in the list but pushed to the bottom.
()
| 88 | // ordered by gpuDisplayOrder. Out-of-stock types are preserved in the list but |
| 89 | // pushed to the bottom. |
| 90 | func (s *SpecStore) GPUOptions() []string { |
| 91 | seen := map[string]bool{} |
| 92 | for key := range s.specs { |
| 93 | gpuType := strings.Split(key, "_x")[0] |
| 94 | seen[gpuType] = true |
| 95 | } |
| 96 | var ordered []string |
| 97 | for _, gpu := range gpuDisplayOrder { |
| 98 | if seen[gpu] { |
| 99 | ordered = append(ordered, gpu) |
| 100 | } |
| 101 | } |
| 102 | for gpuType := range seen { |
| 103 | if !slices.Contains(gpuDisplayOrder, gpuType) { |
| 104 | ordered = append(ordered, gpuType) |
| 105 | } |
| 106 | } |
| 107 | var available, unavailable []string |
| 108 | for _, gpu := range ordered { |
| 109 | if s.IsGPUTypeAvailable(gpu) { |
| 110 | available = append(available, gpu) |
| 111 | } else { |
| 112 | unavailable = append(unavailable, gpu) |
| 113 | } |
| 114 | } |
| 115 | return append(available, unavailable...) |
| 116 | } |
| 117 | |
| 118 | // GPUCounts returns all valid GPU counts for a given GPU type, sorted. |
| 119 | func (s *SpecStore) GPUCounts(gpuType string) []int { |