File tree Expand file tree Collapse file tree 7 files changed +38
-103
lines changed
Expand file tree Collapse file tree 7 files changed +38
-103
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ func main() {
9090 log .Fatalf ("unable to initialize %s backend: %v" , llamacpp .Name , err )
9191 }
9292
93- gpuInfo := gpuinfo .New ()
93+ gpuInfo := gpuinfo .New (llamaServerPath )
9494
9595 scheduler := scheduling .NewScheduler (
9696 log ,
Original file line number Diff line number Diff line change 11package gpuinfo
22
3- type GPUInfo struct {}
3+ type GPUInfo struct {
4+ // modelRuntimeInstallPath is the location where DMR installed it's llama-server
5+ // and accompanying tools
6+ modelRuntimeInstallPath string
7+ }
48
5- func New () * GPUInfo {
6- return & GPUInfo {}
9+ func New (modelRuntimeInstallPath string ) * GPUInfo {
10+ return & GPUInfo {
11+ modelRuntimeInstallPath : modelRuntimeInstallPath ,
12+ }
713}
814
915func (g * GPUInfo ) GetVRAMSize () (uint64 , error ) {
10- return getVRAMSize ()
16+ return getVRAMSize (g . modelRuntimeInstallPath )
1117}
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import "C"
88import "errors"
99
1010// getVRAMSize returns total system GPU memory in bytes
11- func getVRAMSize () (uint64 , error ) {
11+ func getVRAMSize (_ string ) (uint64 , error ) {
1212 vramSize := C .getVRAMSize ()
1313 if vramSize == 0 {
1414 return 0 , errors .New ("could not get metal VRAM size" )
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import "C"
88import "errors"
99
1010// getVRAMSize returns total system GPU memory in bytes
11- func getVRAMSize () (uint64 , error ) {
11+ func getVRAMSize (_ string ) (uint64 , error ) {
1212 vramSize := C .getVRAMSize ()
1313 if vramSize == 0 {
1414 return 0 , errors .New ("could not get nvidia VRAM size" )
Original file line number Diff line number Diff line change 11package gpuinfo
22
3- /*
4- #include "nvapi.h"
5- */
6- import "C"
7- import "errors"
3+ import (
4+ "bufio"
5+ "context"
6+ "errors"
7+ "os/exec"
8+ "path/filepath"
9+ "strconv"
10+ "strings"
11+ )
812
913// getVRAMSize returns total system GPU memory in bytes
10- func getVRAMSize () (uint64 , error ) {
11- vramSize := C .getVRAMSize ()
12- if vramSize == 0 {
13- return 0 , errors .New ("could not get nvapi VRAM size" )
14+ func getVRAMSize (ctx context.Context , modelRuntimeInstallPath string ) (uint64 , error ) {
15+ nvGPUInfoBin := filepath .Join (modelRuntimeInstallPath , "com.docker.nv-gpu-info.exe" )
16+
17+ cmd := exec .CommandContext (ctx , nvGPUInfoBin )
18+ out , err := cmd .CombinedOutput ()
19+ if err != nil {
20+ return 0 , err
21+ }
22+ sc := bufio .NewScanner (strings .NewReader (string (out )))
23+ for sc .Scan () {
24+ vram , found := strings .CutPrefix (sc .Text (), "GPU[0]: dedicated memory:" )
25+ if found {
26+ vram = strings .TrimSpace (vram )
27+ return strconv .ParseUint (vram , 10 , 64 )
28+ }
1429 }
15- return uint64 ( vramSize ), nil
30+ return 0 , errors . New ( "unexpected nv-gpu-info output format" )
1631}
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments