mirror of
https://github.com/mudler/LocalAI.git
synced 2026-02-16 15:09:09 -06:00
chore: memoize detected GPUs (#5385)
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
committed by
GitHub
parent
cfc73c7773
commit
159388cce8
@@ -2,18 +2,29 @@ package xsysinfo
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/jaypipes/ghw"
|
||||
"github.com/jaypipes/ghw/pkg/gpu"
|
||||
)
|
||||
|
||||
func GPUs() ([]*gpu.GraphicsCard, error) {
|
||||
gpu, err := ghw.GPU()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var (
|
||||
gpuCache []*gpu.GraphicsCard
|
||||
gpuCacheOnce sync.Once
|
||||
gpuCacheErr error
|
||||
)
|
||||
|
||||
return gpu.GraphicsCards, nil
|
||||
func GPUs() ([]*gpu.GraphicsCard, error) {
|
||||
gpuCacheOnce.Do(func() {
|
||||
gpu, err := ghw.GPU()
|
||||
if err != nil {
|
||||
gpuCacheErr = err
|
||||
return
|
||||
}
|
||||
gpuCache = gpu.GraphicsCards
|
||||
})
|
||||
|
||||
return gpuCache, gpuCacheErr
|
||||
}
|
||||
|
||||
func TotalAvailableVRAM() (uint64, error) {
|
||||
|
||||
Reference in New Issue
Block a user