()
| 91 | } |
| 92 | |
| 93 | func (s *SystemState) getSystemCapabilities() string { |
| 94 | |
| 95 | if s.systemCapabilities != "" { |
| 96 | return s.systemCapabilities |
| 97 | } |
| 98 | |
| 99 | capability := os.Getenv(capabilityEnv) |
| 100 | if capability != "" { |
| 101 | xlog.Info("Using forced capability from environment variable", "capability", capability, "env", capabilityEnv) |
| 102 | s.systemCapabilities = capability |
| 103 | return capability |
| 104 | } |
| 105 | |
| 106 | capabilityRunFile := defaultRunFile |
| 107 | capabilityRunFileEnv := os.Getenv(capabilityRunFileEnv) |
| 108 | if capabilityRunFileEnv != "" { |
| 109 | capabilityRunFile = capabilityRunFileEnv |
| 110 | } |
| 111 | |
| 112 | // Check if /run/localai/capability exists and use it |
| 113 | // This might be used by e.g. container images to specify which |
| 114 | // backends to pull in automatically when installing meta backends. |
| 115 | if _, err := os.Stat(capabilityRunFile); err == nil { |
| 116 | capability, err := os.ReadFile(capabilityRunFile) |
| 117 | if err == nil { |
| 118 | xlog.Info("Using forced capability run file", "capabilityRunFile", capabilityRunFile, "capability", string(capability), "env", capabilityRunFileEnv) |
| 119 | s.systemCapabilities = strings.Trim(strings.TrimSpace(string(capability)), "\n") |
| 120 | return s.systemCapabilities |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | // If we are on mac and arm64, we will return metal |
| 125 | if runtime.GOOS == "darwin" && runtime.GOARCH == "arm64" { |
| 126 | xlog.Info("Using metal capability (arm64 on mac)", "env", capabilityEnv) |
| 127 | s.systemCapabilities = metal |
| 128 | return s.systemCapabilities |
| 129 | } |
| 130 | |
| 131 | // If we are on mac and x86, we will return darwin-x86 |
| 132 | if runtime.GOOS == "darwin" && runtime.GOARCH == "amd64" { |
| 133 | xlog.Info("Using darwin-x86 capability (amd64 on mac)", "env", capabilityEnv) |
| 134 | s.systemCapabilities = darwinX86 |
| 135 | return s.systemCapabilities |
| 136 | } |
| 137 | |
| 138 | // If arm64 on linux and a nvidia gpu is detected, we will return nvidia-l4t |
| 139 | if runtime.GOOS == "linux" && runtime.GOARCH == "arm64" { |
| 140 | if s.GPUVendor == Nvidia { |
| 141 | xlog.Info("Using nvidia-l4t capability (arm64 on linux)", "env", capabilityEnv) |
| 142 | if cuda13DirExists { |
| 143 | s.systemCapabilities = nvidiaL4TCuda13 |
| 144 | return s.systemCapabilities |
| 145 | } |
| 146 | if cuda12DirExists { |
| 147 | s.systemCapabilities = nvidiaL4TCuda12 |
| 148 | return s.systemCapabilities |
| 149 | } |
| 150 | s.systemCapabilities = nvidiaL4T |
no outgoing calls
no test coverage detected