-
Notifications
You must be signed in to change notification settings - Fork 116
Expand file tree
/
Copy pathmemory_windows.go
More file actions
46 lines (41 loc) · 1.2 KB
/
memory_windows.go
File metadata and controls
46 lines (41 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package gpuinfo
import (
"bufio"
"context"
"errors"
"os/exec"
"path/filepath"
"runtime"
"strconv"
"strings"
"time"
)
// getVRAMSize returns total system GPU memory in bytes
func getVRAMSize(modelRuntimeInstallPath string) (uint64, error) {
if runtime.GOARCH == "arm64" {
// TODO(p1-0tr): For now, on windows/arm64, stick to the old behaviour. This will
// require backend.GetRequiredMemoryForModel to return 1 as well.
return 1, nil
}
nvGPUInfoBin := filepath.Join(modelRuntimeInstallPath, "bin", "com.docker.nv-gpu-info.exe")
ctx, _ := context.WithTimeout(context.Background(), 30*time.Second)
cmd := exec.CommandContext(ctx, nvGPUInfoBin)
out, err := cmd.CombinedOutput()
if err != nil {
return 0, err
}
sc := bufio.NewScanner(strings.NewReader(string(out)))
for sc.Scan() {
vram, found := strings.CutPrefix(sc.Text(), "GPU[0]: dedicated memory:")
if found {
vram = strings.TrimSpace(vram)
return strconv.ParseUint(vram, 10, 64)
}
}
return 0, errors.New("unexpected nv-gpu-info output format")
}
// hasSupportedAMDGPU returns true if the system has supported AMD GPUs
func hasSupportedAMDGPU() (bool, error) {
// AMD GPU detection is only supported on Linux
return false, nil
}