()
| 190 | } |
| 191 | |
| 192 | func getCurrentDriver() (nvconf.DriverVersion, error) { |
| 193 | _, err := os.Stat(nvidiaSMIPath) |
| 194 | // If the nvidia-smi executable does not exist, then we don't have a driver installed. |
| 195 | if os.IsNotExist(err) { |
| 196 | return nvconf.DriverVersion{}, fmt.Errorf("nvidia-smi does not exist at path: %q", nvidiaSMIPath) |
| 197 | } |
| 198 | if err != nil { |
| 199 | return nvconf.DriverVersion{}, fmt.Errorf("failed to stat nvidia-smi: %w", err) |
| 200 | } |
| 201 | out, err := exec.Command(nvidiaSMIPath, []string{"--query-gpu", "driver_version", "--format=csv,noheader"}...).CombinedOutput() |
| 202 | if err != nil { |
| 203 | log.Warningf("failed to run nvidia-smi: %v", err) |
| 204 | return nvconf.DriverVersion{}, fmt.Errorf("failed to run nvidia-smi: %w", err) |
| 205 | } |
| 206 | // If there are multiple GPUs, there will be one version per line. |
| 207 | // Make sure they are all the same version. |
| 208 | sameVersion := "" |
| 209 | for _, line := range strings.Split(string(out), "\n") { |
| 210 | line = strings.TrimSpace(line) |
| 211 | if line == "" { |
| 212 | continue |
| 213 | } |
| 214 | if sameVersion == "" { |
| 215 | sameVersion = line |
| 216 | continue |
| 217 | } |
| 218 | if line != sameVersion { |
| 219 | return nvconf.DriverVersion{}, fmt.Errorf("multiple driver versions found: %q and %q", sameVersion, line) |
| 220 | } |
| 221 | } |
| 222 | if sameVersion == "" { |
| 223 | return nvconf.DriverVersion{}, fmt.Errorf("no driver version found") |
| 224 | } |
| 225 | return nvconf.DriverVersionFrom(sameVersion) |
| 226 | } |
| 227 | |
| 228 | // ListSupportedDrivers prints the driver to stderr in a format that can be |
| 229 | // consumed by the Makefile to iterate tests across drivers. |
nothing calls this directly
no test coverage detected
searching dependent graphs…